Spaces:
Running
Running
Mimi
commited on
Commit
·
bdc9847
1
Parent(s):
1644bb2
sdf
Browse files- Dockerfile +15 -17
Dockerfile
CHANGED
|
@@ -1,32 +1,30 @@
|
|
| 1 |
# Use Python 3.12 as the base image
|
| 2 |
FROM python:3.12
|
| 3 |
|
| 4 |
-
# Set
|
| 5 |
-
|
| 6 |
|
| 7 |
-
#
|
| 8 |
-
|
| 9 |
-
mkdir -p /home/user/.cache/huggingface && \
|
| 10 |
-
chown -R user:user /home/user/.cache /code
|
| 11 |
|
| 12 |
-
# Set
|
| 13 |
ENV HOME=/home/user \
|
| 14 |
-
|
| 15 |
-
PATH=/home/user/.local/bin:$PATH
|
| 16 |
|
| 17 |
-
#
|
| 18 |
-
|
| 19 |
|
| 20 |
-
#
|
| 21 |
-
|
| 22 |
-
|
|
|
|
| 23 |
|
| 24 |
-
# Copy
|
| 25 |
-
|
| 26 |
|
| 27 |
# Hugging Face Spaces does NOT support --mount=type=secret.
|
| 28 |
# Instead, access HF_TOKEN via environment variables at runtime.
|
| 29 |
-
CMD huggingface-cli login --token
|
| 30 |
streamlit run app.py \
|
| 31 |
--server.headless true \
|
| 32 |
--server.enableCORS false \
|
|
|
|
| 1 |
# Use Python 3.12 as the base image
|
| 2 |
FROM python:3.12
|
| 3 |
|
| 4 |
+
# Set up a new user named "user" with user ID 1000
|
| 5 |
+
RUN useradd -m -u 1000 user
|
| 6 |
|
| 7 |
+
# Switch to the "user" user
|
| 8 |
+
USER user
|
|
|
|
|
|
|
| 9 |
|
| 10 |
+
# Set home to the user's home directory
|
| 11 |
ENV HOME=/home/user \
|
| 12 |
+
PATH=/home/user/.local/bin:$PATH
|
|
|
|
| 13 |
|
| 14 |
+
# Set the working directory to the user's home directory
|
| 15 |
+
WORKDIR $HOME/app
|
| 16 |
|
| 17 |
+
# Try and run pip command after setting the user with `USER user` to avoid permission issues with Python
|
| 18 |
+
RUN pip install --no-cache-dir --upgrade pip
|
| 19 |
+
# Copy the current directory contents into the container at $HOME/app setting the owner to the user
|
| 20 |
+
COPY --chown=user . $HOME/app
|
| 21 |
|
| 22 |
+
# Copy requirements and install dependencies
|
| 23 |
+
RUN pip install --no-cache-dir --upgrade -r requirements.txt
|
| 24 |
|
| 25 |
# Hugging Face Spaces does NOT support --mount=type=secret.
|
| 26 |
# Instead, access HF_TOKEN via environment variables at runtime.
|
| 27 |
+
CMD huggingface-cli login --token $HF_TOKEN --add-to-git-credential && \
|
| 28 |
streamlit run app.py \
|
| 29 |
--server.headless true \
|
| 30 |
--server.enableCORS false \
|