Spaces:
Runtime error
Runtime error
Download Dockerfile from Talosware/talos-access: direct link, hf CLI and curl.
- Browser
- Download file 3.44 kB
-
https://huggingface.co/spaces/Talosware/talos-access/resolve/main/Dockerfile
- Command line
-
hf download hf://spaces/Talosware/talos-access/Dockerfile
-
curl -L -o Dockerfile https://huggingface.co/spaces/Talosware/talos-access/resolve/main/Dockerfile
3.44 kB
| # syntax=docker/dockerfile:1 | |
| # --------------------------------------------------------------------------- | |
| # Talos Access — image for Hugging Face Spaces / external Postgres | |
| # Stage 1: build the React/Vite frontend (esbuild bundle, no tsc gate) | |
| # Stage 2: Python backend (FastAPI + dlib/face_recognition) serving the SPA | |
| # --------------------------------------------------------------------------- | |
| # ---- Stage 1: frontend build ---- | |
| FROM node:22-slim AS frontend | |
| WORKDIR /fe | |
| COPY frontend/package.json ./ | |
| RUN npm install | |
| COPY frontend/ ./ | |
| # Use vite directly (skip `tsc -b`): esbuild transpiles regardless of the | |
| # project's pre-existing strict type errors; this matches how dev runs today. | |
| RUN npx vite build | |
| # ---- Stage 2: backend + static SPA ---- | |
| # NOTA: imagen optimizada para Hugging Face Spaces, que ejecuta el contenedor como | |
| # UID 1000 (no root). La DB es externa (Supabase en prod, docker-compose Postgres en dev); | |
| # sólo se necesita DATABASE_URL en runtime (HF Space secret o docker-compose env). | |
| FROM ubuntu:24.04 AS app | |
| ENV DEBIAN_FRONTEND=noninteractive | |
| ENV TZ=America/Caracas | |
| ENV PYTHONUNBUFFERED=1 | |
| # Only runtime libs are needed: dlib ships as a prebuilt wheel (dlib-bin), so we | |
| # avoid the heavy/OOM-prone source compile entirely. libgl1/libglib2.0-0 are for | |
| # opencv-python-headless. | |
| RUN apt-get update && apt-get install -y --no-install-recommends \ | |
| python3 python3-pip \ | |
| libgl1 libglib2.0-0 \ | |
| libmagic1 \ | |
| tzdata \ | |
| && ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone \ | |
| && rm -rf /var/lib/apt/lists/* | |
| # Hugging Face Spaces corre como UID 1000. ubuntu:24.04 ya trae un usuario 'ubuntu' | |
| # en UID 1000, así que lo eliminamos antes de crear 'user'. | |
| RUN (userdel -r ubuntu 2>/dev/null || true) && useradd -m -u 1000 user | |
| ENV HOME=/home/user \ | |
| PATH=/home/user/.local/bin:/usr/local/bin:/usr/bin:/sbin:/bin | |
| WORKDIR /app | |
| # Install Python deps (system-wide, legibles por cualquier usuario). Use the prebuilt | |
| # dlib wheel, then install the rest without rebuilding dlib/face_recognition from source. | |
| COPY backend/requirements.txt . | |
| RUN pip3 install --no-cache-dir --break-system-packages dlib-bin && \ | |
| grep -ivE '^(face[-_]recognition|dlib)([=<>! ]|$)' requirements.txt > /tmp/reqs.txt && \ | |
| pip3 install --no-cache-dir --break-system-packages -r /tmp/reqs.txt && \ | |
| pip3 install --no-cache-dir --break-system-packages --no-deps face_recognition==1.3.0 face_recognition_models && \ | |
| pip3 install --no-cache-dir --break-system-packages Pillow click numpy | |
| # Backend source + built frontend (servido por FastAPI en /app/static), propiedad | |
| # del usuario de runtime para evitar problemas de permisos en HF. | |
| COPY --chown=user backend/ /app/ | |
| COPY --chown=user --from=frontend /fe/dist /app/static | |
| RUN sed -i 's/\r$//' /app/entrypoint.sh && chmod +x /app/entrypoint.sh | |
| # Config de runtime no secreta. IMPORTANTE: define JWT_SECRET_KEY como Secret del | |
| # Space (el default 'change_me_in_production' es inseguro y el código es público). | |
| # DATABASE_URL (Supabase URL) and POSTGRES_PASSWORD are injected at runtime | |
| # via HF Space secrets or docker-compose environment. | |
| ENV POSTGRES_HOST=postgres \ | |
| POSTGRES_PORT=5432 \ | |
| POSTGRES_USER=talos \ | |
| POSTGRES_DB=talos_access \ | |
| SEED_DEMO=1 | |
| # Comillas simples: Docker preserva así las comillas internas (JSON válido ["*"]). | |
| ENV CORS_ORIGINS='["*"]' | |
| USER user | |
| EXPOSE 8000 | |
| CMD ["sh", "entrypoint.sh"] | |