asahwells commited on
Commit
baa9902
·
1 Parent(s): 2c38872

Configure for Hugging Face Spaces

Browse files
Files changed (1) hide show
  1. Dockerfile +18 -6
Dockerfile CHANGED
@@ -1,12 +1,24 @@
1
  FROM python:3.11-slim
2
 
3
- WORKDIR /app
 
4
 
5
- COPY requirements.txt .
6
- RUN pip install --no-cache-dir -r requirements.txt
7
 
8
- COPY . .
 
 
9
 
10
- ENV PORT=8000
11
 
12
- CMD ["sh", "-c", "uvicorn main:app --host 0.0.0.0 --port $PORT"]
 
 
 
 
 
 
 
 
 
 
1
  FROM python:3.11-slim
2
 
3
+ # Set up a new user named "user" with user ID 1000
4
+ RUN useradd -m -u 1000 user
5
 
6
+ # Switch to the "user" user
7
+ USER user
8
 
9
+ # Set home to the user's home directory
10
+ ENV HOME=/home/user \
11
+ PATH=/home/user/.local/bin:$PATH
12
 
13
+ WORKDIR $HOME/app
14
 
15
+ # Copy the current directory contents into the container at $HOME/app setting the owner to the user
16
+ COPY --chown=user . $HOME/app
17
+
18
+ # Install requirements
19
+ RUN pip install --no-cache-dir --upgrade -r requirements.txt
20
+
21
+ # Set the port to 7860 (required by Hugging Face Spaces)
22
+ ENV PORT=7860
23
+
24
+ CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]