File size: 1,527 Bytes
0d57f1c
 
a3962e7
0d57f1c
a3962e7
 
e4309fa
 
a3962e7
28decc7
 
 
 
 
e4309fa
0d57f1c
 
e4309fa
94deb87
a3962e7
 
0d57f1c
 
 
 
 
a3962e7
0d57f1c
 
 
 
 
 
 
 
 
 
844748c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# Use an official Python runtime as a parent image
FROM python:3.9-slim

# Set the working directory in the container
WORKDIR /code

# Copy the pyproject.toml file into the container at /code
COPY ./pyproject.toml /code/pyproject.toml

# Copy the rest of the application code (the 'app' directory contents)
# into the container at /code/app
# Adjust if your Python code is not in an 'app' subfolder
COPY ./app /code/app

# Install the project and its dependencies using pyproject.toml
# --no-cache-dir: Disables the cache to keep image size down
# --upgrade pip: Ensures pip is up-to-date
RUN pip install --no-cache-dir --upgrade pip && \
    pip install --no-cache-dir -e /code


# Make port 8000 available to the world outside this container
# Hugging Face Spaces expects the app to listen on port 7860 by default,
# but Docker apps often use 8000. We can map this in Space config if needed,
# or change the port here and in the CMD. Let's use 8000 for now.
EXPOSE 8000

# Define environment variable (optional, can be set in HF Secrets)
# ENV NAME World

# Run main.py when the container launches
# Use uvicorn to run the FastAPI application
# --host 0.0.0.0: Makes the server accessible externally
# --port 8000: The port the server will listen on
# app.main:app: Tells uvicorn where to find the FastAPI app instance
# (in main.py inside the 'app' directory, the instance named 'app')
# Adjust 'app.main:app' if your file/instance names are different.
CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "7860"]