A personal project aimed to further advance my skills with docker, github actions and terraform. The app functionality is very basic as python development isn't the main thing for this project.
%%{init: {'theme':'dark'}}%%
flowchart TB;
app-code(Python app)
pytest(Pytest)
Dockerfile((Dockerfile))
sa[[Service Account]]
registry[[Artifact Registry]]
cloud-run[[Cloud Run Job]]
subgraph Terraform
sa
registry
cloud-run
end
subgraph Local
app-code
pytest
Dockerfile
end
subgraph GCP
artifact-reg[Artifact Registry]
cloud-run-job[Cloud run job]
end
Local --On: Push to main--> Image[Build and push docker image]
Terraform --On: Push to main--> tf-apply[Plan and apply terraform specification]
tf-apply --> GCP
Image --> artifact-reg
artifact-reg --- cloud-run-job
The application consists of two functions.
- Randomize and number between 1 and 100.
- Square this number and return that as the output of the app.
Nothing groundbreaking here, and I think it's safe to assume that I may be the first developer to be replaced by AI...
A test is also built in with pytest to assert that the function square-number
works as intended.
The python app is containerized with docker. The Dockerfile
and docker-compose.yml
specifies this process.
This spins up a cloud environment where the python app can be run. Service account, artifact registry and a cloud run job is being specified and applied upon push to main.
Three actions are used.
Performs the pytests with every push, regardless of branch.
With every pull request, we perform these actions to make sure that things work as intended.
When a pull request has been approved and gets merged into main, we want to update our production environment accordingly. This is being done with terraform and docker. Our GCP environment has been updated.