File size: 682 Bytes
03631a9 3a57716 |
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 |
# Use an official Python image as a base
FROM python:3.12-slim
# Create a new user
RUN useradd -m user
# Set the working directory inside the container
WORKDIR /app
# Copy the requirements file and install dependencies
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
RUN mkdir /.cache
# Change ownership of the application directory to the new user
RUN chown -R user:user /.cache
RUN chown -R user:user /app
# Copy the rest of the application code
COPY . .
# Expose port 8000 for the FastAPI app
EXPOSE 7860
# Switch to the new user
USER user
# Run the FastAPI app with uvicorn
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"] |