| 1234567891011121314151617181920212223242526272829303132333435363738394041424344 |
- # Stage 1: Build frontend
- FROM node:18-alpine AS frontend-builder
- WORKDIR /app/frontend
- COPY frontend/package*.json ./
- RUN npm ci
- COPY frontend/ ./
- RUN npm run build
- # Stage 2: Build backend
- FROM python:3.11-slim AS backend
- WORKDIR /app
- # Set timezone to Asia/Shanghai
- ENV TZ=Asia/Shanghai
- RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
- # Install system dependencies
- RUN apt-get update && apt-get install -y --no-install-recommends \
- libpq-dev \
- && rm -rf /var/lib/apt/lists/*
- # Install Python dependencies
- COPY backend/requirements.txt ./
- RUN pip install --no-cache-dir -r requirements.txt
- # Copy backend code
- COPY backend/ ./
- # Copy frontend build
- COPY --from=frontend-builder /app/frontend/dist ./static
- # Environment variables
- ENV FLASK_CONFIG=production
- ENV PYTHONUNBUFFERED=1
- # Expose port
- EXPOSE 5000
- # Run with gunicorn (production)
- CMD ["gunicorn", "-w", "4", "-b", "0.0.0.0:5000", "wsgi:app"]
- # Alternative: Flask dev server (not recommended for production)
- # CMD ["python", "run.py"]
|