feat: Shrink docker image
All checks were successful
Build Docker / Build Image (push) Successful in 1m11s
All checks were successful
Build Docker / Build Image (push) Successful in 1m11s
This commit is contained in:
18
.dockerignore
Normal file
18
.dockerignore
Normal 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
|
||||||
31
Dockerfile
31
Dockerfile
@@ -1,17 +1,32 @@
|
|||||||
FROM --platform=$BUILDPLATFORM python:3.10-alpine AS builder
|
### 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
|
||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
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 --frozen --no-dev --no-install-workspace
|
||||||
|
|
||||||
COPY requirements.txt /app
|
### Runtime stage ###
|
||||||
RUN --mount=type=cache,target=/root/.cache/pip \
|
FROM python:3.13-alpine AS runtime
|
||||||
pip3 install -r requirements.txt
|
ENV PATH="/app/.venv/bin:$PATH"
|
||||||
|
|
||||||
|
# Install curl for healthchecks
|
||||||
|
RUN apk add --no-cache curl
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
# Copy the virtual environment from build stage
|
||||||
|
COPY --from=build /app/.venv /app/.venv
|
||||||
|
|
||||||
|
# Copy all top-level Python files
|
||||||
COPY . /app
|
COPY . /app
|
||||||
|
|
||||||
# Add mount point for data volume
|
# Optional mount for data
|
||||||
|
ENV BASE_DIR=/mnt
|
||||||
VOLUME /mnt
|
VOLUME /mnt
|
||||||
|
|
||||||
ENTRYPOINT ["python3"]
|
EXPOSE 5000
|
||||||
CMD ["main.py"]
|
|
||||||
|
|
||||||
FROM builder as dev-envs
|
ENTRYPOINT ["python3", "main.py"]
|
||||||
|
|||||||
Reference in New Issue
Block a user