Spaces:
Sleeping
Sleeping
Download Dockerfile from Aynkhn/Face-Expression-Analyzer: direct link, hf CLI and curl.
- Browser
- Download file 2.54 kB
-
https://huggingface.co/spaces/Aynkhn/Face-Expression-Analyzer/resolve/main/Dockerfile
- Command line
-
hf download hf://spaces/Aynkhn/Face-Expression-Analyzer/Dockerfile
-
curl -L -o Dockerfile https://huggingface.co/spaces/Aynkhn/Face-Expression-Analyzer/resolve/main/Dockerfile
2.54 kB
| # --- Stage 1: build the frontend --- | |
| FROM node:20-alpine AS frontend-builder | |
| WORKDIR /app/frontend | |
| COPY frontend/package.json frontend/package-lock.json ./ | |
| # ci rather than install: a lockfile is committed, and `npm install` is free to | |
| # ignore it and resolve versions that were never tested. | |
| RUN npm ci | |
| COPY frontend/ ./ | |
| # Empty means "same origin". next/font and output:'export' inline NEXT_PUBLIC_* | |
| # values at *build* time, so leaving this unset previously baked | |
| # http://localhost:8000 into an image whose server listens on 7860 -- the bundle | |
| # called a host that does not exist for the user. | |
| ENV NEXT_PUBLIC_BACKEND_URL="" | |
| ENV NODE_ENV=production | |
| # `prebuild` stages the MediaPipe WASM runtime and model into public/models so | |
| # both are served from this origin: the runtime is copied from node_modules (so | |
| # its version always matches the installed package) and the model is downloaded. | |
| RUN npm run build | |
| # --- Stage 2: runtime --- | |
| FROM python:3.11-slim-bookworm | |
| # Hugging Face Spaces expects the process to run as uid 1000. | |
| RUN useradd --create-home --uid 1000 appuser | |
| WORKDIR /app | |
| # gcc and libpq-dev are not needed: psycopg2-binary ships prebuilt wheels, and | |
| # dropping them saves roughly 200MB. curl is kept for the healthcheck. | |
| RUN apt-get update \ | |
| && apt-get install -y --no-install-recommends curl \ | |
| && rm -rf /var/lib/apt/lists/* | |
| COPY backend/pyproject.toml backend/README.md* ./ | |
| COPY backend/app ./app | |
| RUN pip install --no-cache-dir . | |
| COPY backend/alembic.ini ./ | |
| COPY backend/migrations ./migrations | |
| COPY --from=frontend-builder /app/frontend/out ./static | |
| RUN chown -R appuser:appuser /app | |
| ENV PORT=7860 \ | |
| ENVIRONMENT=production \ | |
| DATABASE_URL="" \ | |
| # Must be on: the container sits behind the Spaces proxy, and without it | |
| # every visitor shares a single rate-limit bucket. | |
| TRUST_PROXY_HEADERS=true \ | |
| PYTHONUNBUFFERED=1 | |
| # FACEVISION_ADMIN_KEY is deliberately not set here. The application refuses to | |
| # start in production without it, which is what prevents a deployment from | |
| # silently running on a key that is public in the repository. Provide it as a | |
| # runtime secret: | |
| # docker run -e FACEVISION_ADMIN_KEY=... | |
| # On Hugging Face Spaces, add it under Settings -> Repository secrets. | |
| USER appuser | |
| EXPOSE 7860 | |
| # Meaningful now that /api/health actually probes the database. | |
| HEALTHCHECK --interval=30s --timeout=5s --start-period=20s --retries=3 \ | |
| CMD curl -fsS http://127.0.0.1:7860/api/health || exit 1 | |
| CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "7860"] | |