From 47d5325230715cb01de0a8814a909cc11546859d Mon Sep 17 00:00:00 2001
From: dlorenc <dlorenc@google.com>
Date: Mon, 20 Dec 2021 07:21:15 -0600
Subject: [PATCH] Switch the trillian containers to multi-plat builds. (#547)

This also adds the ko targets for building them, and entries
to tools.go so go.mod recognizes these dependencies so we can build
them with ko.

Signed-off-by: Dan Lorenc <lorenc.d@gmail.com>
---
 Makefile            | 11 +++++++++++
 docker-compose.yml  |  5 +++--
 hack/tools/tools.go |  5 +++++
 3 files changed, 19 insertions(+), 2 deletions(-)

diff --git a/Makefile b/Makefile
index beae9a0..c496c4e 100644
--- a/Makefile
+++ b/Makefile
@@ -139,6 +139,17 @@ ko-local:
 		--tags $(GIT_VERSION) --tags $(GIT_HASH) --local \
 		github.com/sigstore/rekor/cmd/rekor-cli
 
+# This builds the trillian containers we rely on using ko for cross platform support
+.PHONY: ko-trillian
+ko-trillian:
+	LDFLAGS="$(SERVER_LDFLAGS)" GIT_HASH=$(GIT_HASH) GIT_VERSION=$(GIT_VERSION) \
+	ko publish --base-import-paths --bare \
+		--platform=all --tags $(GIT_VERSION) --tags $(GIT_HASH) \
+		github.com/google/trillian/cmd/trillian_log_signer
+	ko publish --base-import-paths --bare \
+		--platform=all --tags $(GIT_VERSION) --tags $(GIT_HASH) \
+		github.com/google/trillian/cmd/trillian_log_server
+
 
 ## --------------------------------------
 ## Tooling Binaries
diff --git a/docker-compose.yml b/docker-compose.yml
index 8ec602a..d436c92 100644
--- a/docker-compose.yml
+++ b/docker-compose.yml
@@ -16,6 +16,7 @@
 version: '3.4'
 services:
   mysql:
+    platform: linux/amd64
     image: gcr.io/trillian-opensource-ci/db_server:v1.4.0
     environment:
       - MYSQL_ROOT_PASSWORD=zaphod
@@ -45,7 +46,7 @@ services:
       retries: 3
       start_period: 5s
   trillian-log-server:
-    image: gcr.io/trillian-opensource-ci/log_server:v1.4.0
+    image: gcr.io/projectsigstore/trillian_log_server@sha256:f850a0defd089ea844822030c67ae05bc93c91168a7dd4aceb0b6648c39f696b
     command: [
       "--storage_system=mysql",
       "--mysql_uri=test:zaphod@tcp(mysql:3306)/test",
@@ -60,7 +61,7 @@ services:
     depends_on:
       - mysql
   trillian-log-signer:
-    image: gcr.io/trillian-opensource-ci/log_signer:v1.4.0
+    image: gcr.io/projectsigstore/trillian_log_signer@sha256:fe90d523f6617974f70878918e4b31d49b2b46a86024bb2d6b01d2bbfed8edbf
     command: [
       "--storage_system=mysql",
       "--mysql_uri=test:zaphod@tcp(mysql:3306)/test",
diff --git a/hack/tools/tools.go b/hack/tools/tools.go
index 9eed603..24561b8 100644
--- a/hack/tools/tools.go
+++ b/hack/tools/tools.go
@@ -1,3 +1,4 @@
+//go:build tools
 // +build tools
 
 // Copyright 2021 The Sigstore Authors.
@@ -24,4 +25,8 @@ import (
 	_ "github.com/dvyukov/go-fuzz/go-fuzz-build"
 	_ "github.com/dvyukov/go-fuzz/go-fuzz-dep"
 	_ "github.com/go-swagger/go-swagger/cmd/swagger"
+
+	// These are so we can build these two binaries into containers with ko
+	_ "github.com/google/trillian/cmd/trillian_log_server"
+	_ "github.com/google/trillian/cmd/trillian_log_signer"
 )
-- 
GitLab