Spaces:
Build error
Build error
Enoch Jason J
commited on
Commit
·
1425e56
1
Parent(s):
0ba11f7
Securely mount HF token during build
Browse files- Dockerfile +7 -7
Dockerfile
CHANGED
|
@@ -10,19 +10,19 @@ COPY download_models.py .
|
|
| 10 |
RUN pip install --no-cache-dir -r requirements_local.txt
|
| 11 |
|
| 12 |
# --- Pre-download and Cache Models ---
|
| 13 |
-
# FIX:
|
| 14 |
-
#
|
| 15 |
-
#
|
| 16 |
-
# The ARG line is no longer needed.
|
| 17 |
RUN --mount=type=cache,target=/root/.cache/huggingface \
|
| 18 |
-
|
|
|
|
| 19 |
|
| 20 |
# Copy the main application code
|
| 21 |
-
COPY
|
| 22 |
|
| 23 |
# Expose the port the app runs on
|
| 24 |
EXPOSE 8000
|
| 25 |
|
| 26 |
# Command to run the application
|
| 27 |
-
CMD ["uvicorn", "
|
| 28 |
|
|
|
|
| 10 |
RUN pip install --no-cache-dir -r requirements_local.txt
|
| 11 |
|
| 12 |
# --- Pre-download and Cache Models ---
|
| 13 |
+
# FIX: The RUN command is now updated to securely access the HF_TOKEN secret.
|
| 14 |
+
# 1. --mount=type=secret... makes the secret available at a temporary path.
|
| 15 |
+
# 2. The environment variable is set by reading from that secret path.
|
|
|
|
| 16 |
RUN --mount=type=cache,target=/root/.cache/huggingface \
|
| 17 |
+
--mount=type=secret,id=HUGGING_FACE_HUB_TOKEN \
|
| 18 |
+
HUGGING_FACE_HUB_TOKEN=$(cat /run/secrets/HUGGING_FACE_HUB_TOKEN) python download_models.py
|
| 19 |
|
| 20 |
# Copy the main application code
|
| 21 |
+
COPY main.py .
|
| 22 |
|
| 23 |
# Expose the port the app runs on
|
| 24 |
EXPOSE 8000
|
| 25 |
|
| 26 |
# Command to run the application
|
| 27 |
+
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000"]
|
| 28 |
|