I have an application made of two compiled Go programs and a Terraformed test stack. There will be more functions and resources in the coming weeks. Maybe other technologies that will need other environments.
I want to do some CI/CD throughout the advancement of the project using Gitlab CI and am fairly new to it. I have seen online .gitlab-ci.yml templates for Golang (Go) OR Terraform (TF). I don't succeed at connecting the two in an optimal fashion. The standard way of doing things seems very sub-optimal to me.
My options:
- I could write a Dockerfile that installs Go & TF, turn this into an image and pull it as the root image of my pipeline. But this seems to be too monolithic (big Dockerfile).
- I could specify a Go root image and a stage image for TF. This would imply
- that I either re-pull TF at any of my stages where TF is needed. Which would mean long pulling/building time thus not eco(nomically/logically)-friendly
or
- that I don't decompose my TF CI process into multiple stages. But this would make my program harder to debug down the road. Think
terraform init ; terraform plan ; terraform apply ; terraform destroy
: I want to have these commands used in separate stages.
What are your suggestions on this matter ? How could I properly link the tech environments in Gitlab CI and keep building time low ? Is there a way where building time is low and where I don't rely on a big monolithic Dockerfile ?