1
1
FROM python:3.10-slim AS base
2
2
3
- # Install system dependencies
3
+ # Create non-root user first
4
+ RUN useradd -m -u 1000 -s /bin/bash appuser
5
+ ENV HOME=/home/appuser
6
+
7
+ # Create required directories early
8
+ RUN mkdir -p \
9
+ /home/appuser/.aider \
10
+ /home/appuser/.cache \
11
+ /home/appuser/pw-browsers \
12
+ /app \
13
+ /venv && \
14
+ chown -R appuser:appuser \
15
+ /home/appuser \
16
+ /app \
17
+ /venv
18
+
19
+ # Install all system dependencies in one layer
4
20
RUN apt-get update && \
5
- apt-get install --no-install-recommends -y build-essential git libportaudio2 pandoc && \
21
+ apt-get install -y --no-install-recommends \
22
+ build-essential \
23
+ chromium \
24
+ fonts-noto-color-emoji \
25
+ fonts-freefont-ttf \
26
+ git \
27
+ libportaudio2 \
28
+ pandoc \
29
+ xauth \
30
+ xvfb && \
31
+ apt-get clean && \
6
32
rm -rf /var/lib/apt/lists/*
7
33
8
- # Create app user with UID 1000
9
- RUN useradd -m -u 1000 -s /bin/bash appuser
10
-
11
34
WORKDIR /app
12
35
13
- # Create virtual environment
14
- RUN python -m venv /venv
15
- ENV PATH="/venv/bin:$PATH"
16
-
17
- # Playwright browser settings
18
- ENV PLAYWRIGHT_BROWSERS_PATH=/home/appuser/pw-browsers
19
- ENV PLAYWRIGHT_SKIP_BROWSER_GC=1
20
-
21
- # Create directories with proper permissions
22
- RUN mkdir -p /home/appuser/.aider /home/appuser/.cache /home/appuser/pw-browsers && \
23
- chown -R appuser:appuser /home/appuser /app /venv
36
+ # Set up Python environment and Playwright settings
37
+ ENV PATH="/venv/bin:$PATH" \
38
+ PLAYWRIGHT_BROWSERS_PATH=/home/appuser/pw-browsers \
39
+ PLAYWRIGHT_SKIP_BROWSER_GC=1
24
40
25
- # So git doesn't complain about unusual permissions
26
- RUN git config --system --add safe.directory /app
41
+ RUN python -m venv /venv && \
42
+ /venv/bin/pip install --no-cache-dir --upgrade pip
27
43
28
44
# ########################
29
45
FROM base AS aider-full
30
46
31
47
ENV AIDER_DOCKER_IMAGE=paulgauthier/aider-full
32
48
33
- COPY . /tmp/aider
49
+ COPY --chown=appuser:appuser . /tmp/aider
34
50
35
- # Install dependencies as root
36
- RUN /venv/bin/python -m pip install --upgrade -- no-cache-dir pip && \
37
- /venv/bin/python -m pip install --no-cache-dir /tmp/aider[help,browser,playwright] \
38
- --extra-index-url https://download.pytorch.org/whl/cpu && \
39
- rm -rf /tmp/aider
51
+ # Install dependencies as root first
52
+ RUN pip install --no-cache-dir /tmp/aider[help,browser,playwright] \
53
+ --extra-index-url https://download.pytorch.org/whl/cpu && \
54
+ rm -rf /tmp/aider && \
55
+ chown -R appuser:appuser /venv
40
56
41
- # Install playwright browsers
42
- RUN /venv/bin/python -m playwright install --with-deps chromium
43
-
44
- # Fix site-packages permissions
45
- RUN find /venv/lib/python3.10/site-packages \( -type d -exec chmod a+rwx {} + \) -o \( -type f -exec chmod a+rw {} + \)
46
-
47
- # Switch to appuser
57
+ # Switch to non-root user after installations
48
58
USER appuser
59
+ RUN git config --global --add safe.directory /app && \
60
+ playwright install chromium
49
61
50
62
ENTRYPOINT ["/venv/bin/aider" ]
51
63
@@ -54,21 +66,17 @@ FROM base AS aider
54
66
55
67
ENV AIDER_DOCKER_IMAGE=paulgauthier/aider
56
68
57
- COPY . /tmp/aider
58
-
59
- # Install dependencies as root
60
- RUN /venv/bin/python -m pip install --upgrade --no-cache-dir pip && \
61
- /venv/bin/python -m pip install --no-cache-dir /tmp/aider[playwright] \
62
- --extra-index-url https://download.pytorch.org/whl/cpu && \
63
- rm -rf /tmp/aider
64
-
65
- # Install playwright browsers
66
- RUN /venv/bin/python -m playwright install --with-deps chromium
69
+ COPY --chown=appuser:appuser . /tmp/aider
67
70
68
- # Fix site-packages permissions
69
- RUN find /venv/lib/python3.10/site-packages \( -type d -exec chmod a+rwx {} + \) -o \( -type f -exec chmod a+rw {} + \)
71
+ # Install dependencies as root first
72
+ RUN pip install --no-cache-dir /tmp/aider[playwright] \
73
+ --extra-index-url https://download.pytorch.org/whl/cpu && \
74
+ rm -rf /tmp/aider && \
75
+ chown -R appuser:appuser /venv
70
76
71
- # Switch to appuser
77
+ # Switch to non-root user after installations
72
78
USER appuser
79
+ RUN git config --global --add safe.directory /app && \
80
+ playwright install chromium
73
81
74
82
ENTRYPOINT ["/venv/bin/aider" ]
0 commit comments