# ============================================================ # Stage 1 — Build the React frontend # ============================================================ FROM node:22-slim AS frontend-build WORKDIR /app/frontend # Copy package files first for better layer caching COPY frontend/package.json frontend/package-lock.json ./ # Install dependencies RUN npm ci --production=false # Copy the rest of the frontend source COPY frontend/ . # Build-time env vars — these are PUBLIC client-side keys that get baked # into the JS bundle. They are NOT secrets (visible in browser devtools). ENV VITE_FIREBASE_API_KEY=AIzaSyAjBBEyjCTg813dfDxstJmw1xQ390AaEko ENV VITE_FIREBASE_AUTH_DOMAIN=socialshareandcarengo.firebaseapp.com ENV VITE_FIREBASE_PROJECT_ID=socialshareandcarengo ENV VITE_FIREBASE_STORAGE_BUCKET=socialshareandcarengo.firebasestorage.app ENV VITE_FIREBASE_MESSAGING_SENDER_ID=233936256945 ENV VITE_FIREBASE_APP_ID=1:233936256945:web:4ce50f81d085c00c1bc790 ENV VITE_FIREBASE_MEASUREMENT_ID=G-9J43PT6H4G ENV VITE_RAZORPAY_KEY_ID=rzp_test_SKJ5P6PFqYPrNt ENV VITE_API_URL=/api # Build the production bundle RUN npm run build # ============================================================ # Stage 2 — Production Python runtime # ============================================================ FROM python:3.11-slim # Install curl for health-check probes RUN apt-get update && apt-get install -y --no-install-recommends curl \ && rm -rf /var/lib/apt/lists/* WORKDIR /app # ── Python dependencies ──────────────────────────────────── COPY backend/requirements.txt ./requirements.txt RUN pip install --no-cache-dir -r requirements.txt # ── Backend source code ──────────────────────────────────── COPY backend/ ./backend/ # ── Built frontend (from Stage 1) ────────────────────────── COPY --from=frontend-build /app/frontend/dist ./frontend/dist # ── Expose a single port ─────────────────────────────────── ENV PORT=7860 EXPOSE 7860 # ── Health check ─────────────────────────────────────────── HEALTHCHECK --interval=30s --timeout=5s --start-period=10s --retries=3 \ CMD curl -f http://localhost:7860/api/health || exit 1 # ── Start with Gunicorn (production WSGI server) ────────── CMD ["gunicorn", \ "--bind", "0.0.0.0:7860", \ "--workers", "4", \ "--timeout", "120", \ "--access-logfile", "-", \ "--error-logfile", "-", \ "--chdir", "/app/backend", \ "app:app"]