Files
ss-tools/docker/all-in-one.Dockerfile
busya 1e0dacaf1b build: add dependency caching for bundle builds
Cache pip/npm dependency downloads via BuildKit cache mounts and skip
the postgres pull when the image is already present locally, so a
repeat ./build.sh bundle run does not download dependencies twice.
2026-08-03 17:37:57 +07:00

70 lines
2.3 KiB
Docker

# ============================================================
# All-in-One Docker image (no Playwright, <200MB target)
# ============================================================
# Build: docker build -f docker/all-in-one.Dockerfile -t superset-tools:latest .
# Run: docker run -p 8000:8000 --env-file backend/.env superset-tools:latest
#
# Stages:
# 1. frontend-builder — node:20-alpine, npm ci + build, discarded
# 2. runtime — python:3.11-slim, backend deps (no playwright),
# copies frontend build, uvicorn serves both SPA + API on :8000
# ── Stage 1: Build Frontend ────────────────────────────────
FROM node:20-alpine AS frontend-builder
ARG APP_VERSION=0.0.0
ENV APP_VERSION=${APP_VERSION}
WORKDIR /app/frontend
# Install deps (layer cache when package.json unchanged)
COPY frontend/package.json frontend/package-lock.json* ./
RUN --mount=type=cache,target=/root/.npm \
npm ci --prefer-offline --no-audit --no-fund --legacy-peer-deps
# Build frontend
COPY frontend/ ./
RUN npm run build
# ── Stage 2: Runtime ───────────────────────────────────────
FROM python:3.11-slim AS runtime
ENV PYTHONDONTWRITEBYTECODE=1 \
PYTHONUNBUFFERED=1 \
BACKEND_PORT=8000 \
DEBIAN_FRONTEND=noninteractive
WORKDIR /app
# System deps (git for GitPython, curl for healthcheck)
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
curl \
git \
&& rm -rf /var/lib/apt/lists/*
# Python deps (NO playwright — saves ~350MB)
COPY backend/requirements-backend.txt /app/backend/requirements-backend.txt
RUN --mount=type=cache,target=/root/.cache/pip \
pip install -r /app/backend/requirements-backend.txt
# Backend source
COPY backend/ /app/backend/
# Frontend build (from stage 1)
COPY --from=frontend-builder /app/frontend/build /app/frontend/build
# Entrypoint + certs.sh
COPY docker/certs.sh /app/certs.sh
COPY docker/backend.entrypoint.sh /app/entrypoint.sh
RUN chmod +x /app/entrypoint.sh
WORKDIR /app/backend
EXPOSE 8000
HEALTHCHECK --interval=30s --timeout=5s --start-period=10s --retries=3 \
CMD curl -sf http://localhost:8000/ || exit 1
ENTRYPOINT ["/app/entrypoint.sh"]
CMD ["python", "-m", "uvicorn", "src.app:app", "--host", "0.0.0.0", "--port", "8000"]