58 lines
1.4 KiB
Docker
58 lines
1.4 KiB
Docker
# Multi-stage build for production
|
|
# Stage 1: Build React frontend
|
|
FROM node:20-slim AS frontend-builder
|
|
|
|
WORKDIR /app/frontend
|
|
|
|
# Copy package files from nested directory
|
|
COPY frontend/frontend/package*.json ./
|
|
|
|
# Install dependencies
|
|
RUN npm ci --only=production
|
|
|
|
# Copy frontend source
|
|
COPY frontend/frontend ./
|
|
|
|
# Build for production (outputs to ../backend/static)
|
|
RUN npm run build
|
|
|
|
# Stage 2: Production Flask app
|
|
FROM python:3.14-slim
|
|
|
|
WORKDIR /app
|
|
|
|
# Install uv for dependency management
|
|
COPY --from=ghcr.io/astral-sh/uv:latest /uv /usr/local/bin/uv
|
|
|
|
# Copy Python dependency files
|
|
COPY pyproject.toml uv.lock ./
|
|
|
|
# Install Python dependencies
|
|
RUN uv sync --frozen --no-dev
|
|
|
|
# Copy backend code
|
|
COPY backend ./backend
|
|
COPY main.py ./
|
|
COPY migrations ./migrations
|
|
|
|
# Copy built frontend from frontend-builder stage
|
|
COPY --from=frontend-builder /app/backend/static ./backend/static
|
|
|
|
# Create directories for uploads and database
|
|
RUN mkdir -p backend/instance backend/static/images backend/static/audio
|
|
|
|
# Set environment variables
|
|
ENV FLASK_ENV=production
|
|
ENV PORT=5001
|
|
ENV PYTHONUNBUFFERED=1
|
|
|
|
# Expose port
|
|
EXPOSE 5001
|
|
|
|
# Health check
|
|
HEALTHCHECK --interval=30s --timeout=5s --start-period=10s --retries=3 \
|
|
CMD python -c "import urllib.request; urllib.request.urlopen('http://localhost:5001/api/health')"
|
|
|
|
# Run Flask app with socketio support
|
|
CMD ["uv", "run", "python", "main.py"]
|