Spaces:
Sleeping
Sleeping
Mimi
commited on
Commit
·
1644bb2
1
Parent(s):
b5e7d77
asdf
Browse files- Dockerfile +15 -2
Dockerfile
CHANGED
@@ -4,12 +4,25 @@ FROM python:3.12
|
|
4 |
# Set working directory
|
5 |
WORKDIR /code
|
6 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
7 |
# Copy requirements and install dependencies
|
8 |
-
COPY ./requirements.txt /code/requirements.txt
|
9 |
RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt
|
10 |
|
11 |
# Copy application files
|
12 |
-
COPY . /code/app
|
13 |
|
14 |
# Hugging Face Spaces does NOT support --mount=type=secret.
|
15 |
# Instead, access HF_TOKEN via environment variables at runtime.
|
|
|
4 |
# Set working directory
|
5 |
WORKDIR /code
|
6 |
|
7 |
+
# Create a non-root user and set permissions
|
8 |
+
RUN useradd -m -u 1000 user && \
|
9 |
+
mkdir -p /home/user/.cache/huggingface && \
|
10 |
+
chown -R user:user /home/user/.cache /code
|
11 |
+
|
12 |
+
# Set environment variables
|
13 |
+
ENV HOME=/home/user \
|
14 |
+
HF_HOME=/home/user/.cache/huggingface \
|
15 |
+
PATH=/home/user/.local/bin:$PATH
|
16 |
+
|
17 |
+
# Switch to the new user
|
18 |
+
USER user
|
19 |
+
|
20 |
# Copy requirements and install dependencies
|
21 |
+
COPY --chown=user:user ./requirements.txt /code/requirements.txt
|
22 |
RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt
|
23 |
|
24 |
# Copy application files
|
25 |
+
COPY --chown=user:user . /code/app
|
26 |
|
27 |
# Hugging Face Spaces does NOT support --mount=type=secret.
|
28 |
# Instead, access HF_TOKEN via environment variables at runtime.
|