From 2acb47c516da9589f28e611699fea363f1495db2 Mon Sep 17 00:00:00 2001 From: Alexandre Iooss Date: Tue, 1 Sep 2020 11:23:56 +0200 Subject: [PATCH 01/15] Base docker on Debian Buster --- Dockerfile | 22 ++++++++++++++-------- ansible/roles/1-apt-basic/tasks/main.yml | 2 ++ 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/Dockerfile b/Dockerfile index 60acc6e3..b26d5fe4 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,20 +1,26 @@ -FROM python:3-alpine +FROM debian:buster +# Force the stdout and stderr streams to be unbuffered ENV PYTHONUNBUFFERED 1 -# Install LaTeX requirements -RUN apk add --no-cache gettext texlive texmf-dist-latexextra texmf-dist-fontsextra nginx gcc libc-dev libffi-dev postgresql-dev libxml2-dev libxslt-dev jpeg-dev +# Install APT requirements +RUN apt-get update && \ + apt-get install -y nginx python3 python3-pip python3-dev \ + uwsgi uwsgi-plugin-python3 python3-venv git acl gettext \ + libjs-bootstrap4 fonts-font-awesome \ + texlive-latex-extra texlive-fonts-extra texlive-lang-french && \ + rm -rf /var/lib/apt/lists/* -RUN apk add --no-cache bash - -RUN mkdir /code -WORKDIR /code +# Instal PyPI requirements COPY requirements /code/requirements -RUN pip install gunicorn ptpython --no-cache-dir RUN pip install -r requirements/base.txt -r requirements/cas.txt -r requirements/production.txt --no-cache-dir +# Copy code +WORKDIR /code COPY . /code/ +#RUN pip install gunicorn ptpython --no-cache-dir + # Configure nginx RUN mkdir /run/nginx RUN ln -sf /dev/stdout /var/log/nginx/access.log && ln -sf /dev/stderr /var/log/nginx/error.log diff --git a/ansible/roles/1-apt-basic/tasks/main.yml b/ansible/roles/1-apt-basic/tasks/main.yml index eba6e5c3..105fbf36 100644 --- a/ansible/roles/1-apt-basic/tasks/main.yml +++ b/ansible/roles/1-apt-basic/tasks/main.yml @@ -13,6 +13,8 @@ - git - acl - gettext + - libjs-bootstrap4 + - fonts-font-awesome - texlive-latex-extra - texlive-fonts-extra - texlive-lang-french From 09853ce990e80f47476f5dca7ec7eec92d149164 Mon Sep 17 00:00:00 2001 From: Alexandre Iooss Date: Tue, 1 Sep 2020 12:09:02 +0200 Subject: [PATCH 02/15] Use debian deps in Dockerfile --- Dockerfile | 19 +++++++++++-------- requirements.txt | 7 +++++++ requirements/base.txt | 31 ------------------------------- requirements/cas.txt | 1 - requirements/production.txt | 1 - 5 files changed, 18 insertions(+), 41 deletions(-) create mode 100644 requirements.txt delete mode 100644 requirements/base.txt delete mode 100644 requirements/cas.txt delete mode 100644 requirements/production.txt diff --git a/Dockerfile b/Dockerfile index b26d5fe4..bcec728c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,19 +1,22 @@ -FROM debian:buster +FROM debian:buster-backports # Force the stdout and stderr streams to be unbuffered ENV PYTHONUNBUFFERED 1 -# Install APT requirements +# Install Django, external apps, LaTeX and dependencies +# Outside Docker, you may also need git, acl, python3-venv, uwsgi, uwsgi-plugin-python3, nginx RUN apt-get update && \ - apt-get install -y nginx python3 python3-pip python3-dev \ - uwsgi uwsgi-plugin-python3 python3-venv git acl gettext \ - libjs-bootstrap4 fonts-font-awesome \ - texlive-latex-extra texlive-fonts-extra texlive-lang-french && \ + apt-get install -t buster-backports -y python3-django python3-django-crispy-forms \ + python3-django-extensions python3-django-filters python3-django-polymorphic \ + python3-djangorestframework python3-django-cas-server python3-psycopg2 python3-pil \ + python3-babel python3-lockfile python3-pip \ + texlive-latex-extra texlive-fonts-extra texlive-lang-french \ + gettext libjs-bootstrap4 fonts-font-awesome && \ rm -rf /var/lib/apt/lists/* # Instal PyPI requirements -COPY requirements /code/requirements -RUN pip install -r requirements/base.txt -r requirements/cas.txt -r requirements/production.txt --no-cache-dir +COPY requirements.txt /code/ +RUN pip3 install -r /code/requirements.txt --no-cache-dir # Copy code WORKDIR /code diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 00000000..ac2104e2 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,7 @@ +django-htcpcp-tea==0.3.1 +django-mailer==2.0.1 +django-phonenumber-field==4.0.0 +django-tables2==2.1.0 +django-rest-polymorphic==0.1.8 +django-bootstrap-datepicker-plus==3.0.5 +django-colorfield==0.3.2 diff --git a/requirements/base.txt b/requirements/base.txt deleted file mode 100644 index ba380f73..00000000 --- a/requirements/base.txt +++ /dev/null @@ -1,31 +0,0 @@ -beautifulsoup4==4.9.1 -certifi==2019.6.16 -chardet==3.0.4 -defusedxml==0.6.0 -Django~=2.2 -django-allauth==0.39.1 -django-crispy-forms==1.7.2 -django-extensions==2.1.9 -django-filter==2.2.0 -django-htcpcp-tea==0.3.1 -django-mailer==2.0.1 -django-phonenumber-field==4.0.0 -django-polymorphic==2.0.3 -django-tables2==2.1.0 -docutils==0.14 -idna==2.8 -lxml==4.5.2 -oauthlib==3.1.0 -phonenumbers==8.12.7 -Pillow==7.1.2 -python3-openid==3.1.0 -pytz==2019.1 -requests==2.22.0 -requests-oauthlib==1.2.0 -six==1.12.0 -sqlparse==0.3.0 -djangorestframework==3.9.0 -django-rest-polymorphic==0.1.8 -urllib3==1.25.3 -django-bootstrap-datepicker-plus==3.0.5 -django-colorfield==0.3.2 diff --git a/requirements/cas.txt b/requirements/cas.txt deleted file mode 100644 index 8a0baa85..00000000 --- a/requirements/cas.txt +++ /dev/null @@ -1 +0,0 @@ -django-cas-server==1.2.0 diff --git a/requirements/production.txt b/requirements/production.txt deleted file mode 100644 index fe939cce..00000000 --- a/requirements/production.txt +++ /dev/null @@ -1 +0,0 @@ -psycopg2-binary==2.8.4 From bf7b18704834a96f187c5ca6b493cf16b85f4f1c Mon Sep 17 00:00:00 2001 From: Alexandre Iooss Date: Tue, 1 Sep 2020 13:52:28 +0200 Subject: [PATCH 03/15] Working docker devserver --- Dockerfile | 16 +++------------- entrypoint.sh | 24 ++++++++++++++++-------- 2 files changed, 19 insertions(+), 21 deletions(-) diff --git a/Dockerfile b/Dockerfile index bcec728c..f74cf170 100644 --- a/Dockerfile +++ b/Dockerfile @@ -4,12 +4,12 @@ FROM debian:buster-backports ENV PYTHONUNBUFFERED 1 # Install Django, external apps, LaTeX and dependencies -# Outside Docker, you may also need git, acl, python3-venv, uwsgi, uwsgi-plugin-python3, nginx RUN apt-get update && \ apt-get install -t buster-backports -y python3-django python3-django-crispy-forms \ python3-django-extensions python3-django-filters python3-django-polymorphic \ python3-djangorestframework python3-django-cas-server python3-psycopg2 python3-pil \ - python3-babel python3-lockfile python3-pip \ + python3-babel python3-lockfile python3-pip python3-phonenumbers ipython3 \ + uwsgi uwsgi-plugin-python3 \ texlive-latex-extra texlive-fonts-extra texlive-lang-french \ gettext libjs-bootstrap4 fonts-font-awesome && \ rm -rf /var/lib/apt/lists/* @@ -22,15 +22,5 @@ RUN pip3 install -r /code/requirements.txt --no-cache-dir WORKDIR /code COPY . /code/ -#RUN pip install gunicorn ptpython --no-cache-dir - -# Configure nginx -RUN mkdir /run/nginx -RUN ln -sf /dev/stdout /var/log/nginx/access.log && ln -sf /dev/stderr /var/log/nginx/error.log -RUN ln -sf /code/nginx_note.conf_docker /etc/nginx/conf.d/nginx_note.conf -RUN rm /etc/nginx/conf.d/default.conf - +EXPOSE 8080 ENTRYPOINT ["/code/entrypoint.sh"] -EXPOSE 80 - -CMD ["./manage.py", "shell_plus", "--ptpython"] diff --git a/entrypoint.sh b/entrypoint.sh index 09cbc3c8..f677b496 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -11,14 +11,22 @@ else sed -i -e "s/REPLACEME/La Note Kfet \\\\ud83c\\\\udf7b/g" /code/note_kfet/fixtures/cas.json fi -python manage.py compilemessages -python manage.py makemigrations -python manage.py migrate +# Set up Django project +python3 manage.py collectstatic --noinput +python3 manage.py compilemessages +python3 manage.py makemigrations +python3 manage.py migrate -nginx - -if [ "$DJANGO_APP_STAGE" = "prod" ]; then - gunicorn -b 0.0.0.0:8000 --workers=2 --threads=4 --worker-class=gthread note_kfet.wsgi --access-logfile '-' --error-logfile '-'; +if [ "$1" ]; then + # Command passed + echo "Running $@..." + $@ else - python manage.py runserver 0.0.0.0:8000; + # Launch server + if [ "$DJANGO_APP_STAGE" = "prod" ]; then + # FIXME: serve static files + uwsgi --http 0.0.0.0:8080 --master --module note_kfet.wsgi --processes 4 + else + python3 manage.py runserver 0.0.0.0:8080; + fi fi From 55be6be6c52556a7c2d9463ddd8b06434246271f Mon Sep 17 00:00:00 2001 From: Alexandre Iooss Date: Tue, 1 Sep 2020 14:03:06 +0200 Subject: [PATCH 04/15] Docker instruction before Docker compose --- Dockerfile | 10 +++++----- README.md | 50 ++++++++++++++++++++++++++++++++------------------ 2 files changed, 37 insertions(+), 23 deletions(-) diff --git a/Dockerfile b/Dockerfile index f74cf170..ef2531a0 100644 --- a/Dockerfile +++ b/Dockerfile @@ -15,12 +15,12 @@ RUN apt-get update && \ rm -rf /var/lib/apt/lists/* # Instal PyPI requirements -COPY requirements.txt /code/ -RUN pip3 install -r /code/requirements.txt --no-cache-dir +COPY requirements.txt /var/www/note_kfet/ +RUN pip3 install -r /var/www/note_kfet/requirements.txt --no-cache-dir # Copy code -WORKDIR /code -COPY . /code/ +WORKDIR /var/www/note_kfet +COPY . /var/www/note_kfet/ EXPOSE 8080 -ENTRYPOINT ["/code/entrypoint.sh"] +ENTRYPOINT ["/var/www/note_kfet/entrypoint.sh"] diff --git a/README.md b/README.md index 7087b120..246601a0 100644 --- a/README.md +++ b/README.md @@ -144,30 +144,44 @@ Sinon vous pouvez suivre les étapes ici. Il est possible de travailler sur une instance Docker. -1. Cloner le dépôt là où vous voulez : +Pour construire l'image Docker `nk20`, - $ git clone git@gitlab.crans.org:bde/nk20.git +``` +git clone https://gitlab.crans.org/bde/nk20/ && cd nk20 +docker build . -t nk20 +``` -2. Copiez le fichier `.env_example` à la racine du projet vers le fichier `.env`, - et mettez à jour vos variables d'environnement +Ensuite pour lancer la note Kfet en tant que vous (option `-u`), +l'exposer sur son port 80 (option `-p`) et monter le code en écriture (option `-v`), -3. Dans le fichier `docker_compose.yml`, qu'on suppose déjà configuré, - ajouter les lignes suivantes, en les adaptant à la configuration voulue : +``` +docker run -it --rm -u $(id -u):$(id -g) -v "$(pwd):/var/www/note_kfet/" -p 80:8080 nk20 +``` - nk20: - build: /chemin/vers/nk20 - volumes: - - /chemin/vers/nk20:/code/ - env_file: /chemin/vers/nk20/.env - restart: always - labels: - - traefik.domain=ndd.example.com - - traefik.frontend.rule=Host:ndd.example.com - - traefik.port=8000 +Si vous souhaitez lancer une commande spéciale, vous pouvez l'ajouter à la fin, par exemple, -4. Enjoy : +``` +docker run -it --rm -u $(id -u):$(id -g) -v "$(pwd):/var/www/note_kfet/" -p 80:8080 nk20 python3 ./manage.py createsuperuser +``` - $ docker-compose up -d nk20 +#### Avec Docker Compose + +On vous conseilles de faire un fichier d'environnement `.env` en prenant exemple sur `.env_example`. + +Pour par exemple utiliser le Docker de la note Kfet avec Traefik pour réaliser le HTTPS, + +```YAML +nk20: + build: /chemin/vers/le/code/nk20 + volumes: + - /chemin/vers/le/code/nk20:/var/www/note_kfet/ + env_file: /chemin/vers/le/code/nk20/.env + restart: always + labels: + - traefik.domain=ndd.example.com + - traefik.frontend.rule=Host:ndd.example.com + - traefik.port=8080 +``` ### Lancer un serveur de développement From bfd08fec096fff78048f7df022c022b409aa4b94 Mon Sep 17 00:00:00 2001 From: Alexandre Iooss Date: Tue, 1 Sep 2020 14:16:18 +0200 Subject: [PATCH 05/15] Working Docker production env --- entrypoint.sh | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/entrypoint.sh b/entrypoint.sh index f677b496..ab33fbe8 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -5,10 +5,10 @@ if [ -z ${NOTE_URL+x} ]; then echo "Warning: your env files are not configurated." else - sed -i -e "s/example.com/$DOMAIN/g" /code/apps/member/fixtures/initial.json - sed -i -e "s/localhost/$NOTE_URL/g" /code/note_kfet/fixtures/initial.json - sed -i -e "s/\"\.\*\"/\"https?:\/\/$NOTE_URL\/.*\"/g" /code/note_kfet/fixtures/cas.json - sed -i -e "s/REPLACEME/La Note Kfet \\\\ud83c\\\\udf7b/g" /code/note_kfet/fixtures/cas.json + sed -i -e "s/example.com/$DOMAIN/g" /var/www/note_kfet/apps/member/fixtures/initial.json + sed -i -e "s/localhost/$NOTE_URL/g" /var/www/note_kfet/note_kfet/fixtures/initial.json + sed -i -e "s/\"\.\*\"/\"https?:\/\/$NOTE_URL\/.*\"/g" /var/www/note_kfet/note_kfet/fixtures/cas.json + sed -i -e "s/REPLACEME/La Note Kfet \\\\ud83c\\\\udf7b/g" /var/www/note_kfet/note_kfet/fixtures/cas.json fi # Set up Django project @@ -24,8 +24,9 @@ if [ "$1" ]; then else # Launch server if [ "$DJANGO_APP_STAGE" = "prod" ]; then - # FIXME: serve static files - uwsgi --http 0.0.0.0:8080 --master --module note_kfet.wsgi --processes 4 + uwsgi --http-socket 0.0.0.0:8080 --master --plugins python3 \ + --module note_kfet.wsgi:application --env DJANGO_SETTINGS_MODULE=note_kfet.settings \ + --processes 4 --static-map /static=/var/www/note_kfet/static --harakiri=20 --max-requests=5000 --vacuum else python3 manage.py runserver 0.0.0.0:8080; fi From 6de46a9264ea83f62017aa760eb1d2ae18093e84 Mon Sep 17 00:00:00 2001 From: Alexandre Iooss Date: Tue, 1 Sep 2020 14:19:24 +0200 Subject: [PATCH 06/15] Remove useless nginx/uwsgi config --- .../roles/4-nginx/templates/nginx_note.conf | 2 +- nginx_note.conf_docker | 27 ------------------- uwsgi_params | 26 ------------------ 3 files changed, 1 insertion(+), 54 deletions(-) delete mode 100644 nginx_note.conf_docker delete mode 100644 uwsgi_params diff --git a/ansible/roles/4-nginx/templates/nginx_note.conf b/ansible/roles/4-nginx/templates/nginx_note.conf index 9be2d980..b195e739 100644 --- a/ansible/roles/4-nginx/templates/nginx_note.conf +++ b/ansible/roles/4-nginx/templates/nginx_note.conf @@ -53,7 +53,7 @@ server { # Finally, send all non-media requests to the Django server. location / { uwsgi_pass note; - include /var/www/note_kfet/uwsgi_params; # the uwsgi_params file you installed + include /etc/nginx/uwsgi_params; } ssl_certificate /etc/letsencrypt/live/nk20-beta.crans.org/fullchain.pem; diff --git a/nginx_note.conf_docker b/nginx_note.conf_docker deleted file mode 100644 index 020fe204..00000000 --- a/nginx_note.conf_docker +++ /dev/null @@ -1,27 +0,0 @@ -# This is an example NGINX site configuration for note_kfet in Docker -# Only HTTP, please use a reverse proxy to secure it! - -server { - # Serve this site by default on HTTP - listen 80 default_server; - listen [::]:80 default_server; - - # Max upload size - client_max_body_size 75M; - - # Django statics and media - location /static { - alias /code/static; - } - location /media { - alias /code/media; - } - - # Send all non-media requests to the Django server. - location / { - proxy_pass http://127.0.0.1:8000; - proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; - proxy_set_header Host $host; - proxy_redirect off; - } -} diff --git a/uwsgi_params b/uwsgi_params deleted file mode 100644 index 827deedb..00000000 --- a/uwsgi_params +++ /dev/null @@ -1,26 +0,0 @@ - -uwsgi_param QUERY_STRING $query_string; -uwsgi_param REQUEST_METHOD $request_method; -uwsgi_param CONTENT_TYPE $content_type; -uwsgi_param CONTENT_LENGTH $content_length; - -uwsgi_param REQUEST_URI $request_uri; -uwsgi_param PATH_INFO $document_uri; -uwsgi_param DOCUMENT_ROOT $document_root; -uwsgi_param SERVER_PROTOCOL $server_protocol; -uwsgi_param REQUEST_SCHEME $scheme; -uwsgi_param HTTPS $https if_not_empty; - -uwsgi_param REMOTE_ADDR $remote_addr; -uwsgi_param REMOTE_PORT $remote_port; -uwsgi_param SERVER_PORT $server_port; -uwsgi_param SERVER_NAME $server_name; - - - - - - - - - From b4ef4b8089677841970ab4aed805c045b6c4837d Mon Sep 17 00:00:00 2001 From: Alexandre Iooss Date: Tue, 1 Sep 2020 14:28:11 +0200 Subject: [PATCH 07/15] Use local javascript and css libs --- note_kfet/settings/base.py | 2 ++ note_kfet/templates/base.html | 20 +++++--------------- 2 files changed, 7 insertions(+), 15 deletions(-) diff --git a/note_kfet/settings/base.py b/note_kfet/settings/base.py index 2aa303ed..230bf441 100644 --- a/note_kfet/settings/base.py +++ b/note_kfet/settings/base.py @@ -164,8 +164,10 @@ LANGUAGES = [ STATIC_URL = '/static/' # Add some custom statics from /note_kfet/static +# Because we are using Debian, also include /usr/share/javascript STATICFILES_DIRS = [ os.path.join(BASE_DIR, 'note_kfet/static'), + '/usr/share/javascript', ] # Collect statics to /static/ diff --git a/note_kfet/templates/base.html b/note_kfet/templates/base.html index df38eac9..13d0623f 100644 --- a/note_kfet/templates/base.html +++ b/note_kfet/templates/base.html @@ -24,24 +24,14 @@ SPDX-License-Identifier: GPL-3.0-or-later {# Bootstrap, Font Awesome and custom CSS #} - - - + + {# JQuery, Bootstrap and Turbolinks JavaScript #} - - - + + + From 5feb23ad51007f3f019addf80fe265fb0a004fd3 Mon Sep 17 00:00:00 2001 From: Alexandre Iooss Date: Tue, 1 Sep 2020 14:33:38 +0200 Subject: [PATCH 08/15] Use Debian font awesome --- apps/member/templates/member/base.html | 6 ++-- apps/member/templates/member/user_list.html | 2 +- .../templates/permission/all_rights.html | 4 +-- apps/wei/templates/wei/base.html | 6 ++-- note_kfet/templates/base.html | 28 +++++++++---------- 5 files changed, 23 insertions(+), 23 deletions(-) diff --git a/apps/member/templates/member/base.html b/apps/member/templates/member/base.html index bb99595e..e1e9335b 100644 --- a/apps/member/templates/member/base.html +++ b/apps/member/templates/member/base.html @@ -69,11 +69,11 @@ SPDX-License-Identifier: GPL-3.0-or-later {% endif %} {% if can_lock_note %} {% elif can_unlock_note %} {% endif %} @@ -181,4 +181,4 @@ SPDX-License-Identifier: GPL-3.0-or-later }); } -{% endblock %} \ No newline at end of file +{% endblock %} diff --git a/apps/member/templates/member/user_list.html b/apps/member/templates/member/user_list.html index ce0b14a7..a41d7e69 100644 --- a/apps/member/templates/member/user_list.html +++ b/apps/member/templates/member/user_list.html @@ -7,7 +7,7 @@ SPDX-License-Identifier: GPL-3.0-or-later {% block content %} {% if "member.change_profile_registration_valid"|has_perm:user %} - {% trans "Registrations" %} + {% trans "Registrations" %} {% endif %} diff --git a/apps/permission/templates/permission/all_rights.html b/apps/permission/templates/permission/all_rights.html index 107f8f25..69b74714 100644 --- a/apps/permission/templates/permission/all_rights.html +++ b/apps/permission/templates/permission/all_rights.html @@ -13,7 +13,7 @@ SPDX-License-Identifier: GPL-3.0-or-later
- {% trans "Superusers have all rights on everything, to manage the website." %} + {% trans "Superusers have all rights on everything, to manage the website." %}
@@ -116,4 +116,4 @@ SPDX-License-Identifier: GPL-3.0-or-later update(); }); -{% endblock %} \ No newline at end of file +{% endblock %} diff --git a/apps/wei/templates/wei/base.html b/apps/wei/templates/wei/base.html index dd343f8e..a6521bd2 100644 --- a/apps/wei/templates/wei/base.html +++ b/apps/wei/templates/wei/base.html @@ -43,14 +43,14 @@ SPDX-License-Identifier: GPL-3.0-or-later {% with bde_kfet_fee=club.parent_club.membership_fee_paid|add:club.parent_club.parent_club.membership_fee_paid %}
{% trans 'WEI fee (paid students)'|capfirst %}
{{ club.membership_fee_paid|add:bde_kfet_fee|pretty_money }} -
{% endwith %} {% with bde_kfet_fee=club.parent_club.membership_fee_unpaid|add:club.parent_club.parent_club.membership_fee_unpaid %}
{% trans 'WEI fee (unpaid students)'|capfirst %}
{{ club.membership_fee_unpaid|add:bde_kfet_fee|pretty_money }} -
{% endwith %} {% endif %} @@ -106,4 +106,4 @@ SPDX-License-Identifier: GPL-3.0-or-later {% block profile_content %}{% endblock %}
-{% endblock %} \ No newline at end of file +{% endblock %} diff --git a/note_kfet/templates/base.html b/note_kfet/templates/base.html index 13d0623f..3381c78e 100644 --- a/note_kfet/templates/base.html +++ b/note_kfet/templates/base.html @@ -59,54 +59,54 @@ SPDX-License-Identifier: GPL-3.0-or-later {% if "note.transactiontemplate"|not_empty_model_list %} {% endif %} {% if "note.transaction"|not_empty_model_list %} {% endif %} {% if "auth.user"|model_list_length >= 2 %} {% endif %} {% if "member.club"|not_empty_model_list %} {% endif %} {% if "activity.activity"|not_empty_model_list %} {% endif %} {% if "treasury.invoice"|not_empty_model_list %} {% endif %} {% if "wei.weiclub"|not_empty_model_list %} {% endif %} {% if request.user.is_authenticated %} {% endif %} {% if request.user.is_staff and ""|has_perm:user %} {% endif %} @@ -114,16 +114,16 @@ SPDX-License-Identifier: GPL-3.0-or-later {% if request.user.is_authenticated %} @@ -131,14 +131,14 @@ SPDX-License-Identifier: GPL-3.0-or-later {% if request.path != "/registration/signup/" %} {% endif %} {% if request.path != "/accounts/login/" %} {% endif %} From d89f6dcf5cbf3b74ff32ba3cfd3f5dbb117970c5 Mon Sep 17 00:00:00 2001 From: Alexandre Iooss Date: Tue, 1 Sep 2020 14:39:03 +0200 Subject: [PATCH 09/15] Update install instructions --- README.md | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 246601a0..76cc69a3 100644 --- a/README.md +++ b/README.md @@ -14,21 +14,25 @@ Sinon vous pouvez suivre les étapes ici. ### Installation avec Debian/Ubuntu 1. **Installation des dépendances APT.** + On tire les dépendances le plus possible à partir des dépôts de Debian. + On a besoin d'un environnement LaTeX pour générer les factures. ```bash - $ sudo apt install nginx python3 python3-pip python3-dev uwsgi uwsgi-plugin-python3 python3-venv git acl - ``` - - La génération des factures de l'application trésorerie nécessite une installation de LaTeX suffisante, - - ```bash - $ sudo apt install texlive-latex-extra texlive-fonts-extra texlive-lang-french + $ sudo apt update + $ sudo apt install -t buster-backports -y python3-django python3-django-crispy-forms \ + python3-django-extensions python3-django-filters python3-django-polymorphic \ + python3-djangorestframework python3-django-cas-server python3-psycopg2 python3-pil \ + python3-babel python3-lockfile python3-pip python3-phonenumbers ipython3 \ + uwsgi uwsgi-plugin-python3 \ + texlive-latex-extra texlive-fonts-extra texlive-lang-french \ + gettext libjs-bootstrap4 fonts-font-awesome \ + nginx python3-venv git acl ``` 2. **Clonage du dépot** dans `/var/www/note_kfet`, ```bash - $ mkdir -p /var/www/note_kfet && cd /var/www/note_kfet + $ sudo mkdir -p /var/www/note_kfet && cd /var/www/note_kfet $ sudo chown www-data:www-data . $ sudo chmod g+rwx . $ sudo -u www-data git clone git@gitlab.crans.org:bde/nk20.git . @@ -39,8 +43,7 @@ Sinon vous pouvez suivre les étapes ici. ```bash $ python3 -m venv env $ source env/bin/activate - (env)$ pip3 install -r requirements/base.txt - (env)$ pip3 install -r requirements/prod.txt # uniquement en prod, nécessite une base postgres + (env)$ pip3 install -r requirements.txt (env)$ deactivate # sortir de l'environnement ``` @@ -197,7 +200,7 @@ un serveur de développement par exemple sur son ordinateur. $ python3 -m venv venv $ source venv/bin/activate - (env)$ pip install -r requirements/base.txt + (env)$ pip install -r requirements.txt 3. Copier le fichier `.env_example` vers `.env` à la racine du projet et mettre à jour ce qu'il faut From 9b2a8c4f6fd2e4085593e54a99d924b7b937fd41 Mon Sep 17 00:00:00 2001 From: Alexandre Iooss Date: Tue, 1 Sep 2020 14:47:03 +0200 Subject: [PATCH 10/15] Try to fix Gitlab CI --- .gitlab-ci.yml | 14 +++++++++----- tox.ini | 8 ++------ 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 8d28c037..49c83a05 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,24 +1,28 @@ -image: python:3.8 +image: debian:buster-backports stages: - test - quality-assurance before_script: - - pip install tox + # We do not include uwsgi and LaTeX here + - apt-get update && \ + apt-get install -t buster-backports -y python3-django python3-django-crispy-forms \ + python3-django-extensions python3-django-filters python3-django-polymorphic \ + python3-djangorestframework python3-django-cas-server python3-psycopg2 python3-pil \ + python3-babel python3-lockfile python3-pip python3-phonenumbers ipython3 \ + gettext libjs-bootstrap4 fonts-font-awesome tox && \ + rm -rf /var/lib/apt/lists/* py37-django22: - image: python:3.7 stage: test script: tox -e py37-django22 py38-django22: - image: python:3.8 stage: test script: tox -e py38-django22 linters: - image: python:3.8 stage: quality-assurance script: tox -e linters diff --git a/tox.ini b/tox.ini index 14a05064..dd3e4b50 100644 --- a/tox.ini +++ b/tox.ini @@ -13,9 +13,7 @@ skipsdist = True setenv = PYTHONWARNINGS = all deps = - -r{toxinidir}/requirements/base.txt - -r{toxinidir}/requirements/cas.txt - -r{toxinidir}/requirements/production.txt + -r{toxinidir}/requirements.txt coverage commands = ./manage.py makemigrations @@ -24,9 +22,7 @@ commands = [testenv:linters] deps = - -r{toxinidir}/requirements/base.txt - -r{toxinidir}/requirements/cas.txt - -r{toxinidir}/requirements/production.txt + -r{toxinidir}/requirements.txt flake8 flake8-colors flake8-import-order From e3fc79231dbebde0d613cbcaf09dd7d0fd289533 Mon Sep 17 00:00:00 2001 From: Alexandre Iooss Date: Tue, 1 Sep 2020 14:53:11 +0200 Subject: [PATCH 11/15] CI 1 VS erdnaxe 0 --- .gitlab-ci.yml | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 49c83a05..aeceb6e0 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -6,13 +6,14 @@ stages: before_script: # We do not include uwsgi and LaTeX here - - apt-get update && \ - apt-get install -t buster-backports -y python3-django python3-django-crispy-forms \ - python3-django-extensions python3-django-filters python3-django-polymorphic \ - python3-djangorestframework python3-django-cas-server python3-psycopg2 python3-pil \ - python3-babel python3-lockfile python3-pip python3-phonenumbers ipython3 \ - gettext libjs-bootstrap4 fonts-font-awesome tox && \ - rm -rf /var/lib/apt/lists/* + - > + apt-get update && + apt-get install -t buster-backports -y python3-django python3-django-crispy-forms + python3-django-extensions python3-django-filters python3-django-polymorphic + python3-djangorestframework python3-django-cas-server python3-psycopg2 python3-pil + python3-babel python3-lockfile python3-pip python3-phonenumbers ipython3 + gettext libjs-bootstrap4 fonts-font-awesome tox && + rm -rf /var/lib/apt/lists/* py37-django22: stage: test From 27845303b8cd978b92909f006abb914aa051c3e1 Mon Sep 17 00:00:00 2001 From: Alexandre Iooss Date: Tue, 1 Sep 2020 15:13:08 +0200 Subject: [PATCH 12/15] CI 2 VS erdnaxe 0 --- .gitlab-ci.yml | 46 +++++++++++++++++++++++++++++++--------------- 1 file changed, 31 insertions(+), 15 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index aeceb6e0..35c69e01 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,30 +1,46 @@ -image: debian:buster-backports - stages: - test - quality-assurance -before_script: - # We do not include uwsgi and LaTeX here - - > - apt-get update && - apt-get install -t buster-backports -y python3-django python3-django-crispy-forms - python3-django-extensions python3-django-filters python3-django-polymorphic - python3-djangorestframework python3-django-cas-server python3-psycopg2 python3-pil - python3-babel python3-lockfile python3-pip python3-phonenumbers ipython3 - gettext libjs-bootstrap4 fonts-font-awesome tox && - rm -rf /var/lib/apt/lists/* - +# Debian Buster py37-django22: stage: test - script: tox -e py37-django22 + image: debian:buster-backports + before_script: > + apt-get update && + apt-get install -t buster-backports -y python3-django python3-django-crispy-forms + python3-django-extensions python3-django-filters python3-django-polymorphic + python3-djangorestframework python3-django-cas-server python3-psycopg2 python3-pil + python3-babel python3-lockfile python3-pip python3-phonenumbers ipython3 + gettext libjs-bootstrap4 fonts-font-awesome tox && + rm -rf /var/lib/apt/lists/* + script: tox -e py37-django22 +# Ubuntu 20.04 py38-django22: stage: test - script: tox -e py38-django22 + image: ubuntu:20.04 + before_script: > + apt-get update && + apt-get install -y python3-django python3-django-crispy-forms + python3-django-extensions python3-django-filters python3-django-polymorphic + python3-djangorestframework python3-django-cas-server python3-psycopg2 python3-pil + python3-babel python3-lockfile python3-pip python3-phonenumbers ipython3 + gettext libjs-bootstrap4 fonts-font-awesome tox && + rm -rf /var/lib/apt/lists/* + script: tox -e py38-django22 linters: stage: quality-assurance + image: debian:buster-backports + before_script: > + apt-get update && + apt-get install -t buster-backports -y python3-django python3-django-crispy-forms + python3-django-extensions python3-django-filters python3-django-polymorphic + python3-djangorestframework python3-django-cas-server python3-psycopg2 python3-pil + python3-babel python3-lockfile python3-pip python3-phonenumbers ipython3 + gettext libjs-bootstrap4 fonts-font-awesome tox && + rm -rf /var/lib/apt/lists/* script: tox -e linters # Be nice to new contributors, but please use `tox` From 85c9c4b2ba1ee8be6044d06baf197b46b9c9f67d Mon Sep 17 00:00:00 2001 From: Alexandre Iooss Date: Tue, 1 Sep 2020 15:13:25 +0200 Subject: [PATCH 13/15] CI 3 VS erdnaxe 0 --- tox.ini | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tox.ini b/tox.ini index dd3e4b50..a759504a 100644 --- a/tox.ini +++ b/tox.ini @@ -10,8 +10,9 @@ envlist = skipsdist = True [testenv] +sitepackages = True setenv = - PYTHONWARNINGS = all + PYTHONWARNINGS = all deps = -r{toxinidir}/requirements.txt coverage From 739da3a090148d3d33db31d88ea2d53e533f1f90 Mon Sep 17 00:00:00 2001 From: Alexandre Iooss Date: Tue, 1 Sep 2020 15:19:06 +0200 Subject: [PATCH 14/15] CI 4 VS erdnaxe 0 --- .gitlab-ci.yml | 55 ++++++++++++++++++++++++++------------------------ 1 file changed, 29 insertions(+), 26 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 35c69e01..15fb138c 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -6,41 +6,44 @@ stages: py37-django22: stage: test image: debian:buster-backports - before_script: > - apt-get update && - apt-get install -t buster-backports -y python3-django python3-django-crispy-forms - python3-django-extensions python3-django-filters python3-django-polymorphic - python3-djangorestframework python3-django-cas-server python3-psycopg2 python3-pil - python3-babel python3-lockfile python3-pip python3-phonenumbers ipython3 - gettext libjs-bootstrap4 fonts-font-awesome tox && - rm -rf /var/lib/apt/lists/* - script: tox -e py37-django22 + before_script: + - > + apt-get update && + apt-get install -t buster-backports -y python3-django python3-django-crispy-forms + python3-django-extensions python3-django-filters python3-django-polymorphic + python3-djangorestframework python3-django-cas-server python3-psycopg2 python3-pil + python3-babel python3-lockfile python3-pip python3-phonenumbers ipython3 + gettext libjs-bootstrap4 fonts-font-awesome tox && + rm -rf /var/lib/apt/lists/* + script: tox -e py37-django22 # Ubuntu 20.04 py38-django22: stage: test image: ubuntu:20.04 - before_script: > - apt-get update && - apt-get install -y python3-django python3-django-crispy-forms - python3-django-extensions python3-django-filters python3-django-polymorphic - python3-djangorestframework python3-django-cas-server python3-psycopg2 python3-pil - python3-babel python3-lockfile python3-pip python3-phonenumbers ipython3 - gettext libjs-bootstrap4 fonts-font-awesome tox && - rm -rf /var/lib/apt/lists/* - script: tox -e py38-django22 + before_script: + - > + apt-get update && + apt-get install -y python3-django python3-django-crispy-forms + python3-django-extensions python3-django-filters python3-django-polymorphic + python3-djangorestframework python3-django-cas-server python3-psycopg2 python3-pil + python3-babel python3-lockfile python3-pip python3-phonenumbers ipython3 + gettext libjs-bootstrap4 fonts-font-awesome tox && + rm -rf /var/lib/apt/lists/* + script: tox -e py38-django22 linters: stage: quality-assurance image: debian:buster-backports - before_script: > - apt-get update && - apt-get install -t buster-backports -y python3-django python3-django-crispy-forms - python3-django-extensions python3-django-filters python3-django-polymorphic - python3-djangorestframework python3-django-cas-server python3-psycopg2 python3-pil - python3-babel python3-lockfile python3-pip python3-phonenumbers ipython3 - gettext libjs-bootstrap4 fonts-font-awesome tox && - rm -rf /var/lib/apt/lists/* + before_script: + - > + apt-get update && + apt-get install -t buster-backports -y python3-django python3-django-crispy-forms + python3-django-extensions python3-django-filters python3-django-polymorphic + python3-djangorestframework python3-django-cas-server python3-psycopg2 python3-pil + python3-babel python3-lockfile python3-pip python3-phonenumbers ipython3 + gettext libjs-bootstrap4 fonts-font-awesome tox && + rm -rf /var/lib/apt/lists/* script: tox -e linters # Be nice to new contributors, but please use `tox` From aa247c281f3c7d5c3c1309e20285bb46ebb0b923 Mon Sep 17 00:00:00 2001 From: Alexandre Iooss Date: Tue, 1 Sep 2020 15:42:00 +0200 Subject: [PATCH 15/15] Fix tzdata prompt during apt install --- .gitlab-ci.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 15fb138c..f9fde42e 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -22,6 +22,8 @@ py38-django22: stage: test image: ubuntu:20.04 before_script: + # Fix tzdata prompt + - ln -sf /usr/share/zoneinfo/Europe/Paris /etc/localtime && echo Europe/Paris > /etc/timezone - > apt-get update && apt-get install -y python3-django python3-django-crispy-forms