feat: Shrink docker file
All checks were successful
Build Docker / BuildImage (push) Successful in 42s
Check Code Quality / RuffCheck (push) Successful in 1m13s

This commit is contained in:
2026-03-23 04:19:01 +00:00
parent 10f31b1171
commit 378bbc1633
2 changed files with 39 additions and 20 deletions

18
.dockerignore Normal file
View File

@@ -0,0 +1,18 @@
# Ignore text files
*.txt
*.md
LICENSE
# UV/Python virtual env files
.venv/
.python-version
# Git
.git/
.gitignore
.gitea/
.pre-commit-config.yaml
# Docker build files
Dockerfile
.dockerignore

View File

@@ -1,31 +1,32 @@
FROM --platform=$BUILDPLATFORM python:3.13-alpine ### Build stage ###
COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /bin/ FROM python:3.13-alpine AS build
COPY --from=ghcr.io/astral-sh/uv:0.8.21 /uv /uvx /bin/
ENV UV_PROJECT_ENVIRONMENT=/app/.venv
# Install curl for healthcheck
RUN apk add --no-cache curl
# Set working directory
WORKDIR /app WORKDIR /app
# Install dependencies
RUN --mount=type=cache,target=/root/.cache/uv \ RUN --mount=type=cache,target=/root/.cache/uv \
--mount=type=bind,source=uv.lock,target=uv.lock \ --mount=type=bind,source=uv.lock,target=uv.lock \
--mount=type=bind,source=pyproject.toml,target=pyproject.toml \ --mount=type=bind,source=pyproject.toml,target=pyproject.toml \
uv sync --locked --no-install-project uv sync --frozen --no-dev --no-install-workspace
# Copy the project into the image ### Runtime stage ###
ADD . /app FROM python:3.13-alpine AS runtime
ENV PATH="/app/.venv/bin:$PATH"
# Sync the project # Install curl for healthchecks
RUN --mount=type=cache,target=/root/.cache/uv \ RUN apk add --no-cache curl
uv sync --locked WORKDIR /app
# Add mount point for data volume # Copy the virtual environment from build stage
ENV BASE_DIR=/data COPY --from=build /app/.venv /app/.venv
VOLUME /data
# Copy all top-level Python files
COPY . /app
# Optional mount for data
#ENV BASE_DIR=/data
#VOLUME /data
EXPOSE 5000 EXPOSE 5000
ENTRYPOINT ["python3", "main.py"]
ENTRYPOINT ["uv", "run"]
CMD ["main.py"]