In this lesson we will:
- Generate a deployment artifact.
- Push the artifact to Acquia Cloud Platform.
Lesson Goal
Generate a production-ready deployment artifact for a Drupal 9 application.
In order to complete this lesson you will need:
Lesson
Manual approach¶
At a minimum, use Composer to remove development dependencies and optimize your application's autoloader:
composer install --no-dev --optimize-autoloader
This will install only the dependencies in your composer.json's "require" array (not in the "require-dev" array) and will optimize Composer's autoloader, which significantly improves application performance.
You should also consider performing the following manual steps:
- Remove Drupal core text files, like
CHANGELOG.txt, from your docroot directory. These can inadvertently reveal your exact Drupal core version to malicious site visitors. - Change/Restrict any reachable path for security purposes.
- Compile front end source code (like SASS) into front end assets (like CSS).
After you've manually prepared your codebase for production, you will need to create a new Git tag.
Using a git tag for deployment is a best practice because tags are immutable. In other words, after it has been created a tag cannot be changed. For instance, using a tag will prevent someone from accidentally pushing a new commit to a branch that is deployed to your production environment. This cannot happen with a tag.
git tag 1.0.0 -m 'This is the first major release!'
Now that your tag is cut, you can push it to Acquia Cloud Platform:
Naming your releases¶
You should use a naming convention for your tags that works well for your team. The most popular (and recommended option) is Semantic Versioning (semver). In short, semver provides a set of rules for naming tags. The rules help you track:
- The order in which releases are made.
- Releases that introduce backwards incompatible changes (major).
- Releases that introduce new, backwards compatible functionality (minor).
- Releases that provide backwards compatible bug fixes (patch).
Tags using semver take the form MAJOR.MINOR.PATCH. For more information, see semver.org.
In combination with Composer version constraints, you can use semver to ensure that your application's dependencies are never accidentally updated to a backwards incompatible version.
Now that you have a deployment artifact, you're ready to deploy it on your Acquia Cloud Platform non-production environment! Reminder: Before moving to Production, ensure you take a database backup of your Production environment first.
Resources