API-Manager/Dockerfile
Marko Milić edde7e05bb Fixed "python image runs with root as the default user"
Added non-root user creation** (`appuser` with UID/GID 1000) - **Set
proper file ownership** for all application directories - **Switched
container execution** to non-root user with `USER appuser` - **Fixed
permission issues** for static files directory
2025-11-14 12:55:08 +01:00

22 lines
688 B
Docker

FROM python:3.10
# Create non-root user
RUN groupadd --gid 1000 appuser \
&& useradd --uid 1000 --gid appuser --shell /bin/bash --create-home appuser
COPY requirements.txt /app/
COPY apimanager/ /app/apimanager/
COPY static/ /app/static/
COPY gunicorn.conf.py /app/gunicorn.conf.py
COPY .github/local_settings_container.py /app/apimanager/apimanager/local_settings.py
RUN pip install -r /app/requirements.txt
WORKDIR /app
RUN ./apimanager/manage.py migrate
# Set proper ownership and switch to non-root user
RUN chown -R appuser:appuser /app
USER appuser
WORKDIR /app/apimanager
EXPOSE 8000
CMD ["gunicorn", "--bind", ":8000", "--config", "../gunicorn.conf.py", "apimanager.wsgi"]