forked from CipherYuvraj/Algorithm-Visualiser-Platform
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
45 lines (33 loc) · 1.15 KB
/
Dockerfile
File metadata and controls
45 lines (33 loc) · 1.15 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
# Multi-stage build optimized for Render free tier
# Stage 1: Build React frontend
FROM node:18-alpine AS frontend-build
WORKDIR /app/frontend
# Copy package files
COPY frontend/package*.json ./
RUN npm ci --only=production
# Copy frontend source and build
COPY frontend/ ./
RUN npm run build
# Stage 2: Python backend with built frontend
FROM python:3.11-slim
# Set working directory
WORKDIR /app
# Install system dependencies (minimal for free tier)
RUN apt-get update && apt-get install -y \
curl \
&& rm -rf /var/lib/apt/lists/* \
&& apt-get clean
# Copy backend requirements and install Python dependencies
COPY backend/requirements.txt ./
RUN pip install --no-cache-dir -r requirements.txt
# Copy backend source
COPY backend/ ./
# Copy built frontend from previous stage
COPY --from=frontend-build /app/frontend/build ./frontend/build
# Render uses PORT environment variable
ENV ENVIRONMENT=production
# Health check for Render
HEALTHCHECK --interval=30s --timeout=10s --start-period=30s --retries=3 \
CMD curl -f http://localhost:${PORT:-8000}/health || exit 1
# Use PORT from environment (Render requirement)
CMD ["sh", "-c", "python main.py"]