From dbf4b3c55e450273ecd145b2e39d4268f5b1523b Mon Sep 17 00:00:00 2001 From: Maxime Robert Date: Thu, 2 May 2024 14:37:51 +0200 Subject: [PATCH] Deploy starter kit --- .../start_vitamui.yml | 13 ++++++ .../stop_vitamui.yml | 13 ++++++ deployment/ansible-vitamui/frontend_apps.yml | 9 +++++ .../group_vars/all/vitamui_vars.yml | 3 ++ deployment/pki/scripts/generate_certs.sh | 1 + deployment/pki/scripts/generate_certs_dev.sh | 2 + .../templates/index_links.html.j2 | 6 +++ .../reverse/templates/apache/httpd_config | 6 +++ .../templates/nginx/conf.d/upstream.j2 | 10 +++++ .../templates/nginx/conf.d/vhosts.conf.j2 | 22 ++++++++++ ui/pom.xml | 1 + ui/ui-frontend/package.json | 2 +- ui/ui-starter-kit/pom.xml | 40 +++++++++++++++++++ 13 files changed, 127 insertions(+), 1 deletion(-) create mode 100644 ui/ui-starter-kit/pom.xml diff --git a/deployment/ansible-vitamui-exploitation/start_vitamui.yml b/deployment/ansible-vitamui-exploitation/start_vitamui.yml index 72f33b3af2b..179e5429aee 100644 --- a/deployment/ansible-vitamui-exploitation/start_vitamui.yml +++ b/deployment/ansible-vitamui-exploitation/start_vitamui.yml @@ -313,6 +313,19 @@ etat: started tags: frontend_apps +# To prevent creating a new hosts_ui_starter_kit host, we reuse hosts_ui_portal +- hosts: hosts_ui_portal + gather_facts: no + roles: + - service_state + - check_port + vars: + vitamui_struct: + service_name: nginx + port_service: "{{ vitamui.starter_kit.port_service }}" + etat: started + tags: frontend_apps + ### REVERSE - hosts: hosts_vitamui_reverseproxy gather_facts: no diff --git a/deployment/ansible-vitamui-exploitation/stop_vitamui.yml b/deployment/ansible-vitamui-exploitation/stop_vitamui.yml index 68149f71ba2..cc0371c8981 100644 --- a/deployment/ansible-vitamui-exploitation/stop_vitamui.yml +++ b/deployment/ansible-vitamui-exploitation/stop_vitamui.yml @@ -129,6 +129,19 @@ etat: stopped tags: frontend_apps +# To prevent creating a new hosts_ui_starter_kit host, we reuse hosts_ui_portal +- hosts: hosts_ui_portal + gather_facts: no + roles: + - service_state + - check_port + vars: + vitamui_struct: + service_name: nginx + port_service: "{{ vitamui.starter_kit.port_service }}" + etat: stopped + tags: frontend_apps + ## VITAMUI COMPONENTS ### CAS diff --git a/deployment/ansible-vitamui/frontend_apps.yml b/deployment/ansible-vitamui/frontend_apps.yml index 66a22829ff9..82d2ac604ea 100644 --- a/deployment/ansible-vitamui/frontend_apps.yml +++ b/deployment/ansible-vitamui/frontend_apps.yml @@ -70,3 +70,12 @@ - nginx_webapp vars: vitamui_struct: "{{ vitamui.ingest }}" + +# To prevent creating a new hosts_ui_starter_kit host, we reuse hosts_ui_portal +- hosts: hosts_ui_portal + gather_facts: no + any_errors_fatal: true + roles: + - nginx_webapp + vars: + vitamui_struct: "{{ vitamui.starter_kit }}" diff --git a/deployment/environments/group_vars/all/vitamui_vars.yml b/deployment/environments/group_vars/all/vitamui_vars.yml index d8a2ba01faf..5e963d76aee 100755 --- a/deployment/environments/group_vars/all/vitamui_vars.yml +++ b/deployment/environments/group_vars/all/vitamui_vars.yml @@ -83,6 +83,9 @@ vitamui: pastis: vitamui_component: ui-pastis port_service: 9015 + starter_kit: + vitamui_component: ui-starter-kit + port_service: 8004 # Applications api_gateway: diff --git a/deployment/pki/scripts/generate_certs.sh b/deployment/pki/scripts/generate_certs.sh index 8794568eadb..36523e0d135 100755 --- a/deployment/pki/scripts/generate_certs.sh +++ b/deployment/pki/scripts/generate_certs.sh @@ -48,6 +48,7 @@ function generateCerts { generateHostCertAndStorePassphrase ui-archive-search hosts_ui_archive_search generateHostCertAndStorePassphrase ui-collect hosts_ui_collect generateHostCertAndStorePassphrase ui-pastis hosts_ui_pastis + generateHostCertAndStorePassphrase ui-starter-kit hosts_ui_portal #Reverse generateHostCertAndStorePassphrase reverse hosts_vitamui_reverseproxy diff --git a/deployment/pki/scripts/generate_certs_dev.sh b/deployment/pki/scripts/generate_certs_dev.sh index 6b7ef95fea6..b6292eb23fe 100755 --- a/deployment/pki/scripts/generate_certs_dev.sh +++ b/deployment/pki/scripts/generate_certs_dev.sh @@ -52,6 +52,8 @@ function generateCerts { generateHostCertAndStorePassphrase ui-archive-search hosts_ui_archive_search generateHostCertAndStorePassphrase ui-pastis hosts_ui_pastis generateHostCertAndStorePassphrase ui-collect hosts_ui_collect + generateHostCertAndStorePassphrase ui-starter-kit hosts_ui_portal + #Reverse generateHostCertAndStorePassphrase reverse hosts_vitamui_reverseproxy diff --git a/deployment/roles/merge_index_apache/templates/index_links.html.j2 b/deployment/roles/merge_index_apache/templates/index_links.html.j2 index 0d8a4899e6d..4fc22a32fb7 100644 --- a/deployment/roles/merge_index_apache/templates/index_links.html.j2 +++ b/deployment/roles/merge_index_apache/templates/index_links.html.j2 @@ -29,5 +29,11 @@ {% endfor %}

+

+

Starter kit
+
+ Starter kit +
+

diff --git a/deployment/roles/reverse/templates/apache/httpd_config b/deployment/roles/reverse/templates/apache/httpd_config index 900b2d2fa44..2678d32f256 100644 --- a/deployment/roles/reverse/templates/apache/httpd_config +++ b/deployment/roles/reverse/templates/apache/httpd_config @@ -103,4 +103,10 @@ ProxyPassReverse / {{ 'https' if vitamui.portal.secure | default(secure) | bool else 'http' }}://{{ hostvars[host]['ip_service'] }}:{{ vitamui.portal.port_service }}/ {% endfor %} + # STARTER KIT (To prevent creating a new hosts_ui_starter_kit host, we reuse hosts_ui_portal) +{% for host in groups['hosts_ui_portal'] %} + ProxyPass / {{ 'https' if vitamui.starter_kit.secure | default(secure) | bool else 'http' }}://{{ hostvars[host]['ip_service'] }}:{{ vitamui.starter_kit.port_service }}/ {{ reverse_connection_params }} + ProxyPassReverse / {{ 'https' if vitamui.starter_kit.secure | default(secure) | bool else 'http' }}://{{ hostvars[host]['ip_service'] }}:{{ vitamui.starter_kit.port_service }}/ +{% endfor %} + diff --git a/deployment/roles/reverse/templates/nginx/conf.d/upstream.j2 b/deployment/roles/reverse/templates/nginx/conf.d/upstream.j2 index 1458cf04753..122bf630dbb 100644 --- a/deployment/roles/reverse/templates/nginx/conf.d/upstream.j2 +++ b/deployment/roles/reverse/templates/nginx/conf.d/upstream.j2 @@ -77,3 +77,13 @@ upstream PASTIS { {% endfor %} } {% endif %} + +# To prevent creating a new hosts_ui_starter_kit host, we reuse hosts_ui_portal +{% if groups['hosts_ui_portal']|length > 0 %} +upstream STARTER_KIT { + ip_hash; +{% for h in groups['hosts_ui_portal'] %} + server {{ hostvars[h].ip_service }}:{{ vitamui.starter_kit.port_service }}; +{% endfor %} +} +{% endif %} diff --git a/deployment/roles/reverse/templates/nginx/conf.d/vhosts.conf.j2 b/deployment/roles/reverse/templates/nginx/conf.d/vhosts.conf.j2 index 3e683109e4c..1cfde85a3a7 100644 --- a/deployment/roles/reverse/templates/nginx/conf.d/vhosts.conf.j2 +++ b/deployment/roles/reverse/templates/nginx/conf.d/vhosts.conf.j2 @@ -100,6 +100,28 @@ server { } {% endif %} +# To prevent creating a new hosts_ui_starter_kit host, we reuse hosts_ui_portal +{% if groups['hosts_ui_portal']|length > 0 %} + # STARTER KIT + location /starter-kit { + rewrite /starter-kit/(.*) /$1 break; + proxy_pass {{ 'https' if vitamui.starter_kit.secure | default(secure) | bool else 'http' }}://STARTER_KIT; + + include {{ nginx_conf_dir }}/proxy_params; + + # http://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_request_buffering + # The request body is sent to the proxied server immediately as it is received. + proxy_request_buffering off; + + # http://nginx.org/en/docs/http/ngx_http_core_module.html#client_max_body_size + # Sets the maximum allowed size of the client request body. + # If the size in a request exceeds the configured value, the 413 (Request Entity Too Large) error is returned to the client. + # Please be aware that browsers cannot correctly display this error. + # Setting size to 0 disables checking of client request body size. + client_max_body_size 0; + } +{% endif %} + # CAS SERVER location = /cas { return 302 $scheme://$host/cas/login; diff --git a/ui/pom.xml b/ui/pom.xml index 3f55ad2278d..922417fe7d8 100644 --- a/ui/pom.xml +++ b/ui/pom.xml @@ -24,6 +24,7 @@ ui-archive-search ui-pastis ui-collect + ui-starter-kit diff --git a/ui/ui-frontend/package.json b/ui/ui-frontend/package.json index 659e5b3488a..e6448d68dd8 100644 --- a/ui/ui-frontend/package.json +++ b/ui/ui-frontend/package.json @@ -51,7 +51,7 @@ "build:pastis": "export NODE_OPTIONS=--max_old_space_size=1024; ng build pastis --prod --base-href=/pastis/ --deploy-url=/pastis/ --i18n-locale fr", "build:pastis-standalone": "NODE_OPTIONS=--max_old_space_size=1024 ng build --configuration=standalone --i18n-locale fr --project=pastis", "build:collect": "export NODE_OPTIONS=--max_old_space_size=1024; ng build collect --prod --base-href=/collect/ --deploy-url=/collect/ --i18n-locale fr", - "build:starter-kit": "export NODE_OPTIONS=--max_old_space_size=1024; ng build starter-kit --prod --base-href=/ --deploy-url=/ --i18n-locale fr", + "build:starter-kit": "export NODE_OPTIONS=--max_old_space_size=1024; ng build starter-kit --prod --base-href=/starter-kit/ --deploy-url=/starter-kit/ --i18n-locale fr", "analyze-portal": "ng build portal --stats-json --prod ; webpack-bundle-analyzer dist/portal/stats.json", "analyze-identity": "ng build identity --stats-json --prod --i18n-locale fr ; webpack-bundle-analyzer dist/identity/stats.json", "analyze-referential": "ng build referential --stats-json --prod --i18n-locale fr ; webpack-bundle-analyzer dist/referential/stats.json", diff --git a/ui/ui-starter-kit/pom.xml b/ui/ui-starter-kit/pom.xml new file mode 100644 index 00000000000..fb23cb12d2f --- /dev/null +++ b/ui/ui-starter-kit/pom.xml @@ -0,0 +1,40 @@ + + + + ui-parent + fr.gouv.vitamui + 7.1.0-SNAPSHOT + + 4.0.0 + ui-starter-kit + jar + VITAMUI UI Starter kit + + /starter-kit/ + starter-kit + false + false + false + false + false + false + false + true + + + + + target/www/ + static/ + + + + + com.github.eirslett + frontend-maven-plugin + + + +