VelogaWhite/Django_Cal_Javascript
0
1# Use a stable Python version2FROM python:3.12-slim3 4# 1. Create nonroot user5RUN adduser --uid 1234 nonroot6 7RUN python -m venv /venv8ENV PATH="/venv/bin:$PATH"9 10COPY requirements.txt /tmp/requirements.txt11# Upgrade pip and install requirements12RUN pip install --upgrade pip && \13 pip install -r /tmp/requirements.txt14 15COPY src /src16WORKDIR /src17 18# 2. Run collectstatic with a dummy secret key (Prevents build crashes)19RUN DJANGO_SECRET_KEY=build-only-key python manage.py collectstatic --noinput20 21# 3. Transfer ownership to nonroot22RUN chown -R nonroot:nonroot /src23RUN chown -R nonroot:nonroot /venv24 25ENV DJANGO_DEBUG_FALSE=126 27# 4. Switch user28USER nonroot29 30# Run migration and start server31CMD ["sh", "-c", "python manage.py migrate && gunicorn --bind :7860 superlists.wsgi:application"]32 