-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
64 lines (46 loc) · 1.51 KB
/
Dockerfile
File metadata and controls
64 lines (46 loc) · 1.51 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
# Multi-stage build for better optimization
FROM node:18-alpine AS frontend-builder
WORKDIR /app/frontend
# Copy package files
COPY frontend/package*.json ./
# Clear npm cache and install dependencies
RUN npm cache clean --force && \
(npm ci --no-audit --no-fund || npm install --no-audit --no-fund)
# Copy frontend source code
COPY frontend/ ./
# Build the frontend
RUN npm run build
# Python backend stage
FROM python:3.11-slim AS backend
# Create non-root user for security
RUN groupadd -r appuser && useradd -r -g appuser appuser
# Install system dependencies
RUN apt-get update && apt-get install -y \
gcc \
g++ \
curl \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /app
# Copy and install Python dependencies
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
# Copy application code
COPY . .
# Copy built frontend from previous stage
COPY --from=frontend-builder /app/frontend/build ./frontend/build
# Create logs directory and set permissions
RUN mkdir -p logs && \
chown -R appuser:appuser /app
# Switch to non-root user
USER appuser
# Environment variables
ENV PORT=8080
ENV HOST=0.0.0.0
ENV FLASK_ENV=production
ENV PYTHONPATH=/app
EXPOSE 8080
# Health check
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
CMD curl -f http://localhost:8080/api/plugins || exit 1
# Use gunicorn with eventlet workers for SocketIO support
CMD ["gunicorn", "--bind", "0.0.0.0:8080", "--worker-class", "eventlet", "--workers", "1", "--timeout", "120", "app:app"]