-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathDockerfile
More file actions
62 lines (44 loc) · 1.58 KB
/
Dockerfile
File metadata and controls
62 lines (44 loc) · 1.58 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
55
56
57
58
59
60
61
62
# --- Build Stage ---
FROM python:3.13-slim AS builder
ARG TARGETARCH
# Prevent uv from creating a virtualenv that might be hard to move
ENV UV_COMPILE_BYTECODE=1 \
UV_LINK_MODE=copy \
UV_PYTHON_DOWNLOADS=0
WORKDIR /app
# Install build dependencies. ducc0 requires a C++17 compiler (g++).
RUN apt-get update && apt-get install -y --no-install-recommends \
g++ \
&& rm -rf /var/lib/apt/lists/*
# Install uv
COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /bin/
# 1. Copy only dependency files for better layer caching.
COPY pyproject.toml uv.lock ./
# 2. Install third-party dependencies first (including extras).
# Use cache mount for uv to persist downloads and build artifacts.
RUN --mount=type=cache,target=/root/.cache/uv \
uv sync --frozen --no-dev --no-install-workspace --extra grib --extra netcdf4 --no-editable
# 3. Copy only necessary source files for the final installation step.
COPY src/ ./src/
COPY README.md ./
# 4. Final installation of the project package itself.
RUN --mount=type=cache,target=/root/.cache/uv \
uv sync --frozen --no-dev --extra grib --extra netcdf4 --no-editable
# --- Runtime Stage ---
FROM python:3.13-slim
WORKDIR /app
# Create data directory for mounting
RUN mkdir /data && chmod 777 /data
# Copy the environment from the builder
COPY --from=builder /app/.venv /app/.venv
# Ensure the virtualenv is used by default
ENV PATH="/app/.venv/bin:$PATH" \
PYTHONUNBUFFERED=1
# Add a non-root user for security
RUN useradd -m pst
USER pst
# Volume for data persistence
VOLUME /data
# Default command
ENTRYPOINT ["stormtracker"]
CMD ["--help"]