Spaces:
Sleeping
Sleeping
File size: 795 Bytes
101a62c 7c361ed 101a62c 69c60b3 7c361ed 69c60b3 7c361ed 69c60b3 101a62c 7c361ed 69c60b3 7c361ed 101a62c bf8f81a 101a62c 69c60b3 bf8f81a 101a62c 69c60b3 101a62c 41e824d | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | # Use a stable Python version
FROM python:3.12-slim
# 1. Create nonroot user
RUN adduser --uid 1234 nonroot
RUN python -m venv /venv
ENV PATH="/venv/bin:$PATH"
COPY requirements.txt /tmp/requirements.txt
# Upgrade pip and install requirements
RUN pip install --upgrade pip && \
pip install -r /tmp/requirements.txt
COPY src /src
WORKDIR /src
# 2. Run collectstatic with a dummy secret key (Prevents build crashes)
RUN DJANGO_SECRET_KEY=build-only-key python manage.py collectstatic --noinput
# 3. Transfer ownership to nonroot
RUN chown -R nonroot:nonroot /src
RUN chown -R nonroot:nonroot /venv
ENV DJANGO_DEBUG_FALSE=1
# 4. Switch user
USER nonroot
# Run migration and start server
CMD ["sh", "-c", "python manage.py migrate && gunicorn --bind :7860 superlists.wsgi:application"]
|