saq1b commited on
Commit
c292a92
·
verified ·
1 Parent(s): 53e4005

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +37 -37
Dockerfile CHANGED
@@ -1,37 +1,37 @@
1
- # Use a full Python image
2
- FROM python:3.12
3
-
4
- # Create a new user named "user" with user ID 1000
5
- RUN useradd -m -u 1000 user
6
-
7
- # Switch to the "user" user for the remainder of the build
8
- USER user
9
-
10
- # Set home to the user's home directory and update PATH accordingly
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
- # Upgrade pip (as non-root) to avoid permission issues
18
- RUN pip install --no-cache-dir --upgrade pip
19
-
20
- # Copy the requirements file (with the correct ownership) to leverage Docker cache
21
- COPY --chown=user requirements.txt $HOME/app/requirements.txt
22
-
23
- # Install Python dependencies
24
- RUN pip install -r requirements.txt
25
-
26
- # Copy the rest of the application code into the container (with proper ownership)
27
- COPY --chown=user . $HOME/app
28
-
29
- # (Optional) If you need to download a checkpoint or other assets:
30
- # RUN mkdir -p content
31
- # ADD --chown=user https://<SOME_ASSET_URL> content/<SOME_ASSET_NAME>
32
-
33
- # Expose port 7860 (Hugging Face Spaces expects your app to listen on this port)
34
- EXPOSE 7860
35
-
36
- # Command to run the FastAPI app using uvicorn.
37
- CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]
 
1
+ # Use a Python image
2
+ FROM python:3.12-slim
3
+
4
+ # Create a new user named "user" with user ID 1000
5
+ RUN useradd -m -u 1000 user
6
+
7
+ # Switch to the "user" user for the remainder of the build
8
+ USER user
9
+
10
+ # Set home to the user's home directory and update PATH accordingly
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
+ # Upgrade pip (as non-root) to avoid permission issues
18
+ RUN pip install --no-cache-dir --upgrade pip
19
+
20
+ # Copy the requirements file (with the correct ownership) to leverage Docker cache
21
+ COPY --chown=user requirements.txt $HOME/app/requirements.txt
22
+
23
+ # Install Python dependencies
24
+ RUN pip install -r requirements.txt
25
+
26
+ # Copy the rest of the application code into the container (with proper ownership)
27
+ COPY --chown=user . $HOME/app
28
+
29
+ # (Optional) If you need to download a checkpoint or other assets:
30
+ # RUN mkdir -p content
31
+ # ADD --chown=user https://<SOME_ASSET_URL> content/<SOME_ASSET_NAME>
32
+
33
+ # Expose port 7860 (Hugging Face Spaces expects your app to listen on this port)
34
+ EXPOSE 7860
35
+
36
+ # Command to run the FastAPI app using uvicorn.
37
+ CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]