Skip to content

Instantly share code, notes, and snippets.

@cejkyle
Created November 17, 2020 11:01
Show Gist options
  • Save cejkyle/e013b757bca86657200c3c18d5c54650 to your computer and use it in GitHub Desktop.
Save cejkyle/e013b757bca86657200c3c18d5c54650 to your computer and use it in GitHub Desktop.
# Pull the base terraform execution environment image from the Azure container registry.
FROM iacrepo.azurecr.io/terraform-exec-env
# setup argument which is used to pass and customise Terraform execution command
ARG terraform_cmd
# make folder where source code will be injected into
RUN mkdir -p /home/repo/
# set the working directly to this location
WORKDIR "/home/repo/"
# inject source code into container during build
COPY ./ /home/repo/
# initialise Terraform using a remote backend.
# Azure connection details for test subscription are stored in uat.tfvars
RUN /go/terraform-bundle/terraform init -backend-config uat.tfvars && \
/go/terraform-bundle/terraform validate
# set container to automatically run terraform when the container is run
ENTRYPOINT [ "/go/terraform-bundle/terraform"]
# allow custom arguments to be passed to terraform such as plan or apply
CMD [$terraform_cmd]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment