- Create a very simple Python app
- Write Dockerfile for packaging it
- Local testing with with Docker Compose
- Terraform
- Build image and push to ACR
- Deploy container
- GitHub actions? ✅
- Releases? with tags ✅
- CI/CD pipelines? simple GitHub Actions workflow ✅
Estimate was 10 h but completed in ~8 h
- This should be the default way of working
- You could let GitHub Actions use the remote state but you could also locally modify the infrastructure at the same time
terraform {
required_providers {
azurerm = {
source = "hashicorp/azurerm"
version = "4.59.0"
}
}
backend "azurerm" {}
}- Make sure backend is empty, since we pass the backend configs
# prod.tfbackend
resource_group_name = "rg-terraform"
storage_account_name = "mytfstateacc"
container_name = "tfstate"
key = "prod.tfstate"- Create
prod.tfbackendanddev.tfbackendfor example
az group create --name rg-terraform --location switzerlandnorth- Resource group for the storage account that will store the remote state
az storage account create \
--name mytfstateacc \
--resource-group rg-terraform \
--location switzerlandnorth \
--sku Standard_LRS
az storage container create \
--name tfstate \
--account-name mytfstateaccterraform init -backend-config="prod.tfbackend"- Very useful for simple CI/CD pipeline using GitHub actions
- Tags are a simple way of tracking software version (releases)
git tag v1.0.2- You can tag a specific commit on any branch
git push origin v1.0.2- This pushes the code marked by your tag to GitHub
git tag -d v1.0.2
git push -d origin v1.0.2docker run -it --rm --name mercury-api -p 8000:8000 -v $(pwd):/app mercury-app-v $(pwd):/appmounts the current working directory in the container's app directory- This allows us to comment out the
COPY . .in the Dockerfile during development - Command already pretty verbose, Docker Compose cleaner