-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDockerfile
More file actions
54 lines (38 loc) · 1.61 KB
/
Dockerfile
File metadata and controls
54 lines (38 loc) · 1.61 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
53
54
## ------------------------------- Builder Stage ------------------------------ ##
FROM python:3.14.3-bookworm AS builder
RUN apt-get update && apt-get install --no-install-recommends -y \
build-essential && \
apt-get clean && rm -rf /var/lib/apt/lists/*
# Download the latest installer, install it and then remove it
ADD https://astral.sh/uv/install.sh /install.sh
ENV UV_VERSION=0.11.6
RUN chmod -R 755 /install.sh && /install.sh && rm /install.sh
# Set up the UV environment path correctly
ENV PATH="/root/.local/bin:${PATH}"
WORKDIR /app
# Copy bare minimum for requirements install
COPY pyproject.toml README.md ./
# Override to dummy version when installing dependencies only
ENV SETUPTOOLS_SCM_PRETEND_VERSION=0.0.0
RUN uv sync --no-install-project --no-install-workspace
# Copy entire context - so we can calculate the git revision
COPY . .
# Unset version so the actual version number can be used
ENV SETUPTOOLS_SCM_PRETEND_VERSION=
RUN uv pip install -e .
## ------------------------------- Production Stage ------------------------------ ##
FROM python:3.14.3-slim-bookworm AS runtime
RUN useradd smibuser
USER smibuser
WORKDIR /app
# Copy the entire source directory and virtual environment
COPY --from=builder /app/src ./src
COPY --from=builder /app/.venv ./.venv
COPY --from=builder /app/pyproject.toml ./pyproject.toml
# Set up environment variables for production
ENV PATH="/app/.venv/bin:$PATH"
ENV PYTHONPATH="/app/src"
COPY docker/healthcheck.py ./healthcheck.py
HEALTHCHECK --interval=10s --timeout=10s --start-period=8s --retries=3 \
CMD ["python", "/app/healthcheck.py"]
CMD ["python", "-m", "smib"]