From 5da1ae08b94cc191da8f77756d3f5cddecd4acc4 Mon Sep 17 00:00:00 2001 From: Plamen Ivanov Date: Fri, 30 Jun 2023 13:28:45 +0300 Subject: [PATCH 1/3] refactor(makefile): :recycle: remove repetitive command --- Makefile | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/Makefile b/Makefile index 98d9213f59..65ee829ec0 100644 --- a/Makefile +++ b/Makefile @@ -5,7 +5,7 @@ COLOR_RESET=\033[0m COLOR_CYAN=\033[1;36m COLOR_GREEN=\033[1;32m -.PHONY: help install dev-install run +.PHONY: help install run .DEFAULT_GOAL := help @@ -17,11 +17,8 @@ help: @echo "Please use 'make ' where is one of the following:" @echo " help Return this message with usage instructions." @echo " install Will install the dependencies and create a virtual environment." - @echo " dev-install Will install the dev dependencies too." @echo " run Runs GPT Engineer on the folder with the given name." -dev-install: install - install: create-venv upgrade-pip install-dependencies install-pre-commit farewell create-venv: From 5a3a79d0f83379574320b61ed71c264cdbb3bd57 Mon Sep 17 00:00:00 2001 From: Plamen Ivanov Date: Tue, 13 Feb 2024 23:44:23 +0200 Subject: [PATCH 2/3] chore(Dockerfile): Refactor Dockerfile to use multi-stage build - Change base image from python:3.11-slim to python:3.11-alpine in the builder stage - Use apk package manager instead of apt-get to install dependencies - Remove unnecessary sudo command - Use pip install --no-cache-dir instead of pip install - Add second stage in Dockerfile for final image - Copy dependencies and entrypoint script from builder stage to final stage Signed-off-by: Plamen Ivanov --- docker/Dockerfile | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/docker/Dockerfile b/docker/Dockerfile index 4c7a409dcc..3ea269d051 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -1,13 +1,23 @@ -FROM python:3.11-slim +# Stage 1: Builder stage +FROM python:3.11-alpine AS builder -RUN apt-get update \ - && apt-get install -y sudo tk tcl gcc curl +RUN apk update && apk add --no-cache tk tcl curl WORKDIR /app COPY . . -COPY docker/entrypoint.sh ./entrypoint.sh -RUN sudo pip install -e . +RUN pip install --no-cache-dir -e . -ENTRYPOINT ["bash", "/app/entrypoint.sh"] +# Stage 2: Final stage +FROM python:3.11-alpine + +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 /app . + +COPY docker/entrypoint.sh . + +ENTRYPOINT ["sh", "/app/entrypoint.sh"] From 2988e892b913169eeeefa9d5ca844ae7b33fef84 Mon Sep 17 00:00:00 2001 From: Plamen Ivanov Date: Tue, 13 Feb 2024 23:45:00 +0200 Subject: [PATCH 3/3] chore(entrypoint.sh): update shebang to use `/usr/bin/env sh` - add coding utf-8 declaration - use `find` command to patch permissions of generated files Signed-off-by: Plamen Ivanov --- docker/entrypoint.sh | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/docker/entrypoint.sh b/docker/entrypoint.sh index bb22cc0da9..49a3580130 100644 --- a/docker/entrypoint.sh +++ b/docker/entrypoint.sh @@ -1,13 +1,10 @@ -#!/bin/bash +#!/usr/bin/env sh +# -*- coding: utf-8 -*- + 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 +find "$project_dir" -mindepth 1 -maxdepth 1 ! -path "$project_dir/prompt" -exec chown -R nobody:nogroup {} + -exec chmod -R 777 {} +