From 7e405a17906f78c87d178e29741521d0edd2b3c4 Mon Sep 17 00:00:00 2001
From: Justin Kolberg <amd.prophet@gmail.com>
Date: Mon, 25 Sep 2023 11:30:00 -0700
Subject: [PATCH] chore(ci): add build-fips make target

Signed-off-by: Justin Kolberg <amd.prophet@gmail.com>
---
 ci/build-fips-action/Dockerfile    | 4 ++++
 ci/build-fips-action/entrypoint.sh | 7 -------
 otelcolbuilder/Makefile            | 5 +++++
 3 files changed, 9 insertions(+), 7 deletions(-)

diff --git a/ci/build-fips-action/Dockerfile b/ci/build-fips-action/Dockerfile
index b68a566372..d238cbe64b 100644
--- a/ci/build-fips-action/Dockerfile
+++ b/ci/build-fips-action/Dockerfile
@@ -6,6 +6,10 @@ ENV TARGETARCH=$TARGETARCH
 
 RUN yum groupinstall -y "Development Tools" && yum install -y curl git
 
+RUN curl -Lo go.tar.gz https://go.dev/dl/go1.20.5.linux-$TARGETARCH.tar.gz
+RUN tar -zxvf go.tar.gz -C /usr/local
+ENV PATH="/usr/local/go/bin:${PATH}"
+
 COPY entrypoint.sh /entrypoint.sh
 
 ENTRYPOINT ["/entrypoint.sh"]
diff --git a/ci/build-fips-action/entrypoint.sh b/ci/build-fips-action/entrypoint.sh
index f27f2cb6e6..d307fa68ee 100755
--- a/ci/build-fips-action/entrypoint.sh
+++ b/ci/build-fips-action/entrypoint.sh
@@ -2,13 +2,6 @@
 
 git config --global --add safe.directory /github/workspace
 
-# Install Go
-url="https://go.dev/dl/go${GO_VERSION}.linux-${TARGETARCH}.tar.gz"
-echo "Downloading ${url}"
-curl -Lo go.tar.gz "$url"
-tar -zxvf go.tar.gz -C /usr/local
-export PATH="/usr/local/go/bin:${PATH}"
-
 # Install builder
 cd otelcolbuilder || exit 1
 mkdir "${HOME}/bin"
diff --git a/otelcolbuilder/Makefile b/otelcolbuilder/Makefile
index e3f1bad954..e6df0b2a13 100644
--- a/otelcolbuilder/Makefile
+++ b/otelcolbuilder/Makefile
@@ -134,6 +134,11 @@ build-debug: ensure-correct-builder-version
 	@$(MAKE) generate-sources
 	@$(MAKE) _gobuild_debug
 
+.PHONY: build-fips
+build-fips:
+	docker build --platform linux/amd64	-t otelcol-sumo-builder-fips -f ../ci/build-fips-action/Dockerfile ../ci/build-fips-action
+	docker run -it --platform linux/amd64 --rm -v $(PWD)/../:/github/workspace -w /github/workspace --tmpfs /tmp otelcol-sumo-builder-fips
+
 .PHONY: generate-sources
 generate-sources:
 	@$(MAKE) _builder SKIP_COMPILATION=true