Files
flask_blog/Dockerfile
2026-03-16 04:30:50 +01:00

26 lines
557 B
Docker

FROM python:3.11-slim
ARG USER_UID=1000
ARG USER_GID=1000
# --build-arg USER_GID= USER_UID=
RUN groupadd -g "${USER_GID}" flaskuser \
&& useradd -u "${USER_UID}" -g "${USER_GID}" flaskuser
WORKDIR /app
# Install dependencies
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt gunicorn
# Copy the rest of the code
COPY . .
# Change ownership to our non-root user
RUN chown -R flaskuser:flaskuser /app
USER flaskuser
# Run with Gunicorn (replaces uwsgi)
CMD ["gunicorn", "--bind", "0.0.0.0:5000", "app:app", "--workers", "4"]