Spaces:
3SCError404
/
Paused

nexus / Dockerfile
dushyantsingh0
fix: include frontend in docker context
f332708
Raw History Blame Contribute Delete
1.9 kB
# --- STAGE 1: FRONTEND BUILD (Node.js) ---
FROM node:20-slim AS frontend-builder
WORKDIR /app
# Increase memory for the JS builder to prevent "exit code: 2" crashes
ENV NODE_OPTIONS="--max-old-space-size=4096"
# Copy monorepo root config
COPY frontend/package*.json ./frontend/
COPY frontend/tsconfig.json ./frontend/
# Copy all packages and apps
COPY frontend/packages ./frontend/packages
COPY frontend/apps ./frontend/apps
WORKDIR /app/frontend
# Install and build sequentially (More reliable than --workspaces)
RUN npm install
RUN npm run build -w apps/customer
RUN npm run build -w apps/internal
# --- STAGE 2: BACKEND BASE (Python) ---
FROM python:3.11-slim AS base
ENV PYTHONDONTWRITEBYTECODE=1 \
PYTHONUNBUFFERED=1 \
PYTHONPATH=/app
WORKDIR /app
# Install minimal system dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
build-essential \
libpq-dev \
gcc \
curl \
ca-certificates \
redis-server \
&& apt-get clean && rm -rf /var/lib/apt/lists/*
# Install core requirements
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
# --- STAGE 3: HEAVY-AI ---
FROM base AS heavy
COPY requirements-ai.txt .
RUN pip install --no-cache-dir -r requirements-ai.txt
# --- STAGE 4: PRODUCTION (Unified) ---
FROM heavy AS production
WORKDIR /app
# Copy backend application code
COPY . .
# Copy BUILT frontend assets from Stage 1
COPY --from=frontend-builder /app/frontend/apps/customer/dist ./frontend/apps/customer/dist
COPY --from=frontend-builder /app/frontend/apps/internal/dist ./frontend/apps/internal/dist
# Create runtime directories
RUN mkdir -p uploads logs
# Expose Hugging Face default port
EXPOSE 7860
# Ensure entrypoint script is executable
RUN sed -i 's/\r$//' scripts/run_prod.sh && \
chmod +x scripts/run_prod.sh
# Use the unified sidecar entrypoint
CMD ["./scripts/run_prod.sh"]