-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDockerfile
More file actions
46 lines (36 loc) · 1.72 KB
/
Copy pathDockerfile
File metadata and controls
46 lines (36 loc) · 1.72 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
# ──────────────────────────────────────────────────────────
# Stage 1: Build frontend
# ──────────────────────────────────────────────────────────
FROM node:20-alpine AS frontend-build
WORKDIR /frontend
COPY frontend/package*.json ./
RUN npm ci
COPY frontend/ ./
RUN npm run build
# ──────────────────────────────────────────────────────────
# Stage 2: Python backend
# ──────────────────────────────────────────────────────────
FROM python:3.11-slim AS backend
# System deps for OpenCV
RUN apt-get update && apt-get install -y --no-install-recommends \
libgl1 libglib2.0-0 libsm6 libxrender1 libxext6 \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /app
# Copy requirements and install
COPY backend/requirements.txt ./
RUN pip install --no-cache-dir -r requirements.txt
# Copy backend source
COPY backend/ ./backend/
COPY detection/ ./detection/
COPY yolov8n.pt ./
# Copy built frontend into static serving dir
COPY --from=frontend-build /frontend/dist ./frontend/dist
# Create runtime directories
RUN mkdir -p snapshots data
# Environment defaults (override at runtime)
ENV PYTHONUNBUFFERED=1 \
MODEL_PATH=yolov8n.pt \
DB_URL=sqlite:///./data/safety.db \
SNAPSHOT_DIR=snapshots
EXPOSE 8000
CMD ["uvicorn", "backend.app.main:app", "--host", "0.0.0.0", "--port", "8000"]