-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
60 lines (43 loc) · 2.59 KB
/
Copy pathDockerfile
File metadata and controls
60 lines (43 loc) · 2.59 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# ─────────────────────────────────────────────────────────────────────────────
# Stage 1 — Build the Vite / React client
# ─────────────────────────────────────────────────────────────────────────────
FROM node:22-alpine AS client-build
WORKDIR /build
# Install dependencies first (better layer caching)
COPY client/package.json client/package-lock.json* ./
RUN npm ci --prefer-offline
# Copy source and build
COPY client/ .
RUN npm run build
# Output: /build/dist
# ─────────────────────────────────────────────────────────────────────────────
# Stage 2 — Python runtime
# ─────────────────────────────────────────────────────────────────────────────
FROM python:3.13-slim AS runtime
# Build arg injected by CI — baked in as an env var so the app can expose it
ARG APP_VERSION=dev
ENV APP_VERSION=${APP_VERSION}
# Install uv (fast Python package installer)
COPY --from=ghcr.io/astral-sh/uv:latest /uv /usr/local/bin/uv
WORKDIR /app
# Copy server source
COPY server/ ./server/
# Install Python dependencies
RUN uv pip install --system --no-cache -e ./server/
# Copy the built Vite bundle into server/static
# FastAPI's static files handler will serve these in production
COPY --from=client-build /build/dist ./server/static/
# Create persistent data directories (mounted as volumes at runtime)
# /data → SQLite database (separate from code so volumes don't overlay src)
# uploads/ → datasets and model files
RUN mkdir -p /data server/uploads/datasets server/uploads/models
# Tell the app where to find the DB
ENV DB_PATH=/data/mlcore_db.db
WORKDIR /app/server
# Expose the API / UI port
EXPOSE 8000
# Health-check so container orchestrators know when the app is ready
HEALTHCHECK --interval=30s --timeout=5s --start-period=15s --retries=3 \
CMD python -c "import urllib.request; urllib.request.urlopen('http://localhost:8000/api/health')"
# Run with a single worker by default; scale horizontally via replicas
CMD ["uvicorn", "src.main:app", "--host", "0.0.0.0", "--port", "8000", "--workers", "1"]