Skip to content

Commit 0f9d39c

Browse files
committed
feat(Dockerfile): switch from alpine to slim base image and add git to installed packages
feat(README.md): enhance Docker setup instructions and add debugging section fix(entrypoint.sh): change shebang from sh to bash
1 parent 5f9d7ac commit 0f9d39c

File tree

3 files changed

+72
-21
lines changed

3 files changed

+72
-21
lines changed

docker/Dockerfile

+10-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
11
# Stage 1: Builder stage
2-
FROM python:3.11-alpine AS builder
2+
FROM python:3.11-slim AS builder
33

4-
RUN apk update && apk add --no-cache tk tcl curl
4+
RUN apt-get update && apt-get install -y --no-install-recommends \
5+
tk \
6+
tcl \
7+
curl \
8+
git \
9+
&& rm -rf /var/lib/apt/lists/*
510

611
WORKDIR /app
712

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

1217
# Stage 2: Final stage
13-
FROM python:3.11-alpine
18+
FROM python:3.11-slim
1419

1520
WORKDIR /app
1621

1722
COPY --from=builder /usr/local/lib/python3.11/site-packages /usr/local/lib/python3.11/site-packages
1823
COPY --from=builder /usr/local/bin /usr/local/bin
24+
COPY --from=builder /usr/bin /usr/bin
1925
COPY --from=builder /app .
2026

2127
COPY docker/entrypoint.sh .
2228

23-
ENTRYPOINT ["sh", "/app/entrypoint.sh"]
29+
ENTRYPOINT ["bash", "/app/entrypoint.sh"]

docker/README.md

+61-16
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,69 @@
1-
# Getting Started using Docker
1+
# Getting Started Using Docker
22

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

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

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

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

15-
**Running using docker-compose cli**:
12+
### Using Docker CLI
1613

17-
Building the image:
18-
- `git clone https://github.com/gpt-engineer-org/gpt-engineer.git`
19-
- `cd gpt-engineer`
20-
- `docker-compose -f docker-compose.yml build`
21-
- `docker-compose run --rm gpt-engineer`
14+
1. **Clone the Repository**
2215

16+
```bash
17+
git clone https://github.com/gpt-engineer-org/gpt-engineer.git
18+
cd gpt-engineer
19+
```
2320

24-
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.
21+
2. **Build the Docker Image**
22+
23+
```bash
24+
docker build --rm -t gpt-engineer -f docker/Dockerfile .
25+
```
26+
27+
3. **Run the Docker Container**
28+
29+
```bash
30+
docker run -it --rm -e OPENAI_API_KEY="YOUR_OPENAI_KEY" -v ./your-project:/project gpt-engineer
31+
```
32+
33+
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.
34+
35+
### Using Docker Compose
36+
37+
1. **Clone the Repository** (if not already done)
38+
39+
```bash
40+
git clone https://github.com/gpt-engineer-org/gpt-engineer.git
41+
cd gpt-engineer
42+
```
43+
44+
2. **Build and Run using Docker Compose**
45+
46+
```bash
47+
docker-compose -f docker-compose.yml build
48+
docker-compose run --rm gpt-engineer
49+
```
50+
51+
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.
52+
53+
3. **Another alternative using Docker Compose**
54+
55+
Since there is only one `docker-compose.yml` file, you could run it without the -f option.
56+
- `docker compose up -d --build` - To build and start the containers defined in your `docker-compose.yml` file in detached mode
57+
- `docker compose up -d` - To start the containers defined in your `docker-compose.yml` file in detached mode
58+
- `docker compose down` - To stop and remove all containers, networks, and volumes associated with the `docker-compose.yml`
59+
- `docker compose restart` - To restart the containers defined in the `docker-compose.yml` file
60+
61+
## Debugging
62+
63+
To facilitate debugging, you can run a shell inside the built Docker image:
64+
65+
```bash
66+
docker run -it --entrypoint /bin/bash gpt-engineer
67+
```
68+
69+
This opens a shell inside the Docker container, allowing you to execute commands and inspect the environment manually.

docker/entrypoint.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/usr/bin/env sh
1+
#!/usr/bin/env bash
22
# -*- coding: utf-8 -*-
33

44
project_dir="/project"

0 commit comments

Comments
 (0)