# # Use the official PYTHON 3.9 IMAGE # FROM python:3.9 # # Set the working directory in the container # WORKDIR /code # # Copy the current directory contents into the container at /code # COPY requirements.txt /code/requirements.txt # # Install any needed packages specified in requirements.txt # RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt # # Copy the current directory contents into the container at /code # COPY . /code # # set up new user # RUN useradd user # # Change to the new user # USER user # # set home to the user's home directory # ENV HOME=/home/user \ # PATH=/home/user/.local/bin:$PATH # # Set the working directory in the container # WORKDIR $HOME/user # # Copy the current directory contents into the container at $HOME/app setting the owner to user # COPY --chown=user:user . $HOME/app # # Start the fastapi on port 8000 # CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"] # Use the official PYTHON 3.9 IMAGE FROM python:3.9 # Set the working directory in the container WORKDIR /app # Copy the requirements file into the container COPY requirements.txt /app/requirements.txt # Install the dependencies RUN pip install --no-cache-dir --upgrade -r /app/requirements.txt # Copy the current directory contents into the container COPY . /app # Set up a non-root user RUN useradd -m user && \ chown -R user:user /app # Switch to the non-root user USER user # Set environment variables ENV HOME=/home/user \ PATH=/home/user/.local/bin:$PATH # Expose the application on port 7860 EXPOSE 7860 # Start the FastAPI application CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]