DinoPLayZ commited on
Commit
1e7f554
·
verified ·
1 Parent(s): cf3514c

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +32 -31
Dockerfile CHANGED
@@ -1,31 +1,32 @@
1
- # Use a lightweight Python base image
2
- FROM python:3.10-slim
3
-
4
- # Set up a working directory
5
- WORKDIR /app
6
-
7
- # In HuggingFace Spaces it's crucial to set up the correct user privileges
8
- # Spaces require running as a non-root user with UID 1000
9
- RUN useradd -m -u 1000 user
10
- USER user
11
-
12
- # Ensure the /app path is owned by our new user
13
- # (This step must run as root before we switch, so we move it up)
14
- USER root
15
- RUN chown -R user:user /app
16
- USER user
17
-
18
- # Set environmental variables
19
- ENV PATH="/home/user/.local/bin:$PATH"
20
-
21
- # Copy in the requirements file and install dependencies
22
- COPY --chown=user:user requirements.txt .
23
- RUN pip install --no-cache-dir -r requirements.txt
24
-
25
- # Copy the actual Python script and .env if it exists
26
- COPY --chown=user:user main.py .
27
- # We don't forcibly COPY .env because users should use HF Secrets,
28
- # but if it's there it won't break anything.
29
-
30
- # The command to start our infinite loop script
31
- CMD ["python", "main.py", "--run"]
 
 
1
+ # Use a lightweight Python base image
2
+ FROM python:3.10-slim
3
+
4
+ # Set up a working directory
5
+ WORKDIR /app
6
+
7
+ # In HuggingFace Spaces it's crucial to set up the correct user privileges
8
+ # Spaces require running as a non-root user with UID 1000
9
+ RUN useradd -m -u 1000 user
10
+ USER user
11
+
12
+ # Ensure the /app path is owned by our new user
13
+ # (This step must run as root before we switch, so we move it up)
14
+ USER root
15
+ RUN chown -R user:user /app
16
+ USER user
17
+
18
+ # Set environmental variables
19
+ ENV PATH="/home/user/.local/bin:$PATH"
20
+
21
+ # Copy in the requirements file and install dependencies
22
+ COPY --chown=user:user requirements.txt .
23
+ RUN pip install --no-cache-dir -r requirements.txt
24
+
25
+ # Copy the actual Python script and .env if it exists
26
+ COPY --chown=user:user main.py .
27
+ # We don't forcibly COPY .env because users should use HF Secrets,
28
+ # but if it's there it won't break anything.
29
+
30
+ # The command to start our infinite loop script
31
+ # The -u flag is REQUIRED for Docker/HuggingFace so logs print immediately!
32
+ CMD ["python", "-u", "main.py", "--run"]