From 169dc6b1ee536fea1475828f753260d4dc6eb439 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Sat, 17 Feb 2024 18:27:44 +0900 Subject: [PATCH 01/12] Add initial script for image building --- build-image.sh | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100755 build-image.sh diff --git a/build-image.sh b/build-image.sh new file mode 100755 index 00000000..acfb789a --- /dev/null +++ b/build-image.sh @@ -0,0 +1,14 @@ +#!/bin/sh + +if [ $# -lt 1 ]; then + echo "$0 imageversion [push]" + echo "If push is specified, also push to our harbor" + exit 1 +fi + +tagprefix=harbor.k8s.ungleich.ch/ungleich-public/dynamicweb +version=$1; shift + +tag=${tagprefix}:${version} + +docker build -t "${tag}" . From bd4d81c286d833d97a15750d3145c53344133eb0 Mon Sep 17 00:00:00 2001 From: "app@dynamicweb-production" Date: Sat, 17 Feb 2024 11:20:12 +0100 Subject: [PATCH 02/12] Show virtual machine plan page for admin --- hosting/views.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/hosting/views.py b/hosting/views.py index 3ac8c023..ce59b0d9 100644 --- a/hosting/views.py +++ b/hosting/views.py @@ -1544,7 +1544,12 @@ class VirtualMachinesPlanListView(LoginRequiredMixin, ListView): ordering = '-id' def get_queryset(self): - owner = self.request.user + username = self.request.GET.get('username') + if self.request.user.is_admin and username: + user = CustomUser.objects.get(username=username) + else: + user = self.request.user + owner = user manager = OpenNebulaManager(email=owner.username, password=owner.password) try: From 4eb470df1632ff055eac6b2a5f1f02b4df618d2e Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Sat, 17 Feb 2024 20:48:17 +0900 Subject: [PATCH 03/12] [docker] switch to python 3.5 --- Dockerfile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 50b81cbb..d12c54ff 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,5 @@ -FROM python:3.10.0-alpine3.15 +# FROM python:3.10.0-alpine3.15 +FROM python:3.5-alpine3.12 WORKDIR /usr/src/app From 0d7f10776c3c0ec0b4b1aaa82a07bddf45169071 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Sat, 17 Feb 2024 20:49:31 +0900 Subject: [PATCH 04/12] [docker] push if build is ok --- build-image.sh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/build-image.sh b/build-image.sh index acfb789a..0ac898ed 100755 --- a/build-image.sh +++ b/build-image.sh @@ -2,6 +2,7 @@ if [ $# -lt 1 ]; then echo "$0 imageversion [push]" + echo "Version could be: $(git describe --always)" echo "If push is specified, also push to our harbor" exit 1 fi @@ -11,4 +12,7 @@ version=$1; shift tag=${tagprefix}:${version} +set -ex + docker build -t "${tag}" . +docker push "${tag}" From f178be8395a95e5023756e2824efbadac2b44216 Mon Sep 17 00:00:00 2001 From: PCoder Date: Mon, 19 Feb 2024 20:42:34 +0530 Subject: [PATCH 05/12] Update .dockerignore: ignore .env --- .dockerignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.dockerignore b/.dockerignore index 6b8710a7..a715c9d7 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1 +1,2 @@ .git +.env From 893c8168469382426d59b93606baf2e1e6dc4520 Mon Sep 17 00:00:00 2001 From: PCoder Date: Mon, 19 Feb 2024 20:43:33 +0530 Subject: [PATCH 06/12] Add apks required for the build on alpine 3.12 --- Dockerfile | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index d12c54ff..bee11218 100644 --- a/Dockerfile +++ b/Dockerfile @@ -8,7 +8,12 @@ RUN apk add --update --no-cache \ build-base \ openldap-dev \ python3-dev \ - libpq-dev \ + postgresql-dev \ + jpeg-dev \ + libxml2-dev \ + libxslt-dev \ + libmemcached-dev \ + zlib-dev \ && rm -rf /var/cache/apk/* # FIX https://github.com/python-ldap/python-ldap/issues/432 From b6ff2b62c1da90a8a4c5bfebe10f6edb573d57fa Mon Sep 17 00:00:00 2001 From: PCoder Date: Mon, 19 Feb 2024 20:44:17 +0530 Subject: [PATCH 07/12] Add comment for alpine 3.14 requirement --- Dockerfile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Dockerfile b/Dockerfile index bee11218..7b5440af 100644 --- a/Dockerfile +++ b/Dockerfile @@ -16,6 +16,8 @@ RUN apk add --update --no-cache \ zlib-dev \ && rm -rf /var/cache/apk/* +## For alpine 3.15 replace postgresql-dev with libpq-dev + # FIX https://github.com/python-ldap/python-ldap/issues/432 RUN echo 'INPUT ( libldap.so )' > /usr/lib/libldap_r.so From 8d13629c8b775c63cc8dd8fda7412c36fd09aefa Mon Sep 17 00:00:00 2001 From: PCoder Date: Mon, 19 Feb 2024 20:49:29 +0530 Subject: [PATCH 08/12] Use proper library path for Pillow --- Dockerfile | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 7b5440af..395ebcc9 100644 --- a/Dockerfile +++ b/Dockerfile @@ -22,5 +22,8 @@ RUN apk add --update --no-cache \ RUN echo 'INPUT ( libldap.so )' > /usr/lib/libldap_r.so COPY requirements.txt ./ -RUN pip install --no-cache-dir -r requirements.txt + +# Pillow seems to need LIBRARY_PATH set as follows: (see: https://github.com/python-pillow/Pillow/issues/1763#issuecomment-222383534) +RUN LIBRARY_PATH=/lib:/usr/lib /bin/sh -c "pip install --no-cache-dir -r requirements.txt" + COPY ./ . From 9e98125b13e400d0c083589b252527872fa58a56 Mon Sep 17 00:00:00 2001 From: PCoder Date: Mon, 19 Feb 2024 20:50:10 +0530 Subject: [PATCH 09/12] Use the same django-filer version being used on production --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 8d04a189..73cdf987 100644 --- a/requirements.txt +++ b/requirements.txt @@ -25,7 +25,7 @@ django-compressor==2.0 django-debug-toolbar==1.4 python-dotenv==0.10.3 django-extensions==1.6.7 -django-filer==2.1.2 +django-filer==1.2.0 django-filter==0.13.0 django-formtools==1.0 django-guardian==1.4.4 From 26f3a1881decdcc98c0ae9add4a627af0833a4b7 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Tue, 20 Feb 2024 16:25:13 +0900 Subject: [PATCH 10/12] make build image only push if push is specified --- build-image.sh | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/build-image.sh b/build-image.sh index 0ac898ed..64a67fd6 100755 --- a/build-image.sh +++ b/build-image.sh @@ -15,4 +15,9 @@ tag=${tagprefix}:${version} set -ex docker build -t "${tag}" . -docker push "${tag}" + +push=$1; shift + +if [ "$push" ]; then + docker push "${tag}" +fi From 8b06c2c6e9b599ce887f8e26f451878511ba3557 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Tue, 20 Feb 2024 17:18:29 +0900 Subject: [PATCH 11/12] docker: add entrypoint and add support for dynamic config --- Dockerfile | 3 +++ dynamicweb/settings/base.py | 6 ++++++ entrypoint.sh | 19 +++++++++++++++++++ 3 files changed, 28 insertions(+) create mode 100644 entrypoint.sh diff --git a/Dockerfile b/Dockerfile index 395ebcc9..4c1a9a66 100644 --- a/Dockerfile +++ b/Dockerfile @@ -27,3 +27,6 @@ COPY requirements.txt ./ RUN LIBRARY_PATH=/lib:/usr/lib /bin/sh -c "pip install --no-cache-dir -r requirements.txt" COPY ./ . +COPY entrypoint.sh / + +ENTRYPOINT ["/entrypoint.sh" ] diff --git a/dynamicweb/settings/base.py b/dynamicweb/settings/base.py index f03042dc..b7705e17 100644 --- a/dynamicweb/settings/base.py +++ b/dynamicweb/settings/base.py @@ -777,3 +777,9 @@ if DEBUG: from .local import * # flake8: noqa else: from .prod import * # flake8: noqa + +# Try to load dynamic configuration, if it exists +try: + from .dynamic import * # flake8: noqa +except ImportError: + pass diff --git a/entrypoint.sh b/entrypoint.sh new file mode 100644 index 00000000..e207a457 --- /dev/null +++ b/entrypoint.sh @@ -0,0 +1,19 @@ +#!/bin/sh + +set -uex + +cd /usr/src/app/ +cat > dynamicweb/settings/dynamic.py < Date: Tue, 20 Feb 2024 17:19:05 +0900 Subject: [PATCH 12/12] entrypoint: make executable --- entrypoint.sh | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 entrypoint.sh diff --git a/entrypoint.sh b/entrypoint.sh old mode 100644 new mode 100755