# Use Python 3.9 image as the base | |
FROM python:3.9 | |
# Create a non-root user | |
RUN useradd -m -u 1000 user | |
# Set the working directory | |
WORKDIR /app | |
# Copy the requirements file and install dependencies | |
COPY requirements.txt /app/ | |
RUN pip install --upgrade pip | |
RUN pip install --no-cache-dir -r /app/requirements.txt | |
# Copy the entire application code into the working directory | |
COPY . /app/ | |
# Expose the port that Uvicorn will use | |
EXPOSE 8000 | |
# Switch to the non-root user | |
USER user | |
# Run the main program with Uvicorn (adjust path to match your actual app structure) | |
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000"] | |