Spaces:
Runtime error
Runtime error
File size: 2,478 Bytes
91ac14d 63ed3a7 91ac14d 3380376 e3c6edf 3380376 91ac14d 63ed3a7 91ac14d 63ed3a7 91ac14d 63ed3a7 91ac14d 87e57a0 63ed3a7 91ac14d 63ed3a7 87e57a0 63ed3a7 91ac14d 63ed3a7 91ac14d 87e57a0 91ac14d 63ed3a7 91ac14d 3380376 63ed3a7 91ac14d 63ed3a7 91ac14d | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 | # Base image with uv + Python 3.12
FROM ghcr.io/astral-sh/uv:python3.12-bookworm-slim
# ---------- build-time args ----------
ARG PORT=8001
ARG TRANSPORT_SERVER_URL=https://blanchon-robothub-transportserver.hf.space/api
# ---------- system packages ----------
RUN apt-get update && apt-get install -y --no-install-recommends \
build-essential gcc g++ \
libgl1-mesa-glx libglib2.0-0 libsm6 libxext6 libxrender-dev libgomp1 \
ffmpeg git \
&& apt-get clean && rm -rf /var/lib/apt/lists/*
# ---------- non-root user ----------
RUN groupadd -r appuser && useradd -m -r -g appuser -s /bin/bash appuser
# ---------- working dir ----------
WORKDIR /app
# ---------- copy manifests (as root, but owned by appuser) ----------
COPY --chown=appuser:appuser pyproject.toml uv.lock* ./
COPY --chown=appuser:appuser external/ ./external/
# ---------- switch to non-root BEFORE anything that downloads ----------
USER appuser
# ---------- cache locations (all writable) ----------
ENV \
# generic caches
XDG_CACHE_HOME=/home/appuser/.cache \
# huggingface-hub + datasets
HF_HOME=/home/appuser/.cache \
HF_HUB_CACHE=/home/appuser/.cache/hub \
HUGGINGFACE_HUB_CACHE=/home/appuser/.cache/hub \
# transformers
TRANSFORMERS_CACHE=/home/appuser/.cache/huggingface/hub \
# uv & app settings
PYTHONUNBUFFERED=1 \
PYTHONDONTWRITEBYTECODE=1 \
UV_SYSTEM_PYTHON=1 \
UV_COMPILE_BYTECODE=1 \
UV_CACHE_DIR=/tmp/uv-cache \
PORT=${PORT} \
TRANSPORT_SERVER_URL=${TRANSPORT_SERVER_URL}
# make sure cache dirs exist
RUN mkdir -p $HF_HUB_CACHE $TRANSFORMERS_CACHE
# ---------- install dependencies ----------
RUN --mount=type=cache,target=/tmp/uv-cache \
uv sync --locked --no-install-project --no-dev
# ---------- copy application code ----------
COPY --chown=appuser:appuser . .
# ---------- install project itself ----------
RUN --mount=type=cache,target=/tmp/uv-cache \
uv sync --locked --no-editable --no-dev
# ---------- virtual-env path ----------
ENV PATH="/app/.venv/bin:$PATH"
# ---------- network / health ----------
EXPOSE ${PORT}
HEALTHCHECK --interval=30s --timeout=10s --start-period=30s --retries=3 \
CMD python -c "import urllib.request, os; urllib.request.urlopen(f'http://localhost:{os.getenv(\"PORT\")}/api/health')" || exit 1
# ---------- run ----------
CMD ["sh", "-c", "python launch_simple.py --host 0.0.0.0 --port ${PORT} --transport-server-url ${TRANSPORT_SERVER_URL}"]
|