-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
60 lines (45 loc) · 1.66 KB
/
Dockerfile
File metadata and controls
60 lines (45 loc) · 1.66 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 Frontend (Node.js)
# ==========================================
FROM node:20-alpine as build-frontend
WORKDIR /app/frontend
# 1. Install frontend dependencies
COPY frontend/package*.json ./
RUN npm ci
# 2. Copy source and build
COPY frontend/ ./
ARG VITE_GEMINI_API_KEY
ENV VITE_GEMINI_API_KEY=$VITE_GEMINI_API_KEY
RUN npx vite build
# ==========================================
# STAGE 2: Backend (Python 3.11 Stable)
# ==========================================
# Using 3.11 for maximum compatibility with ML libraries (OpenCV, etc.)
FROM python:3.11-slim
WORKDIR /app
# Prevent Python from writing pyc files to disc
ENV PYTHONDONTWRITEBYTECODE=1
# Prevent Python from buffering stdout and stderr
ENV PYTHONUNBUFFERED=1
# 1. Install system dependencies for OpenCV (gl1, glib2 are required)
RUN apt-get update && apt-get install -y --no-install-recommends \
libgl1 \
libglib2.0-0 \
&& rm -rf /var/lib/apt/lists/*
# 2. Install uv (fast package manager)
COPY --from=ghcr.io/astral-sh/uv:latest /uv /bin/uv
# 3. Copy dependency files
COPY pyproject.toml uv.lock ./
# 4. Install Python dependencies into system (no venv needed in Docker)
RUN uv sync --frozen --no-dev
# 5. Copy Backend code and AI Agent
COPY backend/ ./backend/
COPY my_agent/ ./my_agent/
# Uncomment if you have a data folder:
# COPY data/ ./data/
# 6. --- MONOLITH MAGIC: COPY FRONTEND BUILD ---
# Copy the 'dist' folder from Stage 1 to where FastAPI expects it
COPY --from=build-frontend /app/frontend/dist ./frontend/dist
# 7. Start Server
ENV PORT=8080
CMD ["uv", "run", "uvicorn", "backend.main:app", "--host", "0.0.0.0", "--port", "8080"]