File size: 882 Bytes
ff2d189 1c919ad ff2d189 1c919ad ff2d189 1c919ad ff2d189 1c919ad ff2d189 1c919ad 2f7dd30 ff2d189 e8b509f ff2d189 1c919ad ff2d189 1c919ad |
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 |
# Use an official Python runtime as a parent image
FROM python:3.9-slim
# Set the working directory in the container
WORKDIR /app
# Copy the dependencies file to the working directory
COPY requirements.txt .
# Install any needed packages specified in requirements.txt
RUN pip install --no-cache-dir -r requirements.txt
# Copy the content of the local src directory to the working directory
COPY main.py .
# Create a system group and user for security best practices
RUN addgroup --system appgroup && adduser --system --ingroup appgroup --no-create-home appuser
# Change the ownership of the app directory to the new user for good practice
RUN chown -R appuser:appgroup /app
# Switch to the non-root user
USER appuser
# Make port 8000 available to the world outside this container
EXPOSE 8000
# Run the app.
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000"] |