Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docker And Docker-Compose Support #538

Merged
merged 4 commits into from
Aug 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 60 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# See https://help.github.com/ignore-files/ for more about ignoring files.

# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# Distribution / packaging
dist/
build/
*.egg-info/
*.egg

# Virtual environments
.env
.env.sh
venv/
ENV/

# IDE-specific files
.vscode/
.idea/

# Compiled Python modules
*.pyc
*.pyo
*.pyd

# Python testing
.pytest_cache/
.ruff_cache/
.coverage
.mypy_cache/

# macOS specific files
.DS_Store

# Windows specific files
Thumbs.db

# this application's specific files
archive

# any log file
*log.txt
todo
scratchpad

# Ignore GPT Engineer files
projects
!projects/example

# Pyenv
.python-version

# Benchmark files
benchmark
!benchmark/*/prompt

.gpte_consent
12 changes: 12 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
FROM python:3.9-slim

RUN apt-get update \
&& apt-get install -y sudo

WORKDIR /app

COPY . .

RUN sudo pip install -e .

ENTRYPOINT ["bash", "/app/entrypoint.sh"]
24 changes: 24 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,30 @@ To **run in the browser** you can simply:
[![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)](https://github.com/AntonOsika/gpt-engineer/codespaces)


## Getting Started using Docker

**Running using docker cli**:

Building the image:
- `git clone https://github.com/AntonOsika/gpt-engineer.git`
- `cd gpt-engineer`
- `docker build --rm -t gpt-engineer .`

Running the container:
- `docker run -it --rm -e OPENAI_API_KEY="YOUR OPENAI KEY" -v ./your-project:/project gpt-engineer`

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

**Running using docker-compose cli**:

Building the image:
- `git clone https://github.com/AntonOsika/gpt-engineer.git`
- `cd gpt-engineer`
- `docker-compose build`
- `docker-compose run --rm gpt-engineer`

Set the OPENAI_API_KEY in 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.


## Features

Expand Down
19 changes: 19 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
version: "3"

services:
gpt-engineer:
build:
context: .
dockerfile: Dockerfile
stdin_open: true
tty: true
# Set the API key from the .env file
env_file:
- .env
## OR set the API key directly
# environment:
# - OPENAI_API_KEY="YOUR_API_KEY_HERE"
image: gpt-engineer
volumes:
- ./projects/example:/project

14 changes: 14 additions & 0 deletions entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/bash
project_dir="/project"

# Run the gpt engineer script
gpt-engineer $project_dir "$@"

# Patch the permissions of the generated files to be owned by nobody except prompt file
for item in "$project_dir"/*; do
if [[ "$item" != "$project_dir/prompt" ]]; then
chown -R nobody:nogroup "$item"
chmod -R 777 "$item"
fi
done