forked from xprilion/OpenMLR
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
67 lines (47 loc) · 2.04 KB
/
Dockerfile
File metadata and controls
67 lines (47 loc) · 2.04 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
61
62
63
64
65
66
67
# Production Dockerfile
# Builds frontend and backend into a single image
# Usage: docker build -t openmlr . && docker run -p 3000:3000 openmlr
#
# For development with live reload, use Dockerfile.dev instead:
# make dev-docker
# ── Stage 1: Build frontend ──────────────────────────────
FROM node:20-slim AS frontend-build
WORKDIR /app/frontend
RUN corepack enable && corepack prepare pnpm@latest --activate
COPY frontend/package.json frontend/pnpm-lock.yaml* ./
RUN pnpm install --frozen-lockfile || pnpm install
COPY frontend/ .
RUN pnpm build
# ── Stage 2: Python backend ─────────────────────────────
FROM python:3.12-slim AS runtime
# System deps for asyncpg, lxml, bcrypt
RUN apt-get update && \
apt-get install -y --no-install-recommends \
build-essential libpq-dev libxml2-dev libxslt1-dev curl && \
rm -rf /var/lib/apt/lists/*
# Install uv
COPY --from=ghcr.io/astral-sh/uv:latest /uv /usr/local/bin/uv
# Create non-root user for security
RUN groupadd --gid 1000 openmlr && \
useradd --uid 1000 --gid openmlr --shell /bin/bash --create-home openmlr
WORKDIR /app
# Install Python dependencies (cached layer)
COPY backend/pyproject.toml backend/uv.lock* backend/.python-version ./backend/
COPY backend/openmlr/__init__.py ./backend/openmlr/__init__.py
RUN cd backend && uv sync --no-dev
# Copy backend source
COPY backend/ ./backend/
# Copy configs
COPY backend/configs/ ./backend/configs/
# Copy built frontend
COPY --from=frontend-build /app/frontend/dist ./frontend/dist
# Create data directory for SQLite (when not using Postgres)
RUN mkdir -p /app/data && chown -R openmlr:openmlr /app
# Switch to non-root user
USER openmlr
ENV PORT=3000
EXPOSE 3000
# Health check
HEALTHCHECK --interval=30s --timeout=10s --start-period=30s --retries=3 \
CMD curl -f http://localhost:3000/health || exit 1
CMD ["sh", "-c", "backend/.venv/bin/uvicorn openmlr.app:app --host 0.0.0.0 --port ${PORT:-3000} --app-dir backend"]