Pipertts / Dockerfile
Gregniuki's picture
Update Dockerfile
38b2021
raw
history blame
1.14 kB
# 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"]