-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathDockerfile
More file actions
42 lines (31 loc) · 1.21 KB
/
Copy pathDockerfile
File metadata and controls
42 lines (31 loc) · 1.21 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
# ============================================================
# StudyMate AI — Multi-stage Dockerfile
# Builds the React frontend (static assets) and serves it
# alongside the FastAPI backend, ready for AWS App Runner.
# ============================================================
# ---------- Stage 1: build the frontend ----------
FROM node:20-alpine AS frontend-build
WORKDIR /app
# Copy manifests first for better layer caching
COPY package.json package-lock.json ./
RUN npm ci
# Copy the rest of the frontend source and build
COPY . .
RUN npm run build
# ---------- Stage 2: build the backend image ----------
FROM python:3.11-slim AS backend
# Set environment so Python writes no .pyc files and flushes logs immediately
ENV PYTHONDONTWRITEBYTECODE=1 \
PYTHONUNBUFFERED=1 \
PORT=8000
WORKDIR /app
# Install backend dependencies
COPY backend/requirements.txt ./requirements.txt
RUN pip install --no-cache-dir -r requirements.txt
# Copy backend source
COPY backend/ ./
# Copy the built frontend static assets so FastAPI can optionally serve them
COPY --from=frontend-build /app/dist ./static
EXPOSE 8000
# Run the FastAPI server with uvicorn
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000"]