Skip to content

Commit

Permalink
Merge pull request #1161 from k1lgor/hotfix/docker-image
Browse files Browse the repository at this point in the history
Hotfix/docker image
  • Loading branch information
viborc authored Jun 6, 2024
2 parents 5f9d7ac + e54f070 commit 1e292f4
Show file tree
Hide file tree
Showing 6 changed files with 5,099 additions and 4,966 deletions.
2 changes: 0 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
version: "3"

services:
gpt-engineer:
build:
Expand Down
14 changes: 10 additions & 4 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
# Stage 1: Builder stage
FROM python:3.11-alpine AS builder
FROM python:3.11-slim AS builder

RUN apk update && apk add --no-cache tk tcl curl
RUN apt-get update && apt-get install -y --no-install-recommends \
tk \
tcl \
curl \
git \
&& rm -rf /var/lib/apt/lists/*

WORKDIR /app

Expand All @@ -10,14 +15,15 @@ COPY . .
RUN pip install --no-cache-dir -e .

# Stage 2: Final stage
FROM python:3.11-alpine
FROM python:3.11-slim

WORKDIR /app

COPY --from=builder /usr/local/lib/python3.11/site-packages /usr/local/lib/python3.11/site-packages
COPY --from=builder /usr/local/bin /usr/local/bin
COPY --from=builder /usr/bin /usr/bin
COPY --from=builder /app .

COPY docker/entrypoint.sh .

ENTRYPOINT ["sh", "/app/entrypoint.sh"]
ENTRYPOINT ["bash", "/app/entrypoint.sh"]
77 changes: 61 additions & 16 deletions docker/README.md
Original file line number Diff line number Diff line change
@@ -1,24 +1,69 @@
# Getting Started using Docker
# Getting Started Using Docker

**Running using docker cli**:
This guide provides step-by-step instructions on how to set up and run the Docker environment for your GPT-Engineer project.

Building the image:
- `git clone https://github.com/gpt-engineer-org/gpt-engineer.git`
- `cd gpt-engineer`
- `docker build --rm -t gpt-engineer -f docker/Dockerfile .`
## Prerequisites

Running the container:
- `docker run -it --rm -e OPENAI_API_KEY="YOUR OPENAI KEY" -v ./your-project:/project gpt-engineer`
- Docker installed on your machine.
- Git (for cloning the repository).

The `-v` flag mounts the `your-project` folder into the container. Make sure to have a `prompt` file in there.
## Setup Instructions

**Running using docker-compose cli**:
### Using Docker CLI

Building the image:
- `git clone https://github.com/gpt-engineer-org/gpt-engineer.git`
- `cd gpt-engineer`
- `docker-compose -f docker-compose.yml build`
- `docker-compose run --rm gpt-engineer`
1. **Clone the Repository**

```bash
git clone https://github.com/gpt-engineer-org/gpt-engineer.git
cd gpt-engineer
```

Set the OPENAI_API_KEY in docker/docker-compose.yml using .env file or environment variable, and mount your project folder into the container using volumes. for example "./projects/example:/project" ./projects/example is the path to your project folder.
2. **Build the Docker Image**

```bash
docker build --rm -t gpt-engineer -f docker/Dockerfile .
```

3. **Run the Docker Container**

```bash
docker run -it --rm -e OPENAI_API_KEY="YOUR_OPENAI_KEY" -v ./your-project:/project gpt-engineer
```

Replace `YOUR_OPENAI_KEY` with your actual OpenAI API key. The `-v` flag mounts your local `your-project` directory inside the container. Replace this with your actual project directory. Ensure this directory contains all necessary files, including the `prompt` file.

### Using Docker Compose

1. **Clone the Repository** (if not already done)

```bash
git clone https://github.com/gpt-engineer-org/gpt-engineer.git
cd gpt-engineer
```

2. **Build and Run using Docker Compose**

```bash
docker-compose -f docker-compose.yml build
docker-compose run --rm gpt-engineer
```

Set the `OPENAI_API_KEY` in the `docker/docker-compose.yml` using an `.env` file or as an environment variable. Mount your project directory to the container using volumes, e.g., `"./projects/example:/project"` where `./projects/example` is the path to your project directory.

3. **Another alternative using Docker Compose**

Since there is only one `docker-compose.yml` file, you could run it without the -f option.
- `docker compose up -d --build` - To build and start the containers defined in your `docker-compose.yml` file in detached mode
- `docker compose up -d` - To start the containers defined in your `docker-compose.yml` file in detached mode
- `docker compose down` - To stop and remove all containers, networks, and volumes associated with the `docker-compose.yml`
- `docker compose restart` - To restart the containers defined in the `docker-compose.yml` file

## Debugging

To facilitate debugging, you can run a shell inside the built Docker image:

```bash
docker run -it --entrypoint /bin/bash gpt-engineer
```

This opens a shell inside the Docker container, allowing you to execute commands and inspect the environment manually.
2 changes: 1 addition & 1 deletion docker/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env sh
#!/usr/bin/env bash
# -*- coding: utf-8 -*-

project_dir="/project"
Expand Down
Loading

0 comments on commit 1e292f4

Please sign in to comment.