-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
60 lines (46 loc) · 1.46 KB
/
Dockerfile
File metadata and controls
60 lines (46 loc) · 1.46 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 React Frontend ---
FROM node:20-slim AS frontend-builder
# Accept build arguments for frontend env vars
ARG VITE_GOOGLE_CLIENT_ID
ARG VITE_API_URL=/api
# Set as environment variables for Vite build
ENV VITE_GOOGLE_CLIENT_ID=$VITE_GOOGLE_CLIENT_ID
ENV VITE_API_URL=$VITE_API_URL
WORKDIR /app/frontend-react
COPY frontend-react/package*.json ./
RUN npm install
COPY frontend-react/ ./
RUN npm run build
# --- Stage 2: Final Image ---
FROM python:3.11-slim
# Install system dependencies
RUN apt-get update && apt-get install -y \
libgl1 \
libglib2.0-0 \
portaudio19-dev \
python3-dev \
gcc \
curl \
&& rm -rf /var/lib/apt/lists/*
# Install uv catalyst tool
COPY --from=ghcr.io/astral-sh/uv:0.5 /uv /uvx /bin/
# Set working directory
WORKDIR /app
# Copy dependency files
COPY pyproject.toml uv.lock ./
# Install dependencies using uv sync
RUN uv sync --frozen --no-cache
# Copy the rest of the application
COPY . .
# Copy the built frontend into backend/static for serving
COPY --from=frontend-builder /app/frontend-react/dist ./backend/static
# Deployment environment variables
ENV PORT=8080
ENV PYTHONPATH=/app
ENV PATH="/app/.venv/bin:$PATH"
EXPOSE 8080
# Healthcheck targeting the API
HEALTHCHECK CMD curl --fail http://localhost:8080/api/sessions || exit 1
# Launch the FastAPI app with uvicorn
# Cloud Run sets the PORT env var; we must listen on it.
CMD ["sh", "-c", "uvicorn backend.api:app --host 0.0.0.0 --port ${PORT:-8080}"]