Skip to content

Commit 609f27f

Browse files
committed
feat: add Dockerfile for application build and runtime environment
1 parent 06922ae commit 609f27f

1 file changed

Lines changed: 25 additions & 0 deletions

File tree

Dockerfile

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
FROM ghcr.io/astral-sh/uv:python3.13-bookworm-slim AS builder
2+
ENV UV_COMPILE_BYTECODE=1 UV_LINK_MODE=copy
3+
ENV UV_NO_DEV=1
4+
ENV UV_PYTHON_DOWNLOADS=0
5+
WORKDIR /app
6+
RUN --mount=type=cache,target=/root/.cache/uv \
7+
--mount=type=bind,source=uv.lock,target=uv.lock \
8+
--mount=type=bind,source=pyproject.toml,target=pyproject.toml \
9+
uv sync --locked --no-install-project
10+
COPY . /app
11+
RUN --mount=type=cache,target=/root/.cache/uv \
12+
uv sync --locked
13+
14+
FROM python:3.13-slim-bookworm AS runtime
15+
RUN apt-get update \
16+
&& apt-get upgrade -y \
17+
&& apt-get clean \
18+
&& rm -rf /var/lib/apt/lists/*
19+
RUN groupadd --system --gid 999 nonroot \
20+
&& useradd --system --gid 999 --uid 999 --create-home nonroot
21+
COPY --from=builder --chown=nonroot:nonroot /app/ /app
22+
ENV PATH="/app/.venv/bin:$PATH"
23+
USER nonroot
24+
WORKDIR /app/src
25+
CMD ["python", "-m", "sample_python_app.main"]

0 commit comments

Comments
 (0)