Thing | Version |
---|---|
gcloud | |
OpenTofu | 1.81 |
sops | 3.9 |
age | 1 |
Make | 4 |
Bash | 5 |
Here are the scripts relevant in deploying the project.
Except the directories .github
, ci
, scripts
, secrets
, tf_backend
, all directories are services.
Each service has:
- A
tf
directory, which contains the Terraform configuration for the service. - A
source.sh
file, which sources the base directory'ssource.sh
file and adds on any additional environment variables required by the service. - A
Makefile
which contains the commands to deploy, test and destroy the service.
Here are the relevant make targets for each service. For some services, the Makefile
may omit some of these targets (e.g. docker_registry
service has no code to build or deploy.)
Usage: make [target]
Targets:
help Show this help
local Run the code locally
deploy Deploy the code and infrastructure
destroy Destroy the infrastructure
test Run the tests
code_build Build the code
code_deploy Deploy the code
infra_deploy Deploy the infrastructure
infra_destroy Destroy the infrastructure
url Get the service URL
There are two ways to deploy the project to the cloud. Note that every branch creates its own separate deployment copy.
First, you can simply push to your feature branch, and the CI/CD pipeline will deploy a copy of the infrastructure and the code to the cloud.
To deploy all infrastructure and code on the command line, you can run the following command:
# Decrypt secrets
make decrypt # You need your age key in the sops file, contact Yongbeom for how to do this.
# In the base directory,
make deploy
# This is equivalent to running
make deploy # in docker_registry
make deploy # in frontend
make deploy # in backend
To destroy your deployment, you can do:
# Decrypt secrets
make decrypt # You need your age key in the sops file, contact Yongbeom for how to do this.
# In the base directory,
make destroy
# This is equivalent to running
make destroy # in docker_registry
make destroy # in frontend
make destroy # in backend
Once you have deployed the infrastructure, you do not need to do so again, you can simply update our deployment by deploying code.
To deploy the code, you can do:
# deploy frontend code
make code_deploy # in frontend directory
# deploy backend code
make code_deploy # in backend directory
Alternatively, you can deploy the code locally.
Run the following commands (in separate terminals) to deploy the frontend and backend code locally.
# deploy frontend code
make local
# deploy backend code
make local
All direct subdirectories of the project base directory (with the following exceptions) are microservices.
Additional information about some directories is provided below.
Contains scripts for setting up the project.
Usage:
# Generate a new age key for secret encryption.
./scripts/generate_age_key.sh
# Encrypt all secret files
./scripts/secret.sh encrypt
# Decrypt all secret files
./scripts/secret.sh decrypt
Contains secrets for the project.
Contains the Terraform configuration for the Terraform state backend. For this project, the terraform backend is stored in a Google Cloud Storage bucket.
Footnotes
-
OpenTofu 1.8.0 introduces static variable evaluation, which we use for the project. ↩