Skip to content
This repository was archived by the owner on Apr 22, 2026. It is now read-only.

Commit d5a73ab

Browse files
authored
Docker performance improvements and reduce image size (#1016)
* refactor(makefile): ♻️ remove repetitive command * 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 <paco.iwanow@gmail.com> * 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 <paco.iwanow@gmail.com> --------- Signed-off-by: Plamen Ivanov <paco.iwanow@gmail.com>
1 parent 164730a commit d5a73ab

2 files changed

Lines changed: 20 additions & 13 deletions

File tree

docker/Dockerfile

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,23 @@
1-
FROM python:3.11-slim
1+
# Stage 1: Builder stage
2+
FROM python:3.11-alpine AS builder
23

3-
RUN apt-get update \
4-
&& apt-get install -y sudo tk tcl gcc curl
4+
RUN apk update && apk add --no-cache tk tcl curl
55

66
WORKDIR /app
77

88
COPY . .
9-
COPY docker/entrypoint.sh ./entrypoint.sh
109

11-
RUN sudo pip install -e .
10+
RUN pip install --no-cache-dir -e .
1211

13-
ENTRYPOINT ["bash", "/app/entrypoint.sh"]
12+
# Stage 2: Final stage
13+
FROM python:3.11-alpine
14+
15+
WORKDIR /app
16+
17+
COPY --from=builder /usr/local/lib/python3.11/site-packages /usr/local/lib/python3.11/site-packages
18+
COPY --from=builder /usr/local/bin /usr/local/bin
19+
COPY --from=builder /app .
20+
21+
COPY docker/entrypoint.sh .
22+
23+
ENTRYPOINT ["sh", "/app/entrypoint.sh"]

docker/entrypoint.sh

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,10 @@
1-
#!/bin/bash
1+
#!/usr/bin/env sh
2+
# -*- coding: utf-8 -*-
3+
24
project_dir="/project"
35

46
# Run the gpt engineer script
57
gpt-engineer $project_dir "$@"
68

79
# Patch the permissions of the generated files to be owned by nobody except prompt file
8-
for item in "$project_dir"/*; do
9-
if [[ "$item" != "$project_dir/prompt" ]]; then
10-
chown -R nobody:nogroup "$item"
11-
chmod -R 777 "$item"
12-
fi
13-
done
10+
find "$project_dir" -mindepth 1 -maxdepth 1 ! -path "$project_dir/prompt" -exec chown -R nobody:nogroup {} + -exec chmod -R 777 {} +

0 commit comments

Comments
 (0)