25-cxsj-final/Dockerfile

43 lines
1.0 KiB
Docker

# Multi-stage Dockerfile for Algorithm Platform
# Stage 1: Build Frontend
FROM node:18-alpine AS frontend-build
WORKDIR /app/frontend
COPY frontend/package*.json ./
RUN npm install
COPY frontend/ ./
RUN npm run build
# Stage 2: Setup Backend
FROM python:3.11-slim AS backend
WORKDIR /app/backend
COPY backend/requirements.txt ./
RUN pip install --no-cache-dir -r requirements.txt
COPY backend/ ./
# Stage 3: Final - Nginx + Backend
FROM nginx:alpine
WORKDIR /app
# Install Python and dependencies in final stage
RUN apk add --no-cache python3 py3-pip
# Copy backend
COPY --from=backend /app/backend /app/backend
COPY --from=backend /usr/local/lib/python3.11/site-packages /usr/local/lib/python3.11/site-packages
# Copy frontend build to Nginx
COPY --from=frontend-build /app/frontend/dist /usr/share/nginx/html
# Copy Nginx configuration
COPY nginx.conf /etc/nginx/nginx.conf
# Expose ports
EXPOSE 80
# Start script
COPY docker-entrypoint.sh /docker-entrypoint.sh
RUN chmod +x /docker-entrypoint.sh
CMD ["/docker-entrypoint.sh"]