Skip to content

Commit

Permalink
Docker And Docker-Compose Support (AntonOsika#538)
Browse files Browse the repository at this point in the history
* Added Docker support.

* Fixed a typo.

* Added .dockerignore

* Update README.md

Co-authored-by: karlderkaefer <karlderkaefer@users.noreply.github.com>

---------

Co-authored-by: MurdieX <Ayoub Fletcher>
Co-authored-by: karlderkaefer <karlderkaefer@users.noreply.github.com>
  • Loading branch information
youbamj and karlderkaefer authored Aug 13, 2023
1 parent 95c8655 commit 37550ff
Show file tree
Hide file tree
Showing 5 changed files with 129 additions and 0 deletions.
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

0 comments on commit 37550ff

Please sign in to comment.