-
-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathDockerfile
More file actions
52 lines (37 loc) · 1.67 KB
/
Dockerfile
File metadata and controls
52 lines (37 loc) · 1.67 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# First, build the application in the `/app` directory.
FROM ghcr.io/astral-sh/uv:python3.12-bookworm-slim AS builder
ENV UV_COMPILE_BYTECODE=1 UV_LINK_MODE=copy
# Disable Python downloads to use the system interpreter across both images
ENV UV_PYTHON_DOWNLOADS=0
# Build argument for optional dependencies (e.g., "pgsql")
ARG EXTRA_DEPENDENCIES=""
# Required for git-based Python dependencies during `uv sync`
RUN apt-get update && apt-get install -y --no-install-recommends git \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /app
# Install dependencies
RUN --mount=type=cache,target=/root/.cache/uv \
--mount=type=bind,source=uv.lock,target=uv.lock \
--mount=type=bind,source=pyproject.toml,target=pyproject.toml \
uv sync --frozen --no-install-project --no-dev ${EXTRA_DEPENDENCIES:+--extra} ${EXTRA_DEPENDENCIES}
# Copy the application code
COPY . /app
# Install the project itself
RUN --mount=type=cache,target=/root/.cache/uv \
uv sync --frozen --no-dev ${EXTRA_DEPENDENCIES:+--extra} ${EXTRA_DEPENDENCIES}
# Then, use a final image without uv
FROM python:3.12-slim-bookworm
# Install curl for healthcheck
RUN apt-get update && apt-get install -y --no-install-recommends curl \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /app
# Copy the application from the builder
COPY --from=builder --chown=app:app /app /app
# Place executables in the environment at the front of the path, set env var defaults
ENV PATH="/app/.venv/bin:$PATH" \
ENV=prod \
DB_URI=sqlite:///data/embed_fixer.db
VOLUME [ "/data", "/app/logs" ]
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
CMD curl -f http://localhost:8080/health || exit 1
CMD ["python", "run.py"]