-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
71 lines (52 loc) · 2.22 KB
/
Dockerfile
File metadata and controls
71 lines (52 loc) · 2.22 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
# Multi-stage Dockerfile adapted from GameArena style
# ============================================
# Stage 1: Build frontend (Node.js)
# ============================================
FROM node:18-bullseye-slim AS frontend-builder
WORKDIR /app/frontend
# Copy package files and install dependencies reproducibly
COPY frontend/package.json frontend/package-lock.json ./
RUN npm ci --no-audit --no-fund --silent
# Copy frontend sources and build
COPY frontend/ ./
ARG VITE_API_BASE=""
ENV VITE_API_BASE=${VITE_API_BASE}
RUN npm run build --silent
# ============================================
# Stage 2: Python runtime
# ============================================
FROM python:3.11-slim
LABEL maintainer="FunGame Team"
LABEL description="FunGame - Flask + React + PixiJS"
LABEL version="1.0.0"
ENV PYTHONUNBUFFERED=1 \
PYTHONDONTWRITEBYTECODE=1 \
FLASK_ENV=production \
PORT=5000
WORKDIR /app
# Install minimal system dependencies
RUN apt-get update \
&& apt-get install -y --no-install-recommends curl gcc ca-certificates \
&& rm -rf /var/lib/apt/lists/*
# Copy and install Python requirements
COPY requirements.txt ./requirements.txt
RUN pip install --no-cache-dir -r requirements.txt
# Create a non-root user for running the app
RUN useradd -m -u 1000 fungame || true && mkdir -p /app && chown -R fungame:fungame /app
# Copy application sources into the image and set ownership
# Use --chown so files are owned by the non-root user
COPY --chown=fungame:fungame ./. ./
# Copier le frontend buildé depuis le stage 1
COPY --from=frontend-builder --chown=fungame:fungame /app/frontend/dist ./static
# Copy built frontend from builder into ./frontend/dist so app can serve it
COPY --from=frontend-builder --chown=fungame:fungame /app/frontend/dist/ ./frontend/dist/
# Create runtime directories with proper ownership
RUN mkdir -p /app/logs && chown -R fungame:fungame /app/logs
# Switch to non-root user
USER fungame
EXPOSE 5000
# Healthcheck (runs as container user; use curl if installed)
HEALTHCHECK --interval=30s --timeout=5s --start-period=10s --retries=3 \
CMD ["sh", "-c", "curl -f http://127.0.0.1:5000/api || exit 1"]
# Start the application
CMD ["gunicorn", "-k", "eventlet", "-w", "1", "--bind", "0.0.0.0:5000", "wsgi:app"]