File tree 1 file changed +17
-11
lines changed
1 file changed +17
-11
lines changed Original file line number Diff line number Diff line change 1
- # Base container
2
- FROM ghcr.io/astral-sh/uv:python3.12-bookworm AS base
1
+ # Builder container (with UV as package manager)
2
+ FROM ghcr.io/astral-sh/uv:python3.12-bookworm-slim@sha256:aacf61c53ed988e4a32b8b4da19043fdce7a8efcc67fb21ebc4cc0ba85f335b3 AS builder
3
+
4
+ ENV UV_COMPILE_BYTECODE=1
5
+ ENV UV_LINK_MODE=copy
3
6
4
7
RUN rm -f /etc/apt/apt.conf.d/docker-clean \
5
8
&& echo 'Binary::apt::APT::Keep-Downloaded-Packages "true";' > /etc/apt/apt.conf.d/keep-cache
6
9
RUN --mount=target=/var/lib/apt/lists,type=cache,id=apt-lists-${TARGETPLATFORM},sharing=locked \
7
10
apt-get update -q \
8
11
&& apt-get install -y -q --no-install-recommends \
9
- ffmpeg
12
+ build-essential
10
13
11
- ARG VERSION
12
- ENV VERSION=${VERSION}
14
+ WORKDIR /app
15
+
16
+ COPY . .
13
17
14
- RUN useradd -m appuser
18
+ RUN --mount=target=/root/.cache/uv,type=cache,id=uv-${TARGETPLATFORM},sharing=locked \
19
+ uv sync --frozen --no-dev
15
20
16
- COPY --chown=appuser:appuser . /app
21
+ # Output container (with only venv and app source)
22
+ FROM python:3.12-slim-bookworm@sha256:10f3aaab98db50cba827d3b33a91f39dc9ec2d02ca9b85cbc5008220d07b17f3
17
23
18
24
WORKDIR /app
19
25
20
- RUN --mount=target=/root/.cache/uv,type=cache,id=uv-${TARGETPLATFORM},sharing=locked \
21
- uv sync --frozen
26
+ ENV PATH=/app/.venv/bin:$PATH
22
27
23
- USER appuser
28
+ COPY --from=builder --chown=app:app /app .
24
29
25
- ENV PATH=/app/.venv/bin:$PATH
30
+ ARG VERSION
31
+ ENV VERSION=${VERSION}
26
32
27
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" ]
You can’t perform that action at this time.
0 commit comments