Spaces:
Running
Running
# Multi-stage Dockerfile for OmniSealBench | |
# Stage 1: Build the React frontend | |
FROM node:18-alpine AS frontend-builder | |
WORKDIR /app/frontend | |
# Copy package.json | |
COPY frontend/package.json ./ | |
# Install dependencies | |
RUN npm install | |
# Copy frontend source code | |
COPY frontend/ ./ | |
# Build the React app | |
RUN npm run build | |
# Stage 2: Set up the Flask backend and serve the app | |
FROM python:3.10-slim | |
WORKDIR /app | |
# Copy backend requirements and install dependencies | |
COPY backend/requirements.txt ./ | |
RUN pip install --no-cache-dir -r requirements.txt | |
# Copy backend code | |
COPY backend/ ./ | |
# Copy built frontend from the frontend-builder stage | |
COPY --from=frontend-builder /app/frontend/dist ./static | |
# Copy data and examples directories | |
COPY data/ ./data/ | |
COPY examples/ ./examples/ | |
# Set environment variables | |
ENV FLASK_APP=app.py | |
ENV FLASK_ENV=production | |
# Expose the port the app runs on | |
EXPOSE 5000 | |
# Copy startup and healthcheck scripts and make them executable | |
COPY backend/start.sh backend/healthcheck.sh ./ | |
RUN chmod +x ./start.sh ./healthcheck.sh | |
# Install curl for healthcheck | |
RUN apt-get update && apt-get install -y curl && rm -rf /var/lib/apt/lists/* | |
# Add healthcheck | |
HEALTHCHECK --interval=30s --timeout=10s --start-period=30s --retries=3 CMD ["./healthcheck.sh"] | |
# Command to run the app using the startup script | |
CMD ["./start.sh"] |