diff --git a/CHANGELOG.md b/CHANGELOG.md index 05a2800..99a961b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,4 +9,5 @@ - ADDED admin - track files sizes - ADDED login/logout notifications - FIXED system - customer deploy stack name -- ADDED calandar - planning view (default for mobile) +- ADDED calendar - planning view (default for mobile) +- CHANGED system - optimize docker image size diff --git a/backend/.dockerignore b/backend/.dockerignore index aa58f88..72fb7bc 100644 --- a/backend/.dockerignore +++ b/backend/.dockerignore @@ -15,3 +15,6 @@ uploads/ .git .gitignore Dockerfile +*.md +doc/ +plans/ diff --git a/backend/Dockerfile b/backend/Dockerfile index cff5a08..3f1f4fc 100644 --- a/backend/Dockerfile +++ b/backend/Dockerfile @@ -1,4 +1,4 @@ -# ---- Base: shared setup ---- +# ---- Base: shared setup (used by dev + build) ---- FROM python:3.12-slim AS base COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /bin/ @@ -19,22 +19,30 @@ EXPOSE 8000 ENTRYPOINT ["/app/entrypoint.sh"] CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8000", "--reload"] -# ---- Prod: deps + source ---- -FROM base AS prod +# ---- Build: install deps + source (intermediate stage) ---- +FROM base AS build + +COPY pyproject.toml uv.lock* ./ +RUN uv sync --frozen --no-dev --no-install-project + +COPY . . ARG APP_VERSION=dev +RUN echo "$APP_VERSION" > VERSION && uv sync --frozen --no-dev + +# ---- Prod: clean runtime image without uv ---- +FROM python:3.12-slim AS prod LABEL org.opencontainers.image.source="https://github.com/VEAF/website-2026" LABEL org.opencontainers.image.description="VEAF Website 2026 - Backend API" -COPY pyproject.toml uv.lock* ./ -RUN uv sync --frozen --no-dev --no-install-project +RUN groupadd --gid 1000 worker && useradd --uid 1000 --gid worker --create-home worker -COPY . . -RUN echo "$APP_VERSION" > VERSION -RUN uv sync --frozen --no-dev +WORKDIR /app +ENV PATH="/app/.venv/bin:$PATH" + +COPY --from=build --chown=worker:worker /app /app -RUN chown -R worker:worker /app USER worker EXPOSE 8000 diff --git a/frontend/.dockerignore b/frontend/.dockerignore index eb27e9f..c391a8c 100644 --- a/frontend/.dockerignore +++ b/frontend/.dockerignore @@ -5,3 +5,4 @@ dist .git .gitignore Dockerfile +*.md