44 lines
1022 B
Docker
44 lines
1022 B
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: Final Image (Python + Nginx)
|
|
# Use Python base image to ensure binary compatibility for pandas/numpy
|
|
FROM python:3.11-slim
|
|
|
|
# Install Nginx
|
|
RUN apt-get update && \
|
|
apt-get install -y nginx && \
|
|
rm -rf /var/lib/apt/lists/*
|
|
|
|
WORKDIR /app
|
|
|
|
# Install Backend Dependencies
|
|
COPY backend/requirements.txt /app/backend/requirements.txt
|
|
RUN pip install --no-cache-dir -r /app/backend/requirements.txt
|
|
|
|
# Copy Backend Code
|
|
COPY backend /app/backend
|
|
|
|
# Copy Frontend Build from Stage 1
|
|
COPY --from=frontend-build /app/frontend/dist /usr/share/nginx/html
|
|
|
|
# Copy Nginx Config
|
|
COPY nginx.conf /etc/nginx/nginx.conf
|
|
|
|
# Copy Entrypoint Script
|
|
COPY docker-entrypoint.sh /docker-entrypoint.sh
|
|
RUN chmod +x /docker-entrypoint.sh
|
|
|
|
# Expose Port
|
|
EXPOSE 80
|
|
|
|
# Start Services
|
|
CMD ["/docker-entrypoint.sh"]
|