From 37550ffe611777e5fefd31d4f1d8aba0afb9c1b8 Mon Sep 17 00:00:00 2001 From: Ayoub Fletcher <11021965+ayoubfletcher@users.noreply.github.com> Date: Sun, 13 Aug 2023 09:30:49 +0100 Subject: [PATCH] Docker And Docker-Compose Support (#538) * Added Docker support. * Fixed a typo. * Added .dockerignore * Update README.md Co-authored-by: karlderkaefer --------- Co-authored-by: MurdieX Co-authored-by: karlderkaefer --- .dockerignore | 60 ++++++++++++++++++++++++++++++++++++++++++++++ Dockerfile | 12 ++++++++++ README.md | 24 +++++++++++++++++++ docker-compose.yml | 19 +++++++++++++++ entrypoint.sh | 14 +++++++++++ 5 files changed, 129 insertions(+) create mode 100644 .dockerignore create mode 100644 Dockerfile create mode 100644 docker-compose.yml create mode 100644 entrypoint.sh diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000000..58b0fc0985 --- /dev/null +++ b/.dockerignore @@ -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 diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000000..dd81969641 --- /dev/null +++ b/Dockerfile @@ -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"] diff --git a/README.md b/README.md index 2bd45c46d1..ba11edc810 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000000..1e92f05776 --- /dev/null +++ b/docker-compose.yml @@ -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 + diff --git a/entrypoint.sh b/entrypoint.sh new file mode 100644 index 0000000000..6c6228ce58 --- /dev/null +++ b/entrypoint.sh @@ -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 +