File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -11,54 +11,41 @@ ENV LANG="C.UTF-8" \
1111
1212WORKDIR /app
1313
14+ # Install runtime dependencies first (better caching)
15+ RUN apk add --no-cache \
16+ bash \
17+ busybox-suid \
18+ python3 \
19+ su-exec \
20+ shadow \
21+ tini \
22+ openssl \
23+ tzdata
24+
25+ # Install uv (separate layer for better caching)
26+ RUN curl -LsSf https://astral.sh/uv/install.sh | sh
27+
1428# Copy Python project files
1529COPY backend/pyproject.toml backend/uv.lock ./
1630
17- RUN set -ex && \
18- apk add --no-cache \
19- bash \
20- busybox-suid \
21- python3 \
31+ # Install build dependencies and Python packages, then clean up
32+ RUN apk add --no-cache --virtual .build-deps \
2233 python3-dev \
23- py3-aiohttp \
24- py3-bcrypt \
25- curl \
2634 gcc \
2735 musl-dev \
2836 libffi-dev \
29- su-exec \
30- shadow \
31- tini \
32- openssl \
33- tzdata \
3437 rust \
3538 cargo && \
36- # Install uv
37- curl -LsSf https://astral.sh/uv/install.sh | sh && \
38- # Verify uv installation and show version
39- uv --version && \
40- # Check if lock file exists and is readable
41- ls -la uv.lock && \
42- # Install dependencies using uv
4339 uv sync --frozen --no-dev && \
44- # Remove build dependencies to reduce image size
45- apk del \
46- rust \
47- cargo \
48- gcc \
49- musl-dev \
50- libffi-dev \
51- python3-dev && \
52- # Add user
53- mkdir -p /home/ab && \
40+ apk del .build-deps && \
41+ rm -rf /root/.cache /root/.local /tmp/*
42+
43+ # Create user
44+ RUN mkdir -p /home/ab && \
5445 addgroup -S ab -g 911 && \
55- adduser -S ab -G ab -h /home/ab -s /sbin/nologin -u 911 && \
56- # Clear
57- rm -rf \
58- /root/.cache \
59- /root/.local \
60- /tmp/*
46+ adduser -S ab -G ab -h /home/ab -s /sbin/nologin -u 911
6147
48+ # Copy application code (this layer changes most frequently)
6249COPY --chmod=755 backend/src/. .
6350COPY --chmod=755 entrypoint.sh /entrypoint.sh
6451
You can’t perform that action at this time.
0 commit comments