From 3e8f35706552c32be3894e2f66f160fbf06f5b4e Mon Sep 17 00:00:00 2001 From: Tero Virtanen Date: Mon, 10 Feb 2025 09:14:53 +0200 Subject: [PATCH 1/9] Migration entrypoint --- docker/openshift/Dockerfile | 4 ++++ docker/openshift/migration-entrypoint.sh | 11 +++++++++++ 2 files changed, 15 insertions(+) create mode 100644 docker/openshift/migration-entrypoint.sh diff --git a/docker/openshift/Dockerfile b/docker/openshift/Dockerfile index 32d4a3a2..9d329a23 100644 --- a/docker/openshift/Dockerfile +++ b/docker/openshift/Dockerfile @@ -17,5 +17,9 @@ COPY docker/openshift/crons/ /crons COPY docker/openshift/cron-entrypoint.sh /usr/local/bin/cron-entrypoint RUN chmod +x /crons/* /usr/local/bin/cron-entrypoint +# Copy migration scripts +COPY docker/openshift/migration-entrypoint.sh /usr/local/bin/migration-entrypoint +RUN chmod +x /usr/local/bin/migration-entrypoint + # Copy nginx overrides. COPY docker/openshift/custom.locations /etc/nginx/conf.d/custom.locations diff --git a/docker/openshift/migration-entrypoint.sh b/docker/openshift/migration-entrypoint.sh new file mode 100644 index 00000000..5df2e410 --- /dev/null +++ b/docker/openshift/migration-entrypoint.sh @@ -0,0 +1,11 @@ +#!/bin/bash + +source /init.sh + +echo "Starting migration: $(date)" + +drush state:set system.maintenance_mode 1 --input-format=integer +drush helfi:pre-deploy || true +drush deploy +drush helfi:post-deploy || true +drush state:set system.maintenance_mode 0 --input-format=integer From e89991958d6d5d7f798ff4d3d3670cc547c2ba39 Mon Sep 17 00:00:00 2001 From: Tero Virtanen Date: Mon, 10 Feb 2025 09:16:48 +0200 Subject: [PATCH 2/9] Temporaly ref to test pipelines --- pipelines/drupal-test.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/pipelines/drupal-test.yml b/pipelines/drupal-test.yml index 1b1ec850..de91ecc9 100644 --- a/pipelines/drupal-test.yml +++ b/pipelines/drupal-test.yml @@ -31,6 +31,7 @@ resources: # Azure DevOps repository - repository: helfi-rekry-pipelines type: git + ref: refs/heads/database_migration_PLATTA-5751 # Azure DevOps project/repository name: helfi-rekry/helfi-rekry-pipelines From f6e9220734f888eca6a9f00564a778abcd03b6ce Mon Sep 17 00:00:00 2001 From: Tero Virtanen Date: Mon, 10 Feb 2025 09:17:30 +0200 Subject: [PATCH 3/9] Temporaly ref to test pipelines --- pipelines/drupal-test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pipelines/drupal-test.yml b/pipelines/drupal-test.yml index de91ecc9..82e7879e 100644 --- a/pipelines/drupal-test.yml +++ b/pipelines/drupal-test.yml @@ -31,7 +31,7 @@ resources: # Azure DevOps repository - repository: helfi-rekry-pipelines type: git - ref: refs/heads/database_migration_PLATTA-5751 + ref: refs/heads/databse_migration_PLATTA-5751 # Azure DevOps project/repository name: helfi-rekry/helfi-rekry-pipelines From 951934653275d3c83fcd8b9572a4a125a7bef0d3 Mon Sep 17 00:00:00 2001 From: Tero Virtanen Date: Mon, 10 Feb 2025 09:26:19 +0200 Subject: [PATCH 4/9] Remove temporaly ref to test pipelines --- pipelines/drupal-test.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/pipelines/drupal-test.yml b/pipelines/drupal-test.yml index 82e7879e..1b1ec850 100644 --- a/pipelines/drupal-test.yml +++ b/pipelines/drupal-test.yml @@ -31,7 +31,6 @@ resources: # Azure DevOps repository - repository: helfi-rekry-pipelines type: git - ref: refs/heads/databse_migration_PLATTA-5751 # Azure DevOps project/repository name: helfi-rekry/helfi-rekry-pipelines From b5e407073f8753e6854925dc13a50aabb0221e22 Mon Sep 17 00:00:00 2001 From: Tero Virtanen Date: Mon, 10 Feb 2025 13:07:05 +0200 Subject: [PATCH 5/9] Rename migration to drush-deploy --- docker/openshift/Dockerfile | 6 +++--- .../{migration-entrypoint.sh => drush-deploy-entrypoint.sh} | 0 2 files changed, 3 insertions(+), 3 deletions(-) rename docker/openshift/{migration-entrypoint.sh => drush-deploy-entrypoint.sh} (100%) diff --git a/docker/openshift/Dockerfile b/docker/openshift/Dockerfile index 9d329a23..9fdf2099 100644 --- a/docker/openshift/Dockerfile +++ b/docker/openshift/Dockerfile @@ -17,9 +17,9 @@ COPY docker/openshift/crons/ /crons COPY docker/openshift/cron-entrypoint.sh /usr/local/bin/cron-entrypoint RUN chmod +x /crons/* /usr/local/bin/cron-entrypoint -# Copy migration scripts -COPY docker/openshift/migration-entrypoint.sh /usr/local/bin/migration-entrypoint -RUN chmod +x /usr/local/bin/migration-entrypoint +# Copy drush-deploy scripts +COPY docker/openshift/drush-deploy-entrypoint.sh /usr/local/bin/drush-deploy-entrypoint +RUN chmod +x /usr/local/bin/drush-deploy-entrypoint # Copy nginx overrides. COPY docker/openshift/custom.locations /etc/nginx/conf.d/custom.locations diff --git a/docker/openshift/migration-entrypoint.sh b/docker/openshift/drush-deploy-entrypoint.sh similarity index 100% rename from docker/openshift/migration-entrypoint.sh rename to docker/openshift/drush-deploy-entrypoint.sh From 961c11279b5a0506d57b88c6d61da41031d2706f Mon Sep 17 00:00:00 2001 From: tuutti Date: Tue, 11 Feb 2025 09:35:36 +0200 Subject: [PATCH 6/9] database_migration_PLATTA-5751: Added comments, keep the new deploy script backwards compatible with 20-deploy.sh --- docker/openshift/Dockerfile | 2 +- docker/openshift/drush-deploy-entrypoint.sh | 12 +++++++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/docker/openshift/Dockerfile b/docker/openshift/Dockerfile index 9fdf2099..7c116fa1 100644 --- a/docker/openshift/Dockerfile +++ b/docker/openshift/Dockerfile @@ -17,7 +17,7 @@ COPY docker/openshift/crons/ /crons COPY docker/openshift/cron-entrypoint.sh /usr/local/bin/cron-entrypoint RUN chmod +x /crons/* /usr/local/bin/cron-entrypoint -# Copy drush-deploy scripts +# Copy drush deploy scripts COPY docker/openshift/drush-deploy-entrypoint.sh /usr/local/bin/drush-deploy-entrypoint RUN chmod +x /usr/local/bin/drush-deploy-entrypoint diff --git a/docker/openshift/drush-deploy-entrypoint.sh b/docker/openshift/drush-deploy-entrypoint.sh index 5df2e410..91011360 100644 --- a/docker/openshift/drush-deploy-entrypoint.sh +++ b/docker/openshift/drush-deploy-entrypoint.sh @@ -2,10 +2,20 @@ source /init.sh -echo "Starting migration: $(date)" +echo "Starting deploy: $(date)" + +# Populate deploy ID so 20-deploy.sh is skipped. +# @todo Remove this once 20-deploy.sh is removed. +set_deploy_id $OPENSHIFT_BUILD_NAME drush state:set system.maintenance_mode 1 --input-format=integer +# Run pre-deploy tasks. +# @see https://github.com/City-of-Helsinki/drupal-module-helfi-api-base/blob/main/documentation/deploy-hooks.md drush helfi:pre-deploy || true +# Run maintenance tasks (config import, database updates etc) drush deploy +# Run post-deploy tasks. +# @see https://github.com/City-of-Helsinki/drupal-module-helfi-api-base/blob/main/documentation/deploy-hooks.md drush helfi:post-deploy || true +# Disable maintenance mode drush state:set system.maintenance_mode 0 --input-format=integer From e72ca5dfaa71a16e73745c2d5d1c7db197f7628f Mon Sep 17 00:00:00 2001 From: tuutti Date: Fri, 14 Feb 2025 07:13:21 +0200 Subject: [PATCH 7/9] database_migration_PLATTA-5751: New deploy script structure --- docker/openshift/Dockerfile | 16 ++++------------ docker/openshift/deploy/10-preflight.sh | 11 +++++++++++ docker/openshift/deploy/20-deploy.sh | 21 +++++++++++++++++++++ 3 files changed, 36 insertions(+), 12 deletions(-) create mode 100644 docker/openshift/deploy/10-preflight.sh create mode 100644 docker/openshift/deploy/20-deploy.sh diff --git a/docker/openshift/Dockerfile b/docker/openshift/Dockerfile index 7c116fa1..b10ad83a 100644 --- a/docker/openshift/Dockerfile +++ b/docker/openshift/Dockerfile @@ -5,21 +5,13 @@ COPY / /var/www/html/ WORKDIR /var/www/html RUN composer install --no-progress --profile --prefer-dist --no-interaction --no-dev --optimize-autoloader -# Copy ALL deploy scripts +# Copy custom entrypoint, deploy and cron scripts. +RUN mkdir -p /crons /entrypoints /deploy COPY docker/openshift/entrypoints/ /entrypoints -RUN chmod +x /entrypoints/* - -COPY docker/openshift/init.sh / - -# Copy cron scripts -RUN mkdir /crons COPY docker/openshift/crons/ /crons -COPY docker/openshift/cron-entrypoint.sh /usr/local/bin/cron-entrypoint -RUN chmod +x /crons/* /usr/local/bin/cron-entrypoint +RUN chmod +x /entrypoints/* /deploy/* /crons/* -# Copy drush deploy scripts -COPY docker/openshift/drush-deploy-entrypoint.sh /usr/local/bin/drush-deploy-entrypoint -RUN chmod +x /usr/local/bin/drush-deploy-entrypoint +COPY docker/openshift/init.sh / # Copy nginx overrides. COPY docker/openshift/custom.locations /etc/nginx/conf.d/custom.locations diff --git a/docker/openshift/deploy/10-preflight.sh b/docker/openshift/deploy/10-preflight.sh new file mode 100644 index 00000000..b58e6213 --- /dev/null +++ b/docker/openshift/deploy/10-preflight.sh @@ -0,0 +1,11 @@ +#!/bin/sh + +source /init.sh + +if [ -f "../docker/openshift/preflight/preflight.php" ]; then + echo "Running preflight checks ..." + if ! php ../docker/openshift/preflight/preflight.php; then + exit 1 + fi +fi + diff --git a/docker/openshift/deploy/20-deploy.sh b/docker/openshift/deploy/20-deploy.sh new file mode 100644 index 00000000..91011360 --- /dev/null +++ b/docker/openshift/deploy/20-deploy.sh @@ -0,0 +1,21 @@ +#!/bin/bash + +source /init.sh + +echo "Starting deploy: $(date)" + +# Populate deploy ID so 20-deploy.sh is skipped. +# @todo Remove this once 20-deploy.sh is removed. +set_deploy_id $OPENSHIFT_BUILD_NAME + +drush state:set system.maintenance_mode 1 --input-format=integer +# Run pre-deploy tasks. +# @see https://github.com/City-of-Helsinki/drupal-module-helfi-api-base/blob/main/documentation/deploy-hooks.md +drush helfi:pre-deploy || true +# Run maintenance tasks (config import, database updates etc) +drush deploy +# Run post-deploy tasks. +# @see https://github.com/City-of-Helsinki/drupal-module-helfi-api-base/blob/main/documentation/deploy-hooks.md +drush helfi:post-deploy || true +# Disable maintenance mode +drush state:set system.maintenance_mode 0 --input-format=integer From 0e8f707e7c1f85adc1802b43b1418bdd88d9bca8 Mon Sep 17 00:00:00 2001 From: tuutti Date: Fri, 14 Feb 2025 07:32:25 +0200 Subject: [PATCH 8/9] database_migration_PLATTA-5751: Added missing copy --- docker/openshift/Dockerfile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docker/openshift/Dockerfile b/docker/openshift/Dockerfile index b10ad83a..205ab960 100644 --- a/docker/openshift/Dockerfile +++ b/docker/openshift/Dockerfile @@ -6,9 +6,10 @@ WORKDIR /var/www/html RUN composer install --no-progress --profile --prefer-dist --no-interaction --no-dev --optimize-autoloader # Copy custom entrypoint, deploy and cron scripts. -RUN mkdir -p /crons /entrypoints /deploy +RUN mkdir /crons /entrypoints /deploy COPY docker/openshift/entrypoints/ /entrypoints COPY docker/openshift/crons/ /crons +COPY docker/openshift/deploy /deploy RUN chmod +x /entrypoints/* /deploy/* /crons/* COPY docker/openshift/init.sh / From 0f5ace755bd4cc475a97dc8462bc663990885ec0 Mon Sep 17 00:00:00 2001 From: tuutti Date: Fri, 14 Feb 2025 07:43:35 +0200 Subject: [PATCH 9/9] database_migration_PLATTA-5751: fixed mkdir --- docker/openshift/Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docker/openshift/Dockerfile b/docker/openshift/Dockerfile index 205ab960..71b280a7 100644 --- a/docker/openshift/Dockerfile +++ b/docker/openshift/Dockerfile @@ -5,8 +5,8 @@ COPY / /var/www/html/ WORKDIR /var/www/html RUN composer install --no-progress --profile --prefer-dist --no-interaction --no-dev --optimize-autoloader -# Copy custom entrypoint, deploy and cron scripts. -RUN mkdir /crons /entrypoints /deploy +# Copy custom entrypoint, deploy and cron entrypoints. +RUN mkdir -p /crons /entrypoints /deploy COPY docker/openshift/entrypoints/ /entrypoints COPY docker/openshift/crons/ /crons COPY docker/openshift/deploy /deploy