File size: 989 Bytes
0fb809c 2a473f0 0fb809c 2a473f0 0fb809c 2a473f0 1bc675d 2a473f0 0fb809c 2a473f0 0fb809c 2a473f0 0fb809c 2a473f0 0e6018e 2a473f0 0fb809c 2a473f0 | 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 | # Use Python 3.12 slim base image to keep the image size small
FROM python:3.12-slim
# Create a non-root user with UID 1000 for security best practices
RUN useradd -m -u 1000 user
# Set Python path to /app directory
ENV PYTHONPATH="/app"
# Set the working directory for all subsequent commands
WORKDIR /app
# Install system dependencies and clean up apt cache to reduce image size
RUN apt-get update && apt-get install -y \
curl wget git-core\
&& rm -rf /var/lib/apt/lists/*
# Copy requirements file with appropriate permissions and install dependencies
COPY --chown=user requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
# Copy the rest of the application code with appropriate ownership
COPY --chown=user . /app
# Document the port that the application will listen on
EXPOSE 9099
USER user
# Define the command to run the FastAPI application using uvicorn
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "9099"] |