Skip to content

Instantly share code, notes, and snippets.

@jkeam
Last active April 19, 2024 04:18
Show Gist options
  • Save jkeam/c933b916b1551084a571868ff78b2c1e to your computer and use it in GitHub Desktop.
Save jkeam/c933b916b1551084a571868ff78b2c1e to your computer and use it in GitHub Desktop.
Dockerfile for Cookiecutter Django
FROM registry.access.redhat.com/ubi9/python-311:1-52.1712567218
# Build args mainly for asset compilation
ARG DJANGO_SECRET_KEY
ARG REDIS_URL
ARG DJANGO_ADMIN_URL
ARG SPARKPOST_API_KEY
ARG CARE_OFFICE_PASSWORD
ARG DJANGO_AWS_ACCESS_KEY_ID
ARG DJANGO_AWS_SECRET_ACCESS_KEY
ARG DJANGO_AWS_STORAGE_BUCKET_NAME
ARG DJANGO_AWS_S3_REGION_NAME
# Python settings and django
ENV PYTHONDONTWRITEBYTECODE 1
ENV DJANGO_SETTINGS_MODULE 'config.settings.production'
# Add application sources with correct permissions for OpenShift
USER 0
ADD . .
RUN chown -R 1001:0 ./
USER 1001
# Install the dependencies
RUN pip install -U "pip>=19.3.1" && \
pip install -r ./requirements/production.txt
# Prep for server
RUN python ./manage.py collectstatic --noinput && python ./manage.py compilemessages
# Port for app
EXPOSE 8000
# Run the application
CMD ["/opt/app-root/bin/gunicorn", "config.wsgi", "--bind", "0.0.0.0:8000"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment