heymenn commited on
Commit
b0f61f2
·
verified ·
1 Parent(s): cdc7848

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +18 -11
Dockerfile CHANGED
@@ -1,16 +1,23 @@
1
- # Read the doc: https://huggingface.co/docs/hub/spaces-sdks-docker
2
- # you will also find guides on how best to write your Dockerfile
3
 
4
- FROM python:3.9
 
5
 
6
- RUN useradd -m -u 1000 user
7
- USER user
8
- ENV PATH="/home/user/.local/bin:$PATH"
 
 
9
 
10
- WORKDIR /app
 
11
 
12
- COPY --chown=user ./requirements.txt requirements.txt
13
- RUN pip install --no-cache-dir --upgrade -r requirements.txt
 
14
 
15
- COPY --chown=user . /app
16
- CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]
 
 
 
1
+ # 1. Use an official Python runtime as a parent image
2
+ FROM python:3.10-slim
3
 
4
+ # 2. Set the working directory in the container
5
+ WORKDIR /code
6
 
7
+ # 3. Copy the dependencies file and install them
8
+ # This is done in a separate step to leverage Docker's layer caching.
9
+ # The dependencies will only be re-installed if requirements.txt changes.
10
+ COPY ./requirements.txt /code/requirements.txt
11
+ RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt
12
 
13
+ # 4. Copy the rest of the application's code into the container
14
+ COPY . /code/
15
 
16
+ # 5. Expose the port that the app will run on
17
+ # Hugging Face Spaces expect the app to listen on port 7860
18
+ EXPOSE 7860
19
 
20
+ # 6. Define the command to run your app
21
+ # This command starts the Uvicorn server which serves your FastAPI app.
22
+ # --host 0.0.0.0 makes the server accessible from outside the container.
23
+ CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]