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
.kamal/.env
file with all the variables for our application ready for thestaging
server. Make sure to add the variables on the.kamal/.env.example
. Those variables are needed to access the correct server and have the credentials for the registry -
Create a
.kamal/secrets.staging
file with the secrets for thestaging
server. This file will be used to set the environment variables on the server. Normally you will create this file using a secrets manager like Bitwarden Secrets Manager. You can use the command:
bws secret list <bws_project_id> --output=env > .kamal/secrets.staging
- Create initial version of shared files:
- robots.txt:
~/archetype-symfony-app/staging/robots.txt
and~/archetype-symfony-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 deploy each application separately.
Warning
Normally you want to deploy using your CI/CD tool, but there could be certain cases where you might want to execute a manual deployment.
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.
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.