-
Notifications
You must be signed in to change notification settings - Fork 9
Deployment
Requirements:
- aws-cli v2+
- Terraform v1.5.6+
- AWS IAM account CLI keys
Change directory to src
and type nix-shell
. The required tools will be
downloaded and installed in their required versions.
AWS is configured with Terraform, but the account needs to be bootstrapped beforehand.
This has to be done only once per AWS account.
- Configure AWS CLI with
aws configure
(if you are using a configuration profile, useaws --profile MYPROFILE configure
and thenexport AWS_PROFILE=MYPROFILE
). - Execute
./infra/terraform/bootstrap-aws-account.sh
script.
- Change directory to
src/terraform
. - Run
terraform init
to initialize Terraform. - Run
terraform plan
to view changes that would be performed to infrastructure. - Take note of the outputs - they contain ECR repo URLs and app domains.
Note: the Terraform code configures the EC2 instance using infra/terraform/modules/govtool-ec2/user_data.sh
. This script is only executed on instance creation.
- Set environment variables in your shell (see
src/.env.example
file for list of variables and sample values). - Prepare configuration files for target environment:
- Run
make prepare-config
- this will createconfig/target
directory on your machine with necessary files. - Run
make upload-config instance=$INSTANCE cardano_network=$CARDANO_NETWORK env=$ENVIRONMENT
- this will upload theconfig/target
directory to appropriate EC2 instance.
- Run
- Build the application Docker images:
- Run
make build-backend
. - Run
make build-frontend instance=$INSTANCE cardano_network=$CARDANO_NETWORK env=$ENVIRONMENT
.
- Run
- Push the images to ECR:
- Run
make docker-login
. - Run
make push-backend
. - Run
make push-frontend instance=$INSTANCE cardano_network=$CARDANO_NETWORK env=$ENVIRONMENT
.
- Run
- Deploy the application: run
make deploy-stack instance=$INSTANCE cardano_network=$CARDANO_NETWORK env=$ENVIRONMENT
.
On first deploy, the last command will take a long while. On subsequent deployments it should perform faster.
Alternatively you can type make all instance=$INSTANCE cardano_network=$CARDANO_NETWORK env=$ENVIRONMENT
to deploy all at once.
View the app at https://${ENVIRONMENT}-${INSTANCE}.govtool.byron.network
.
Keep in mind that after initial deployment on a new environment, it will take some time for the Cardano node to get in sync.
After performing a deploy from a local machine, it is crucial to carefully track the application's accessibility and functionality to ensure no unintended changes, such as the accidental activation of BasicAuth^1, have occurred.
Additionally, verifying that all configuration files and environment variables, particularly those related to environment-specific settings like database connections or external service endpoints, are correctly generated and applied is essential for maintaining the intended behavior of the application across different environments. This includes a thorough check of environment variables to confirm they are correctly set and aligned with the specific needs of the deployed environment.