Spaces:
Sleeping
Sleeping
| # ============================================================ | |
| # 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"] |