Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GCP CI Test #168

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions deployment/live/gcp/example-gcp/ci/terragrunt.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,5 @@ include "root" {
inputs = merge(
include.root.locals,
{
example_gcp_docker_image = "us-central1-docker.pkg.dev/trillian-tessera/docker-prod/example-gcp:latest"
log_origin = "example-gcp"
}
)
10 changes: 6 additions & 4 deletions deployment/live/gcp/example-gcp/terragrunt.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@ terraform {
}

locals {
env = path_relative_to_include()
project_id = get_env("GOOGLE_PROJECT", "trillian-tessera")
location = get_env("GOOGLE_REGION", "us-central1")
base_name = get_env("TESSERA_BASE_NAME", "${local.env}-example-gcp")
env = path_relative_to_include()
project_id = get_env("GOOGLE_PROJECT", "trillian-tessera")
location = get_env("GOOGLE_REGION", "us-central1")
base_name = get_env("TESSERA_BASE_NAME", "${local.env}-example-gcp")
example_gcp_docker_image = "us-central1-docker.pkg.dev/trillian-tessera/docker-${local.env}/example-gcp:latest"
log_origin = "example-gcp-${local.env}"
}

remote_state {
Expand Down
49 changes: 43 additions & 6 deletions deployment/modules/gcp/cloudbuild/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,14 @@ terraform {
resource "google_artifact_registry_repository" "docker" {
repository_id = "docker-${var.env}"
location = var.region
description = "Tessera example docker images"
description = "Tessera testing docker images"
format = "DOCKER"
}

locals {
artifact_repo = "${var.region}-docker.pkg.dev/${var.project_id}/${google_artifact_registry_repository.docker.name}"
example_gcp_docker_image = "${local.artifact_repo}/example-gcp"
conformance_gcp_docker_image = "${local.artifact_repo}/conformance-gcp"
hammer_docker_image = "${local.artifact_repo}/hammer"
}

resource "google_cloudbuild_trigger" "docker" {
Expand All @@ -44,22 +45,52 @@ resource "google_cloudbuild_trigger" "docker" {

build {
step {
id = "docker_build_hammer"
name = "gcr.io/cloud-builders/docker"
args = [
"build",
"-t", "${local.example_gcp_docker_image}:$SHORT_SHA",
"-t", "${local.example_gcp_docker_image}:latest",
"-f", "./cmd/example-gcp/Dockerfile",
"-t", "${local.hammer_docker_image}:$SHORT_SHA",
"-t", "${local.hammer_docker_image}:latest",
"-f", "./hammer/Dockerfile",
"."
]
wait_for = ["-"]
}
step {
id = "docker_build_conformance_gcp"
name = "gcr.io/cloud-builders/docker"
args = [
"build",
"-t", "${local.conformance_gcp_docker_image}:$SHORT_SHA",
"-t", "${local.conformance_gcp_docker_image}:latest",
"-f", "./cmd/conformance/gcp/Dockerfile",
"."
]
wait_for = ["-"]
}
step {
name = "gcr.io/cloud-builders/docker"
args = [
"push",
"--all-tags",
local.example_gcp_docker_image
local.conformance_gcp_docker_image
]
wait_for = ["docker_build_conformance_gcp"]
}
step {
id = "terraform_apply_conformance_ci"
name = "alpine/terragrunt"
entrypoint = "terragrunt"
args = [
"apply",
]
dir = "deployment/live/gcp/conformance/ci"
env = [
"TF_IN_AUTOMATION=1",
"TF_INPUT=false",
"TF_VAR_project_id=${var.project_id}"
]
wait_for = ["-"]
}
options {
logging = "CLOUD_LOGGING_ONLY"
Expand Down Expand Up @@ -95,3 +126,9 @@ resource "google_project_iam_member" "cloudrun_deployer" {
role = "roles/run.developer"
member = "serviceAccount:${google_service_account.cloudbuild_service_account.email}"
}

resource "google_storage_bucket_iam_member" "member" {
bucket = "${var.project_id}-cloudbuild-${var.env}-terraform-state"
role = "roles/storage.objectViewer"
member = "serviceAccount:${google_service_account.cloudbuild_service_account.email}"
}
6 changes: 3 additions & 3 deletions deployment/modules/gcp/cloudbuild/outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ output "cloudbuild_trigger_id" {
value = google_cloudbuild_trigger.docker.id
}

output "docker_image" {
description = "The address of the docker image that will be built"
value = local.example_gcp_docker_image
output "conformance_gcp_docker_image" {
description = "The address of the GCP conformance docker image that will be built"
value = local.conformance_gcp_docker_image
}
Loading