From c129737aa08e70a45a65a06a9f002d833ef7fcf8 Mon Sep 17 00:00:00 2001 From: Matthew Lemon Date: Wed, 24 Apr 2024 11:55:15 +0100 Subject: New Dockerfile using RedHat image --- .dockerignore | 8 ++++++++ Dockerfile | 40 +++++++++++++++------------------------- ded/settings.py | 6 +++--- ded/urls.py | 2 +- requirements.txt | 6 +++--- requirements_dev.txt | 14 +++++++------- 6 files changed, 37 insertions(+), 39 deletions(-) create mode 100644 .dockerignore diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..9eecfed --- /dev/null +++ b/.dockerignore @@ -0,0 +1,8 @@ +.git +.gitignore +Dockerfile +.dockerignore +.venv/ +__pycache__/ +*.pyc +*.pyo \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 278656e..15b1b2b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,30 +1,20 @@ -# Pull base image -FROM python:3.12-alpine +FROM registry.access.redhat.com/ubi9/python-311:1-52.1712567218 -WORKDIR /app - -RUN apk add --no-cache \ - build-base \ - curl \ - && adduser -D python \ - && mkdir -p /app \ - && chown python:python /app - -USER python +# Add application sources with correct permissions for OpenShift +USER 0 +COPY . /app +RUN mkdir -p /app/static/css /app/static/js /app/static/img +RUN chown -R 1001:0 /app +USER 1001 -COPY --chown=python:python requirements*.txt ./ - -RUN pip install -r requirements.txt \ - && pip install -r requirements_dev.txt - -COPY --chown=python:python . . +WORKDIR /app -ENV DEBUG="${DEBUG}" \ - PYTHONUNBUFFERED="true" \ - PATH="${PATH}:/home/python/.local/bin" \ - USER="python" -# Collect static files -RUN SECRET_KEY=nothing python manage.py collectstatic --no-input +# Install the dependencies +RUN pip install -U "pip>=19.3.1" && \ + pip install -r requirements.txt && \ + python manage.py collectstatic --noinput && \ + python manage.py migrate -CMD ["python", "manage.py", "runserver", "0.0.0.0:8000"] +# Run the application +CMD python manage.py runserver 0.0.0.0:8080 \ No newline at end of file diff --git a/ded/settings.py b/ded/settings.py index 1b48377..4f22008 100644 --- a/ded/settings.py +++ b/ded/settings.py @@ -43,7 +43,7 @@ INSTALLED_APPS = [ "django.contrib.staticfiles", "crispy_forms", "django_htmx", - "debug_toolbar", + # "debug_toolbar", ] @@ -52,11 +52,11 @@ INTERNAL_IPS = ["127.0.0.1", "localhost"] # DEBUG_TOOLBAR_PANELS = ["debug_toolbar.panels.request.RequestPanel"] -SHOW_TOOLBAR_CALLBACK = "debug_toolbar.middleware.show_toolbar" +# SHOW_TOOLBAR_CALLBACK = "debug_toolbar.middleware.show_toolbar" MIDDLEWARE = [ "django.middleware.security.SecurityMiddleware", - "debug_toolbar.middleware.DebugToolbarMiddleware", + # "debug_toolbar.middleware.DebugToolbarMiddleware", "django.contrib.sessions.middleware.SessionMiddleware", "django.middleware.common.CommonMiddleware", "django.middleware.csrf.CsrfViewMiddleware", diff --git a/ded/urls.py b/ded/urls.py index 9ee8110..229fb29 100644 --- a/ded/urls.py +++ b/ded/urls.py @@ -17,7 +17,7 @@ from django.contrib import admin from django.urls import include, path urlpatterns = [ - path("__debug__", include("debug_toolbar.urls")), + # path("__debug__", include("debug_toolbar.urls")), path("accounts/", include("django.contrib.auth.urls")), path("engagements/", include("engagements.urls")), path("admin/", admin.site.urls), diff --git a/requirements.txt b/requirements.txt index b8172c2..1aeb141 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,5 +1,5 @@ -Django>=5.0.4,<5.1 +Django>=4.2.11,<5.0.0 django-crispy-forms -django-extensions -faker>=13.14.0,<14.0.0 +#django-extensions +#faker>=13.14.0,<14.0.0 django-htmx==1.17.3 diff --git a/requirements_dev.txt b/requirements_dev.txt index 8f7b34c..f7d79f4 100644 --- a/requirements_dev.txt +++ b/requirements_dev.txt @@ -1,7 +1,7 @@ -pdbpp -pre-commit -isort -black -flake8 -requests -django-debug-toolbar==3.7 +# pdbpp +# pre-commit +# isort +# black +# flake8 +# requests +# django-debug-toolbar -- cgit v1.2.3