Davy592's picture
non-root user aftr installing system dependencies
24ca8d9
raw
history blame
761 Bytes
FROM python:3.12-slim
# Install system dependencies as root
RUN apt-get update && apt-get install -y --no-install-recommends \
build-essential \
&& rm -rf /var/lib/apt/lists/*
# Create a non-root user
RUN useradd -m -u 1000 user
USER user
ENV PATH="/home/user/.local/bin:$PATH"
WORKDIR /app
# Copy source code and dependency files FIRST (needed by flit)
COPY --chown=user pyproject.toml ./
COPY --chown=user nygaardcodecommentclassification ./nygaardcodecommentclassification
COPY --chown=user app.py ./
# Install Python dependencies
RUN pip install --no-cache-dir --upgrade pip && \
pip install --no-cache-dir -e ".[api]"
# Expose port
EXPOSE 7860
# Run uvicorn on port 7860
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]