Archetype deployments use the Kamal tool. It can be configured through the files located on the .kamal directory.
For more options see the Kamal documentation.
Before doing any deployment you will need:
- A Linux server (Docker will be installed with Kamal automatically)
- An image pushed to a Docker registry (of our application, ideally tagged as
latest
) - We will setup both
production
andstaging
to the same server and we will use the same database for both environments.
You will need to follow this steps:
-
Before executing any command we have to make sure to have a
.env
file with all the variables for our application ready for thestaging
server. This is temporary because when you setup the server, your.env
will be used as default values. Make sure to also add the variables on the.kamal/.env.example
. Those are needed for the accessories of this project. You can change the values later, located at~/.kamal/env
. -
Upload Traefik certificates configuration files to the server. This configuration will also depend on how you want to manager your certificates. On this example we want to use an origin certificate generated on Cloudflare, so we will upload it to
~/traefik/certs
and create aconf.yml
on~/traefik/conf.yml
with the following content:
tls:
certificates:
- certFile: /certs/cert.crt
keyFile: /certs/cert.key
- Create initial version of shared files:
- robots.txt:
~/archetype-drupal-app/staging/robots.txt
and~/archetype-drupal-app/production/robots.txt
When everything is ready, to prepare the server, you can use the command:
make deploy-setup
This command will install Docker on the server and deploy the application. In case you are deploying multiple applications, remember that you only need to do the setup once, but you will need to push the environment variables and deploy each application separately.
Normally you want to deploy using your CI/CD tool, but you can also deploy manually. To initiate a normal deployment you can use:
make deploy
This command has a default of deploying to staging
the latest
version. You can modify the DESTINATION
variable to deploy to another server:
make deploy DESTINATION=production
You can also change the deployment version by setting the VERSION
variable:
make deploy VERSION=1.0.0
Those variables also work with the deploy-setup
command.
Another command that is better suited for executing in a CI/CD environment is the deploy-env
command:
make deploy-env-push
This command will modify the environment variables of the server.
If you need to rollback to a previous version you can use the deploy
command with the VERSION
variable:
make deploy VERSION=1.9.0
There are other commands available to help you with the deployment process. You can check them in the Makefile file.