-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathDockerfile
More file actions
77 lines (57 loc) · 2.13 KB
/
Dockerfile
File metadata and controls
77 lines (57 loc) · 2.13 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
68
69
70
71
72
73
74
75
76
77
# Multi-stage Dockerfile for MagPie Event Registration Platform
# Stage 1: Build React frontend
# Stage 2: Python runtime with FastAPI serving static frontend
# ============================================
# Stage 1: Frontend Builder
# ============================================
FROM node:18-alpine AS frontend-builder
WORKDIR /app/frontend
# Copy package files
COPY frontend/package*.json ./
# Install ALL dependencies (including devDependencies needed for build)
RUN npm ci
# Copy frontend source
COPY frontend/ ./
# Build frontend with Vite
# Mount VITE_CLERK_PUBLISHABLE_KEY as build secret
RUN --mount=type=secret,id=VITE_CLERK_PUBLISHABLE_KEY \
if [ -f /run/secrets/VITE_CLERK_PUBLISHABLE_KEY ]; then \
export VITE_CLERK_PUBLISHABLE_KEY=$(cat /run/secrets/VITE_CLERK_PUBLISHABLE_KEY); \
else \
echo "WARNING: VITE_CLERK_PUBLISHABLE_KEY build secret not provided"; \
echo "Usage: fly deploy --build-secret VITE_CLERK_PUBLISHABLE_KEY=pk_test_your_key"; \
exit 1; \
fi && \
npm run build
# Output is in /app/frontend/dist/
# ============================================
# Stage 2: Python Runtime
# ============================================
FROM python:3.11-slim
WORKDIR /app
# Install system dependencies
RUN apt-get update && apt-get install -y \
gcc \
&& rm -rf /var/lib/apt/lists/*
# Copy backend requirements
COPY backend/requirements.txt ./backend/
# Install Python dependencies
RUN pip install --no-cache-dir -r backend/requirements.txt
# Copy backend code
COPY backend/ ./backend/
# Copy built frontend from Stage 1
COPY --from=frontend-builder /app/frontend/dist ./frontend/dist
# Create non-root user for security
RUN adduser --disabled-password --gecos '' appuser && \
chown -R appuser:appuser /app
USER appuser
# Set working directory to backend for Python imports
WORKDIR /app/backend
# Environment variables
ENV PYTHONUNBUFFERED=1
ENV PYTHONDONTWRITEBYTECODE=1
# Expose port (fly.io uses 8080)
EXPOSE 8080
# Run uvicorn with production settings
# 2 workers for better performance, no reload
CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8080", "--workers", "2"]