Repository navigation
Expand file tree
/
Copy pathDockerfile
More file actions
55 lines (44 loc) · 1.9 KB
/
Copy pathDockerfile
File metadata and controls
55 lines (44 loc) · 1.9 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
# ==============================================================================
# JobHelperGuru Production Multi-Stage Dockerfile
# Stage 1: Build React Frontend Assets
# Stage 2: Serve Unified FastAPI Service on Render Free Tier
# ==============================================================================
# ------------------------------------------------------------------------------
# Stage 1: Frontend Builder
# ------------------------------------------------------------------------------
FROM node:20-alpine AS frontend-builder
WORKDIR /app/frontend
# Install dependencies
COPY frontend/package*.json ./
RUN npm ci
# Build static bundle
COPY frontend/ ./
ARG VITE_GOOGLE_CLIENT_ID
ENV VITE_GOOGLE_CLIENT_ID=$VITE_GOOGLE_CLIENT_ID
RUN npm run build
# ------------------------------------------------------------------------------
# Stage 2: Production Python Runtime
# ------------------------------------------------------------------------------
FROM python:3.11-slim AS production
WORKDIR /app
# Install system dependencies (curl for container health checks, libpq-dev for PostgreSQL)
RUN apt-get update && apt-get install -y --no-install-recommends \
curl \
gcc \
libpq-dev \
&& rm -rf /var/lib/apt/lists/*
# Install Python production dependencies
COPY requirements.txt .
COPY requirements/ ./requirements/
RUN pip install --no-cache-dir -r requirements.txt
# Copy backend source code and initialize local storage directories
COPY backend/ ./backend/
RUN mkdir -p /app/data/uploads
# Copy built frontend assets from Stage 1 into the location expected by FastAPI
COPY --from=frontend-builder /app/frontend/dist ./frontend/dist
# Render assigns port dynamically via $PORT environment variable (defaults to 8000)
EXPOSE 8000
ENV PORT=8000
ENV PYTHONUNBUFFERED=1
# Start FastAPI via uvicorn binding to 0.0.0.0 and dynamic $PORT
CMD ["sh", "-c", "uvicorn backend.main:app --host 0.0.0.0 --port ${PORT:-8000}"]