diff --git a/DEVELOPMENT.md b/DEVELOPMENT.md deleted file mode 100644 index 1a5255e..0000000 --- a/DEVELOPMENT.md +++ /dev/null @@ -1,18 +0,0 @@ -# Deploy - -``` -export KO_DOCKER_REPO=gcr.io/kontaindotme -``` - -Build all images - -``` -ls cmd/ | xargs -I{} ko publish -P -t latest ./cmd/{} -``` - -Deploy services - -``` -terraform apply -``` - diff --git a/deploy.sh b/deploy.sh new file mode 100755 index 0000000..d88d69d --- /dev/null +++ b/deploy.sh @@ -0,0 +1,21 @@ +#!/usr/bin/env bash + +set -euxo pipefail + +export KO_DOCKER_REPO=gcr.io/kontaindotme +out=$(mktemp -d)/tmp.tfvars + +echo writing to $out + +echo "images = {" > $out +cd cmd +for d in *; do + echo " \"$d\" = \"$(ko publish -P ./$d)\"" >> $out +done +echo "}" >> $out + +cat $out + +cd - + +terraform apply -var-file=kontainme.tfvars -var-file=$out diff --git a/kontainme.tf b/kontainme.tf index af7f817..fa81b01 100644 --- a/kontainme.tf +++ b/kontainme.tf @@ -15,12 +15,12 @@ provider "google" { ////// Variables -variable "image-prefix" { +variable "project" { type = string - default = "gcr.io/kontaindotme/github.com/imjasonh/kontain.me/cmd/" + default = "kontaindotme" } -variable "project" { +variable "bucket" { type = string default = "kontaindotme" } @@ -30,9 +30,9 @@ variable "region" { default = "us-central1" } -variable "bucket" { - type = string - default = "kontaindotme" +variable "images" { + type = map(string) + description = "images to deploy" } variable "services" { @@ -43,64 +43,13 @@ variable "services" { timeout = string })) description = "services to deploy" - - default = { - "api" = { - memory = "2Gi" - cpu = "1" - concurrency = "1" - timeout = "300" # 5m - } - "buildpack" = { - memory = "4Gi" - cpu = "2" - concurrency = "1" - timeout = "900" # 15m - } - "flatten" = { - memory = "1Gi" - cpu = "1" - concurrency = "80" - timeout = "60" # 1m - } - "ko" = { - memory = "4Gi" - cpu = "2" - concurrency = "1" - timeout = "900" # 15m - } - "mirror" = { - memory = "1Gi" - cpu = "1" - concurrency = "80" - timeout = "60" # 1m - } - "random" = { - memory = "1Gi" - cpu = "1" - concurrency = "80" - timeout = "60" # 1m - } - "viz" = { - memory = "1Gi" - cpu = "1" - concurrency = "80" - timeout = "60" # 1m - } - "flatten" = { - memory = "1Gi" - cpu = "1" - concurrency = "80" - timeout = "60" # 1m - } - } } ////// Cloud Storage resource "google_storage_bucket" "bucket" { - name = var.bucket - location = "US" + name = var.bucket + location = "US" uniform_bucket_level_access = false @@ -134,7 +83,7 @@ resource "google_cloud_run_service" "services" { spec { timeout_seconds = each.value.timeout containers { - image = "${var.image-prefix}${each.key}" + image = var.images[each.key] env { name = "BUCKET" value = var.bucket @@ -142,7 +91,7 @@ resource "google_cloud_run_service" "services" { resources { limits = { memory = each.value.memory - cpu = each.value.cpu + cpu = each.value.cpu } } } @@ -169,6 +118,8 @@ resource "google_cloud_run_service_iam_member" "allUsers" { depends_on = [google_cloud_run_service.services] } +// TODO: Ensure domain mappings. + output "services" { value = { for svc in google_cloud_run_service.services :