From ebb6929c225bcc4817d2ac7a8880944fd5620fc0 Mon Sep 17 00:00:00 2001 From: Kevin Barnoin Date: Mon, 29 Apr 2024 11:43:54 +0200 Subject: [PATCH] feat: lbac 2152: deploy upgrade following docker update (#1210) * feat: enable pe cert on production only * feat: update infra following docker update --- .infra/ansible/deploy.yml | 10 ++-------- .infra/files/scripts/cli.sh | 2 +- .infra/files/scripts/migrations-status.sh | 2 +- .infra/files/scripts/migrations-up.sh | 2 +- .../files/scripts/trigger_indexes_creation.sh | 17 +++++++++++++++++ 5 files changed, 22 insertions(+), 11 deletions(-) create mode 100644 .infra/files/scripts/trigger_indexes_creation.sh diff --git a/.infra/ansible/deploy.yml b/.infra/ansible/deploy.yml index 0cb4934c54..ed1e6edf16 100644 --- a/.infra/ansible/deploy.yml +++ b/.infra/ansible/deploy.yml @@ -7,16 +7,10 @@ tasks: - include_tasks: ./tasks/files_copy.yml - - name: Création du docker-compose.yml {{env_type}} - shell: - chdir: /opt/app - cmd: 'sudo docker compose $(for file in $(ls docker-compose.*.yml); do echo -n "-f $file "; done) config -o docker-compose.yml' - register: docker_deploy_output - - name: Récupération des images docker shell: chdir: /opt/app - cmd: "sudo docker compose pull" + cmd: "/opt/app/tools/docker-compose.sh pull" - name: Récupération du status de la stack shell: @@ -114,7 +108,7 @@ hour: "2" weekday: "1" job: "bash /opt/app/tools/ssl/renew-certificate.sh {{ alias_dns_name }} >> /var/log/cron.log 2>&1; /opt/app/tools/monitoring/export-cron-status-prom.sh -c 'Renew certificate Alias' -v $?" - when: env_type != "preview" + when: env_type == "production" - name: "Setup de la Metabase" shell: diff --git a/.infra/files/scripts/cli.sh b/.infra/files/scripts/cli.sh index f286141d40..3800364496 100755 --- a/.infra/files/scripts/cli.sh +++ b/.infra/files/scripts/cli.sh @@ -2,4 +2,4 @@ set -euo pipefail #Needs to be run as sudo -docker compose run --rm --no-deps server yarn cli "$@" +/opt/app/tools/docker-compose.sh run --rm --no-deps server yarn cli "$@" diff --git a/.infra/files/scripts/migrations-status.sh b/.infra/files/scripts/migrations-status.sh index b16784484c..c418bd8d84 100755 --- a/.infra/files/scripts/migrations-status.sh +++ b/.infra/files/scripts/migrations-status.sh @@ -2,4 +2,4 @@ set -euo pipefail #Needs to be run as sudo -docker compose run --rm --no-deps server yarn cli migrations:status +/opt/app/tools/docker-compose.sh run --rm --no-deps server yarn cli migrations:status diff --git a/.infra/files/scripts/migrations-up.sh b/.infra/files/scripts/migrations-up.sh index e5197c7f5a..f569d345d0 100755 --- a/.infra/files/scripts/migrations-up.sh +++ b/.infra/files/scripts/migrations-up.sh @@ -12,7 +12,7 @@ fi run_migrations(){ echo "Application des migrations ..." - docker compose run --rm --no-deps server yarn cli migrations:up 2>&1 | tee "$LOG_FILEPATH" + /opt/app/tools/docker-compose.sh run --rm --no-deps server yarn cli migrations:up 2>&1 | tee "$LOG_FILEPATH" } run_migrations diff --git a/.infra/files/scripts/trigger_indexes_creation.sh b/.infra/files/scripts/trigger_indexes_creation.sh new file mode 100644 index 0000000000..a9df613bcf --- /dev/null +++ b/.infra/files/scripts/trigger_indexes_creation.sh @@ -0,0 +1,17 @@ +#!/usr/bin/env bash +set -euo pipefail +#Needs to be run as sudo + +readonly LOG_DIR="/var/log/data-jobs" + +if [ ! -d "$LOG_DIR" ]; then + sudo mkdir -p "$LOG_DIR" + sudo chown $(whoami):$(whoami) "$LOG_DIR" +fi + +trigger_indexes_creation(){ + echo "Création des index mongoDb ..." + /opt/app/tools/docker-compose.sh run --rm --no-deps server yarn cli indexes:recreate --queued +} + +trigger_indexes_creation