PowerGrid / Dockerfile
pvsai's picture
Fixed dockerize and validate submission working
9f270f4
Raw
History Blame Contribute Delete
1.2 kB
# Stage 1: Build the React frontend
FROM node:20-alpine AS build-frontend
WORKDIR /frontend
# Optimize npm install (no audit, no fund, cache mount)
ENV NPM_CONFIG_PROGRESS=false \
NPM_CONFIG_AUDIT=false \
NPM_CONFIG_FUND=false
COPY frontend/package*.json ./
RUN npm install --frozen-lockfile || npm install
COPY frontend/ .
RUN npm run build
# Stage 2: Final image
FROM python:3.11-slim
WORKDIR /app
# Minimal system dependencies (remove gcc/g++ to save time/space)
RUN apt-get update && apt-get install -y --no-install-recommends \
curl \
&& rm -rf /var/lib/apt/lists/*
# Optimize Python environment and PIP
ENV PYTHONPATH=/app \
PORT=7860 \
PYTHONDONTWRITEBYTECODE=1 \
PYTHONUNBUFFERED=1 \
PIP_NO_CACHE_DIR=1 \
PIP_DISABLE_PIP_VERSION_CHECK=1 \
PIP_DEFAULT_TIMEOUT=120
# Install Python dependencies
COPY backend/requirements.txt ./requirements.txt
RUN pip install -r requirements.txt
# Copy built frontend from Stage 1
COPY --from=build-frontend /frontend/dist ./frontend/dist
# Copy the entire project (respecting .dockerignore which now excludes node_modules)
COPY . .
EXPOSE 7860
# Run the unified FastAPI server
CMD ["python", "backend/main.py"]