-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
77 lines (57 loc) · 2.29 KB
/
Dockerfile
File metadata and controls
77 lines (57 loc) · 2.29 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 build for better efficiency
# Stage 1: Frontend build
FROM node:18-alpine AS frontend-builder
WORKDIR /app
# Copy frontend package files
COPY package*.json ./
# Create production environment file for build
# For local testing on main IDE, use port 10086
RUN echo "VUE_APP_WS_URL=ws://localhost:10086" > .env.production
# Install dependencies (including dev dependencies for build)
RUN npm ci
# Copy frontend source
COPY src/ ./src/
COPY public/ ./public/
COPY vue.config.js ./
COPY babel.config.js ./
# Build frontend
RUN npm run build
# Stage 2: Python runtime
FROM python:3.11-slim
# Set working directory
WORKDIR /app
# Install only essential system dependencies
RUN apt-get update && apt-get install -y \
gcc \
curl \
&& rm -rf /var/lib/apt/lists/*
# Copy and install Python dependencies
COPY server/requirements.txt ./server/
RUN pip install --no-cache-dir -r server/requirements.txt
# Copy server code
COPY server/ ./server/
# Copy deployment scripts
COPY deployment/ ./deployment/
# Copy built frontend from previous stage
COPY --from=frontend-builder /app/dist/ ./dist/
# Create mount points for both local and AWS EFS
RUN mkdir -p /tmp/pythonide-data/ide /mnt/efs/pythonide-data/ide
# Set environment variables
ENV PORT=8080
ENV PYTHONUNBUFFERED=1
ENV PYTHONPATH=/app
ENV IDE_DATA_PATH=/mnt/efs/pythonide-data
ENV MPLBACKEND=Agg
# Expose port
EXPOSE 8080
# Health check
HEALTHCHECK --interval=30s --timeout=3s --start-period=40s --retries=3 \
CMD curl -f http://localhost:8080/health || exit 1
# Start the application with initialization
WORKDIR /app/server
# Create adminData directory (will be empty in CI/CD, populated in production)
RUN mkdir -p /app/adminData
# Note: adminData is in .gitignore for security, so it won't exist in CI/CD builds
# In production, mount credentials as a volume or use AWS Secrets Manager
# Conditional startup based on IS_EXAM_MODE environment variable
CMD ["sh", "-c", "if [ \"$IS_EXAM_MODE\" = \"true\" ]; then echo 'Starting in EXAM mode...' && python /app/server/init_exam_users.py && python /app/server/ensure_efs_directories.py && python server.py; else echo 'Starting in NORMAL mode...' && /app/deployment/sync-student-directories.sh && python /app/server/auto_init_users.py && python /app/server/ensure_efs_directories.py && python server.py; fi"]