Skip to content
This repository has been archived by the owner on Jan 23, 2024. It is now read-only.

Update container registry to artifactory #463

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
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
17 changes: 6 additions & 11 deletions bq-workers/parsers.cloudbuild.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,15 @@

steps:
- # Build parser image
name: gcr.io/cloud-builders/docker:latest
name: gcr.io/cloud-builders/docker
dir: ${_SERVICE}-parser
args: ['build',
'--tag=gcr.io/$PROJECT_ID/${_SERVICE}-parser:${_TAG}', '.']
args: ['build', '-t',
'${_REGION}-docker.pkg.dev/$PROJECT_ID/${_SERVICE}-parser/parser:${_TAG}', '.']
id: build

- # Push the container image to Container Registry
name: gcr.io/cloud-builders/docker
args: ['push', 'gcr.io/$PROJECT_ID/${_SERVICE}-parser:${_TAG}']
waitFor: build
id: push
# Push the container image to Artifact Registry
images:
- '${_REGION}-docker.pkg.dev/$PROJECT_ID/${_SERVICE}-parser/parser:${_TAG}'

images: [
'gcr.io/$PROJECT_ID/${_SERVICE}-parser:${_TAG}'
]
substitutions:
_TAG: latest
13 changes: 6 additions & 7 deletions dashboard/cloudbuild.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,14 @@

steps:
- # Build grafana image
name: gcr.io/cloud-builders/docker:latest
args: ['build', '--tag',
'gcr.io/$PROJECT_ID/fourkeys-grafana-dashboard:${_TAG}', '.']
name: gcr.io/cloud-builders/docker
args: ['build', '-t',
'${_REGION}-docker.pkg.dev/$PROJECT_ID/dashboard/grafana:${_TAG}', '.']
id: build

- # Push the container image to Container Registry
name: gcr.io/cloud-builders/docker
args: ['push', 'gcr.io/$PROJECT_ID/fourkeys-grafana-dashboard:${_TAG}']
id: push
# Push the container image to Artifact Registry
images:
- '${_REGION}-docker.pkg.dev/$PROJECT_ID/dashboard/grafana:${_TAG}'

# Read more about substitutions
# https://cloud.google.com/build/docs/configuring-builds/substitute-variable-values
Expand Down
13 changes: 4 additions & 9 deletions event-handler/cloudbuild.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,12 @@
steps:
- # Build event_handler image
name: gcr.io/cloud-builders/docker:latest
args: ['build', '--tag=gcr.io/$PROJECT_ID/event-handler:${_TAG}', '.']
args: ['build', '-t', '${_REGION}-docker.pkg.dev/$PROJECT_ID/event-handler/handler:${_TAG}', '.']
id: build

- # Push the container image to Container Registry
name: gcr.io/cloud-builders/docker
args: ['push', 'gcr.io/$PROJECT_ID/event-handler:${_TAG}']
waitFor: build
id: push
# Push the container image to Artifact Registry
images:
- '${_REGION}-docker.pkg.dev/$PROJECT_ID/event-handler/handler:${_TAG}'

images: [
'gcr.io/$PROJECT_ID/event-handler:${_TAG}'
]
substitutions:
_TAG: latest
27 changes: 22 additions & 5 deletions setup/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,20 +25,37 @@ To deploy Four Keys with Terraform, you will first need:
export PROJECT_ID="YOUR_PROJECT_ID"
```

1. Set an environment variable indicating the region where you want to deploy the dashboard, event handler and parsers. You can find a list of available regions [here](https://cloud.google.com/artifact-registry/docs/repositories/repo-locations).
```sh
export GAR_REGION="ARTIFACT_REGISTRY_REGION"
```

1. Set an environment variable indicating the service name you want to use:
```sh
export SERVICE="SERVICE_NAME"
```

1. Create an artifact registry repository for the dashboard, event-handler and parsers:
```sh
gcloud artifacts repositories create dashboard --repository-format=docker --location=$GAR_REGION --project $PROJECT_ID && \
gcloud artifacts repositories create event-handler --repository-format=docker --location=$GAR_REGION --project $PROJECT_ID && \
gcloud artifacts repositories create ${SERVICE}-parser --repository-format=docker --location=$GAR_REGION --project $PROJECT_ID
```

1. Clone the fourkeys git repository and change into the root directory
```
git clone https://github.com/dora-team/fourkeys.git && cd fourkeys
```

1. Use Cloud Build to build and push containers to Google Container Registry for the dashboard, event-handler:
1. Use Cloud Build to build and push containers to Google Artifact Registry for the dashboard, event-handler:
```
gcloud builds submit dashboard --config=dashboard/cloudbuild.yaml --project $PROJECT_ID && \
gcloud builds submit event-handler --config=event-handler/cloudbuild.yaml --project $PROJECT_ID
gcloud builds submit dashboard --config=dashboard/cloudbuild.yaml --project $PROJECT_ID --substitutions=_REGION=$GAR_REGION && \
gcloud builds submit event-handler --config=event-handler/cloudbuild.yaml --project $PROJECT_ID --substitutions=_REGION=$GAR_REGION
```

1. Use Cloud Build to build and push containers to Google Container Registry for the parsers you plan to use. See the [`bq-workers`](../bq-workers/) for available options. GitHub for example:
1. Use Cloud Build to build and push containers to Google Artifact Registry for the parsers you plan to use. See the [`bq-workers`](../bq-workers/) for available options. GitHub for example:
```
gcloud builds submit bq-workers --config=bq-workers/parsers.cloudbuild.yaml --project $PROJECT_ID --substitutions=_SERVICE=github
gcloud builds submit bq-workers --config=bq-workers/parsers.cloudbuild.yaml --project $PROJECT_ID --substitutions=_SERVICE=$SERVICE,_REGION=$GAR_REGION
```

1. Change your working directory to `terraform/example` and rename `terraform.tfvars.example` to `terraform.tfvars`
Expand Down
12 changes: 6 additions & 6 deletions terraform/example/main.tf
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
module "fourkeys" {
source = "../modules/fourkeys"
project_id = var.project_id
enable_apis = var.enable_apis
region = var.region
bigquery_region = var.bigquery_region
parsers = var.parsers
source = "../modules/fourkeys"
project_id = var.project_id
enable_apis = var.enable_apis
region = var.region
bigquery_region = var.bigquery_region
parsers = var.parsers
}
10 changes: 5 additions & 5 deletions terraform/example/variables.tf
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
variable "project_id" {
type = string
description = "project to deploy four keys resources to"
type = string
description = "project to deploy four keys resources to"
}

variable "enable_apis" {
Expand All @@ -10,9 +10,9 @@ variable "enable_apis" {
}

variable "region" {
type = string
default = "us-central1"
description = "Region to deploy four keys resources in."
type = string
default = "us-central1"
description = "Region to deploy four keys resources in."
}

variable "bigquery_region" {
Expand Down
8 changes: 4 additions & 4 deletions terraform/modules/fourkeys-circleci-parser/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ locals {
}

resource "google_project_service" "data_source_services" {
project = var.project_id
for_each = toset(local.services)
service = each.value
disable_on_destroy = false
project = var.project_id
for_each = toset(local.services)
service = each.value
disable_on_destroy = false
}

resource "google_cloud_run_service" "circleci_parser" {
Expand Down
10 changes: 5 additions & 5 deletions terraform/modules/fourkeys-circleci-parser/variables.tf
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
variable "project_id" {
type = string
type = string
description = "Project ID of the target project."
}

variable "region" {
type = string
type = string
description = "Region to deploy resources."
default = "us-central1"
default = "us-central1"
}

variable "fourkeys_service_account_email" {
type = string
type = string
description = "Service account for fourkeys."
}

Expand All @@ -21,6 +21,6 @@ variable "enable_apis" {
}

variable "parser_container_url" {
type = string
type = string
description = "URL of image to use in Cloud Run service configuration."
}
8 changes: 4 additions & 4 deletions terraform/modules/fourkeys-cloud-build-parser/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ locals {
}

resource "google_project_service" "data_source_services" {
project = var.project_id
for_each = toset(local.services)
service = each.value
disable_on_destroy = false
project = var.project_id
for_each = toset(local.services)
service = each.value
disable_on_destroy = false
}

resource "google_cloud_run_service" "cloudbuild_parser" {
Expand Down
10 changes: 5 additions & 5 deletions terraform/modules/fourkeys-cloud-build-parser/variables.tf
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
variable "project_id" {
type = string
type = string
description = "Project ID of the target project."
}

variable "region" {
type = string
type = string
description = "Region to deploy resources."
default = "us-central1"
default = "us-central1"
}

variable "fourkeys_service_account_email" {
type = string
type = string
description = "Service account for fourkeys."
}

Expand All @@ -21,6 +21,6 @@ variable "enable_apis" {
}

variable "parser_container_url" {
type = string
type = string
description = "URL of image to use in Cloud Run service configuration."
}
8 changes: 4 additions & 4 deletions terraform/modules/fourkeys-github-parser/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ locals {
}

resource "google_project_service" "data_source_services" {
project = var.project_id
for_each = toset(local.services)
service = each.value
disable_on_destroy = false
project = var.project_id
for_each = toset(local.services)
service = each.value
disable_on_destroy = false
}

resource "google_cloud_run_service" "github_parser" {
Expand Down
10 changes: 5 additions & 5 deletions terraform/modules/fourkeys-github-parser/variables.tf
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
variable "project_id" {
type = string
type = string
description = "Project ID of the target project."
}

variable "region" {
type = string
type = string
description = "Region to deploy resources."
default = "us-central1"
default = "us-central1"
}

variable "fourkeys_service_account_email" {
type = string
type = string
description = "Service account for fourkeys."
}

Expand All @@ -21,6 +21,6 @@ variable "enable_apis" {
}

variable "parser_container_url" {
type = string
type = string
description = "URL of image to use in Cloud Run service configuration."
}
10 changes: 5 additions & 5 deletions terraform/modules/fourkeys-gitlab-parser/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ locals {
}

resource "google_project_service" "data_source_services" {
project = var.project_id
for_each = toset(local.services)
service = each.value
disable_on_destroy = false
project = var.project_id
for_each = toset(local.services)
service = each.value
disable_on_destroy = false
}

resource "google_cloud_run_service" "gitlab_parser" {
Expand Down Expand Up @@ -72,7 +72,7 @@ resource "google_pubsub_subscription" "gitlab" {
project = var.project_id
name = "gitlab"
topic = google_pubsub_topic.gitlab.id

expiration_policy {
ttl = ""
}
Expand Down
10 changes: 5 additions & 5 deletions terraform/modules/fourkeys-gitlab-parser/variables.tf
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
variable "project_id" {
type = string
type = string
description = "Project ID of the target project."
}

variable "region" {
type = string
type = string
description = "Region to deploy resources."
default = "us-central1"
default = "us-central1"
}

variable "fourkeys_service_account_email" {
type = string
type = string
description = "Service account for fourkeys."
}

Expand All @@ -21,6 +21,6 @@ variable "enable_apis" {
}

variable "parser_container_url" {
type = string
type = string
description = "URL of image to use in Cloud Run service configuration."
}
10 changes: 5 additions & 5 deletions terraform/modules/fourkeys-pagerduty-parser/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ locals {
}

resource "google_project_service" "data_source_services" {
project = var.project_id
for_each = toset(local.services)
service = each.value
disable_on_destroy = false
project = var.project_id
for_each = toset(local.services)
service = each.value
disable_on_destroy = false
}

resource "google_cloud_run_service" "pagerduty_parser" {
Expand All @@ -37,7 +37,7 @@ resource "google_cloud_run_service" "pagerduty_parser" {
percent = 100
latest_revision = true
}

metadata {
annotations = {
"run.googleapis.com/ingress" = "internal"
Expand Down
10 changes: 5 additions & 5 deletions terraform/modules/fourkeys-pagerduty-parser/variables.tf
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
variable "project_id" {
type = string
type = string
description = "Project ID of the target project."
}

variable "region" {
type = string
type = string
description = "Region to deploy resources."
default = "us-central1"
default = "us-central1"
}

variable "fourkeys_service_account_email" {
type = string
type = string
description = "Service account for fourkeys."
}

Expand All @@ -21,6 +21,6 @@ variable "enable_apis" {
}

variable "parser_container_url" {
type = string
type = string
description = "URL of image to use in Cloud Run service configuration."
}
Loading