Skip to content

Conversation

@esolitos
Copy link
Contributor

@esolitos esolitos commented Jul 3, 2024

What

The changes in this commit add an automatic Drupal deployment feature to the default Dockerfile for the Drupal-PHP template.

The main changes are:

  1. Added a new environment variable DRUPAL_DEPLOY_CHANGES that can be set to auto to enable automatic deployment.
  2. Added a new init script /docker-entrypoint-init.d/50-deploy-changes.sh that checks the database version and performs a deployment if the codebase version is newer.
  3. The init script uses Drush to check the database version, perform the deployment, and update the version identifier in the database.

Why

This feature allows the Drupal application to be automatically updated when the codebase changes, without the need for manual intervention.

Additional Context

Changes required on workflow: This change requires to also update the "build" workflow to ensure that the init script is included in the container as we already do for things like the crontab file, and the nginx error page. The only difference from the previous steps is that the job only needs to ensure that the file is pleced in [repo-root]/infrastructure/docker/drupal-php/init.d and then the Dockerfile will take care of the rest.

Example:

      - name: Setup init
        if: matrix.container-name == 'drupal-php'
        run: |
          deploy_script="infrastructure/docker/drupal-php/init.d/50-deploy-changes.sh"
          if [[ ! -f "${deploy_script}" ]] ; then
            echo "Downloaded default 'deploy' script" >> $GITHUB_STEP_SUMMARY
            mkdir -p $(dirname "${deploy_script}")
            curl -sSL -o "${deploy_script}" "${{ env.BUILD_TEMPLATES_BASE_URL }}/init/50-deploy-changes.sh"
          fi

Used also on: a slight variation of this is in use in Sikt with their docker init files.

The changes in this commit add an automatic Drupal deployment feature to the default Dockerfile for the Drupal-PHP template.

The main changes are:

1. Added a new environment variable `DRUPAL_DEPLOY_CHANGES` that can be set to `auto` to enable automatic deployment.
2. Added a new init script `/docker-entrypoint-init.d/50-deploy-changes.sh` that checks the database version and performs a deployment if the codebase version is newer.
3. The init script uses Drush to check the database version, perform the deployment, and update the version identifier in the database.

This feature allows the Drupal application to be automatically updated when the codebase changes, without the need for manual intervention.
}

main() {
deployment_identifier_file="${APP_ROOT}/.VERSION"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the part which would need to be looked at because the .VERSION is generated by the generate-deployment-identifier command, which is only taking care of the composer changes, nothing to do with Drupal.

A better way would be probably to compute a hash of site-schema.json to ensure we deploy each time there are new db updates or new modules as well.

At the same time using only site-schema does not take in account changes to drupal config only..
So ultimately you should look into finding a new method to detect if changes should be deployed or not.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants