Digger Old Docs
Search
⌃K
😀

Trowel todo list deployment

In this guide we will deploy our first application using Trowel! We will be deploying https://github.com/veziak/django-todolist. This is a Django application which requires a database.
Visit dashboard.digger.dev and click on create to create your infrastructure bundle for this application
we want to deploy it as a container, so click on the container block, change the port to '8000' and click on generate
We need to add a placeholder for database connection env variable which is needed for our application. Click on "add Secrets" and enter a placeholder value for the DATABASE_URL parameter
click on generate to save your block
lets create a database next, click on add block and select "postgres"
lets download the bundle
For the next step we need aws cli, so make sure you have it installed and then run aws configure if you its your first time using the cli. You will be asked to enter keys which you can generate using [[this tutorial]].
We need to have dgctl cli for the next step. Please follow installation instructions to install it.
now in terminal navigate to the directory where you unzipped the terraform and run dgctl init,
This will initialize your terraform state backend to use an S3 bucket in your account. This is needed so that you can re-download and re-run your terraform from the dashboard project multiple times.
Next up! Lets create the infrastructure
terraform init
# see what will be created
terraform plan
terraform apply
Now we wait for a few minutes until the terraform apply step is completed. We will see an output like the one below:
There are several important peices of output here. For the purposes of this tutorial keep track of lb_dns and docker_registry_url
In the next step we need to visit AWS console and update the secrets. search for "parameter store in the params and find a secret called DATABASE_URL. Replace that value with the value of the other database_url parameter
Final step! We need to build our container image. Remember we noted docker_registry_url ? This is where it comes in handy. The url looks like follows:
209539466991.dkr.ecr.us-east-1.amazonaws.com/drip-be
We need to store these parameters in order to build our image:
export AWS_ACCOUNT_ID="$(aws sts get-caller-identity --query "Account" --output text)"
export AWS_REGION=us-east-1
export ECR_REPO=drip-be
Finally! Run these commands to build and deploy your container image
aws ecr get-login-password --region $AWS_REGION | docker login --username AWS --password-stdin $AWS_ACCOUNT_ID.dkr.ecr.$AWS_REGION.amazonaws.com
docker build -t $AWS_ACCOUNT_ID.dkr.ecr.$AWS_REGION.amazonaws.com/$ECR_REPO .
docker push $AWS_ACCOUNT_ID.dkr.ecr.$AWS_REGION.amazonaws.com/$ECR_REPO:latest
You should see a push in progress and it should be successful in the end