All checks were successful
Build Docker Container / build (push) Successful in 40s
34 lines
852 B
Docker
34 lines
852 B
Docker
FROM python:3.12-slim-trixie
|
|
|
|
# Set a working directory
|
|
WORKDIR /app
|
|
|
|
# Prevent Python from writing .pyc files and enable unbuffered stdout/stderr
|
|
ENV PYTHONDONTWRITEBYTECODE=1 \
|
|
PYTHONUNBUFFERED=1 \
|
|
APP_PORT=8081 \
|
|
GUNICORN_CMD_ARGS="--bind=0.0.0.0:8081 --workers=4 --threads=2"
|
|
|
|
# Install system deps
|
|
RUN apt-get update && apt-get install -y --no-install-recommends \
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
# Create a non-root user
|
|
RUN useradd --create-home --shell /bin/bash appuser
|
|
|
|
# Copy requirements and install
|
|
COPY requirements.txt /app/
|
|
RUN pip install --no-cache-dir -r requirements.txt
|
|
|
|
# Copy application
|
|
COPY . /app
|
|
RUN chown -R appuser:appuser /app
|
|
|
|
USER appuser
|
|
|
|
# expose the default APP_PORT (can be overridden at runtime)
|
|
EXPOSE 8081
|
|
|
|
# Default command: run the app with gunicorn
|
|
CMD ["gunicorn", "--chdir", "./", "app:app"]
|