bake data.csv into docker image
All checks were successful
Build and Push Docker Image / build (push) Successful in 4s
All checks were successful
Build and Push Docker Image / build (push) Successful in 4s
This commit is contained in:
@@ -20,10 +20,6 @@ venv/
|
|||||||
# Local output
|
# Local output
|
||||||
dist/
|
dist/
|
||||||
|
|
||||||
# Don't bake data into the image — mount it at runtime
|
|
||||||
# data.csv is excluded here so it must be provided via docker-compose volume
|
|
||||||
data.csv
|
|
||||||
|
|
||||||
# Git
|
# Git
|
||||||
.git/
|
.git/
|
||||||
.gitignore
|
.gitignore
|
||||||
|
|||||||
16
Dockerfile
16
Dockerfile
@@ -2,21 +2,29 @@ FROM ghcr.io/astral-sh/uv:python3.13-bookworm-slim
|
|||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
# Copy dependency files first (better caching)
|
# 1. Copy dependency files first for layer caching
|
||||||
COPY pyproject.toml uv.lock ./
|
COPY pyproject.toml uv.lock ./
|
||||||
|
|
||||||
# Install dependencies into project environment
|
# 2. Install dependencies
|
||||||
RUN uv sync --frozen --no-dev
|
RUN uv sync --frozen --no-dev
|
||||||
|
|
||||||
# Copy app source
|
# 3. Explicitly copy data.csv first to ensure it exists
|
||||||
|
# (This will fail the build if the file is missing locally)
|
||||||
|
COPY data.csv ./data.csv
|
||||||
|
|
||||||
|
# 4. Copy the rest of the source code
|
||||||
COPY . .
|
COPY . .
|
||||||
|
|
||||||
|
# 5. Environment Setup
|
||||||
ENV PYTHONUNBUFFERED=1
|
ENV PYTHONUNBUFFERED=1
|
||||||
|
# Points to the src folder so Python can find your modules
|
||||||
ENV PYTHONPATH=/app/src
|
ENV PYTHONPATH=/app/src
|
||||||
|
# Points to the file we just baked into the root
|
||||||
ENV DATA_CSV_PATH=/app/data.csv
|
ENV DATA_CSV_PATH=/app/data.csv
|
||||||
ENV UV_PROJECT_ENVIRONMENT=/app/.venv
|
ENV UV_PROJECT_ENVIRONMENT=/app/.venv
|
||||||
ENV UV_LINK_MODE=copy
|
ENV UV_LINK_MODE=copy
|
||||||
|
|
||||||
EXPOSE 8000
|
EXPOSE 8000
|
||||||
|
|
||||||
CMD ["uv", "run", "gunicorn", "--workers", "2", "--bind", "0.0.0.0:8000", "app:app"]
|
# 6. Run from the root, but point Gunicorn to the app inside src
|
||||||
|
CMD ["uv", "run", "gunicorn", "--workers", "2", "--bind", "0.0.0.0:8000", "--chdir", "/app/src", "app:app"]
|
||||||
|
|||||||
Reference in New Issue
Block a user