Spaces:
Running
Running
File size: 1,135 Bytes
41311e9 59d0e56 41311e9 59d0e56 c503f90 41311e9 59d0e56 c503f90 8f9e79a 59d0e56 41311e9 59d0e56 a1e71b8 59d0e56 a1e71b8 59d0e56 a1e71b8 59d0e56 a1e71b8 59d0e56 a1e71b8 38b2021 59d0e56 38b2021 |
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 |
# read the doc: https://huggingface.co/docs/hub/spaces-sdks-docker
# you will also find guides on how best to write your Dockerfile
# Use the official Python 3.9 image as the base image
FROM python:3.9
# Set the working directory to /code
WORKDIR /app
# Copy the requirements file into the container at /code/
COPY ./requirements.txt /app/requirements.txt
# Copy the FastAPI application code into the container
COPY ./app.py /app/app.py
# Install the required Python packages from requirements.txt
RUN pip install --no-cache-dir --upgrade -r requirements.txt
# Create a non-root user (optional but recommended for security)
RUN useradd -m -u 1000 user
# Switch to the non-root user
USER user
# Define environment variables
ENV HOME=/home/user \
PATH=/home/user/.local/bin:$PATH
# Change the working directory to /home/user/app
WORKDIR $HOME/app
# Copy the rest of the application files into the container
COPY --chown=user . $HOME/app
# Expose port 80 for the FastAPI application
EXPOSE 7860
# Specify the command to run your application (modify as needed)
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]
|