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 performance improvements and reduce image size #1016

Merged
merged 8 commits into from
Mar 21, 2024
22 changes: 16 additions & 6 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -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"]
11 changes: 4 additions & 7 deletions docker/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -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 {} +
Loading