Split backend properly
All checks were successful
CI / test (push) Successful in 53s
CI / test-analytics (push) Successful in 2m1s
CI / build-api (push) Successful in 3m22s
CI / build-frontend (push) Successful in 2m6s
CI / build-analytics (push) Successful in 2m45s

This commit is contained in:
2026-05-11 13:56:20 +02:00
parent b7c38c8377
commit dbf1a05b08
3 changed files with 59 additions and 41 deletions

View File

@@ -1,21 +1,5 @@
# syntax=docker/dockerfile:1.7
# ---------------------------------------------------------------------------
# Stage 1 — Build Go analytics service
# ---------------------------------------------------------------------------
FROM rockylinux/rockylinux:10 AS go-build
RUN dnf install -y golang && dnf clean all
WORKDIR /src
COPY analytics/go.mod analytics/go.sum ./
RUN go mod download
COPY analytics/ .
RUN CGO_ENABLED=0 GOOS=linux go build -o /analytics-server ./cmd/server
# ---------------------------------------------------------------------------
# Stage 2 — Python base
# ---------------------------------------------------------------------------
FROM rockylinux/rockylinux:10 AS base
RUN dnf install -y python3 && dnf clean all
@@ -30,44 +14,28 @@ COPY --from=ghcr.io/astral-sh/uv:latest /uv /usr/local/bin/uv
WORKDIR /app
# ---------------------------------------------------------------------------
# Stage 3 — Python dependencies
# ---------------------------------------------------------------------------
FROM base AS deps
COPY pyproject.toml uv.lock* ./
RUN --mount=type=cache,target=/root/.cache/uv \
uv sync --frozen --no-install-project --no-dev
# ---------------------------------------------------------------------------
# Stage 4 — Python application
# ---------------------------------------------------------------------------
FROM deps AS app-build
COPY app/ ./app/
RUN --mount=type=cache,target=/root/.cache/uv \
uv sync --frozen --no-dev
# ---------------------------------------------------------------------------
# Stage 5 — Final image (Python + Go binary)
# ---------------------------------------------------------------------------
FROM base AS final
RUN groupadd --gid 10001 appgroup && \
useradd --uid 10001 --gid 10001 --no-create-home --shell /sbin/nologin appuser
COPY --from=go-build /analytics-server /usr/local/bin/analytics-server
COPY --from=app-build --chown=appuser:appgroup /app /app
USER appuser
WORKDIR /app
ENV PATH="/app/.venv/bin:$PATH" \
ROLE=api
ENV PATH="/app/.venv/bin:$PATH"
EXPOSE 8000 8080
EXPOSE 8000
ENTRYPOINT ["/bin/sh", "-c", "\
if [ \"$ROLE\" = 'analytics' ]; then \
/usr/local/bin/analytics-server; \
else \
uvicorn app.main:app --host 0.0.0.0 --port 8000 --no-access-log; \
fi"]
ENTRYPOINT ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8000", "--no-access-log"]