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
COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /bin/
### Build stage ###
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
# Install dependencies
RUN --mount=type=cache,target=/root/.cache/uv \
--mount=type=bind,source=uv.lock,target=uv.lock \
--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
ADD . /app
### Runtime stage ###
FROM python:3.13-alpine AS runtime
ENV PATH="/app/.venv/bin:$PATH"
# Sync the project
RUN --mount=type=cache,target=/root/.cache/uv \
uv sync --locked
# Install curl for healthchecks
RUN apk add --no-cache curl
WORKDIR /app
# Add mount point for data volume
ENV BASE_DIR=/data
VOLUME /data
# Copy the virtual environment from build stage
COPY --from=build /app/.venv /app/.venv
# Copy all top-level Python files
COPY . /app
# Optional mount for data
#ENV BASE_DIR=/data
#VOLUME /data
EXPOSE 5000
ENTRYPOINT ["uv", "run"]
CMD ["main.py"]
ENTRYPOINT ["python3", "main.py"]