Pipertts / Dockerfile
Gregniuki's picture
Update Dockerfile
8f9e79a
raw
history blame
1.08 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 /code
# Copy the requirements file into the container at /code/
COPY ./requirements.txt /code/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
# Specify the command to run your application (modify as needed)
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]