Skip to content

Commit 5fe33e5

Browse files
committed
dev: Enhance container build cache
1 parent 58d091b commit 5fe33e5

File tree

1 file changed

+17
-14
lines changed

1 file changed

+17
-14
lines changed

Diff for: cicd/Dockerfile

+17-14
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,36 @@
11
# Builder container (with UV as package manager)
2-
FROM ghcr.io/astral-sh/uv:python3.13-bookworm-slim@sha256:525eb0972b68435ca35014cf975e368b1a6cdd48fb0b5836866518b89863ca4c AS builder
2+
FROM ghcr.io/astral-sh/uv:python3.13-bookworm-slim@sha256:525eb0972b68435ca35014cf975e368b1a6cdd48fb0b5836866518b89863ca4c AS build
33

4-
ENV UV_COMPILE_BYTECODE=1
5-
ENV UV_LINK_MODE=copy
6-
7-
RUN rm -f /etc/apt/apt.conf.d/docker-clean \
8-
&& echo 'Binary::apt::APT::Keep-Downloaded-Packages "true";' > /etc/apt/apt.conf.d/keep-cache
4+
# UV build dependencies
95
RUN --mount=target=/var/lib/apt/lists,type=cache,id=apt-lists-${TARGETPLATFORM},sharing=locked \
10-
apt-get update -q \
11-
&& apt-get install -y -q --no-install-recommends \
6+
apt-get update \
7+
&& apt-get install -y --no-install-recommends \
128
build-essential
139

10+
# Copy project definitions
1411
WORKDIR /app
12+
COPY pyproject.toml uv.lock ./
1513

16-
COPY . .
17-
14+
# Install Python dependencies
15+
ENV UV_COMPILE_BYTECODE=1
16+
ENV UV_LINK_MODE=copy
1817
RUN --mount=target=/root/.cache/uv,type=cache,id=uv-${TARGETPLATFORM},sharing=locked \
1918
uv sync --frozen --no-dev
2019

2120
# Output container (with only venv and app source)
2221
FROM python:3.13-slim-bookworm@sha256:ae9f9ac89467077ed1efefb6d9042132d28134ba201b2820227d46c9effd3174
2322

23+
# Set default dir
2424
WORKDIR /app
2525

26-
ENV PATH=/app/.venv/bin:$PATH
27-
28-
COPY --from=builder --chown=app:app /app .
26+
# Copy sources and venv
27+
COPY . .
28+
COPY --from=build /app/.venv /app/.venv
29+
ENV PATH="/app/.venv/bin:${PATH}"
2930

31+
# Allow app to know its version
3032
ARG VERSION
3133
ENV VERSION=${VERSION}
3234

33-
CMD ["bash", "-c", "gunicorn app.main:api --bind 0.0.0.0:8080 --graceful-timeout 60 --proxy-protocol --timeout 60 --worker-class uvicorn.workers.UvicornWorker --workers 4"]
35+
# Starting the backend
36+
CMD gunicorn app.main:api --bind 0.0.0.0:8080 --graceful-timeout 60 --proxy-protocol --timeout 60 --worker-class uvicorn.workers.UvicornWorker --workers 4

0 commit comments

Comments
 (0)