fix(docker): multi-stage build and publish tags
Build and Push Docker Image / build (push) Canceled after 0s
Build and Push Docker Image / build (push) Canceled after 0s
- Split Dockerfile into builder and runtime stages - Put .venv on PATH so pymodbus resolves in the container - Push image to Docker Hub and GHCR with latest and 7-char SHA tags - Use real repo/image names in README
This commit is contained in:
3 files changed
+33
-12
No files matched your search
+11
-3
@@ -1,10 +1,18 @@
|
||||
FROM python:3.11-slim
|
||||
# Stage 1: build and install dependencies
|
||||
FROM python:3.11-slim AS builder
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
# Install dependencies
|
||||
COPY pyproject.toml uv.lock ./
|
||||
RUN pip install uv && uv sync --frozen
|
||||
RUN pip install --no-cache-dir uv && uv sync --frozen --no-dev --no-install-project
|
||||
|
||||
# Stage 2: runtime (slim, no build toolchain)
|
||||
FROM python:3.11-slim AS runtime
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
COPY --from=builder /app/.venv ./.venv
|
||||
ENV PATH="/app/.venv/bin:$PATH"
|
||||
|
||||
# Copy application
|
||||
COPY main.py ./
|
||||
|
||||
Reference in new issue
Block a user