Spaces:
Sleeping
Sleeping
| # Read the doc: https://huggingface.co/docs/hub/spaces-sdks-docker | |
| # you will also find guides on how best to write your Dockerfile | |
| FROM python:3.9 | |
| RUN useradd -m -u 1000 user | |
| # Create directory for secrets | |
| RUN mkdir -p /home/user/secrets && chown user:user /home/user/secrets | |
| USER user | |
| ENV PATH="/home/user/.local/bin:$PATH" | |
| WORKDIR /app | |
| COPY --chown=user ./requirements.txt requirements.txt | |
| RUN pip install --no-cache-dir --upgrade -r requirements.txt | |
| # Mount and store the GEMINI_API_KEY secret at build time | |
| RUN --mount=type=secret,id=GEMINI_API_KEY,mode=0444,required=true \ | |
| cat /run/secrets/GEMINI_API_KEY > /home/user/secrets/gemini_key && \ | |
| echo "GEMINI_API_KEY=$(cat /home/user/secrets/gemini_key)" > /app/.env | |
| COPY --chown=user . /app | |
| # Copy models | |
| COPY --chown=user ./models /app/models | |
| CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"] | |