From a586fc6705584b46d4d9138e78606c0e995585c7 Mon Sep 17 00:00:00 2001 From: David Rabkin Date: Mon, 5 Feb 2024 17:33:35 +0200 Subject: [PATCH 1/3] Make the Dockerfile platform-independent --- Dockerfile | 38 ++------------------------------------ go.mod | 2 +- 2 files changed, 3 insertions(+), 37 deletions(-) diff --git a/Dockerfile b/Dockerfile index 63f5664..998f748 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,47 +1,13 @@ -FROM registry.access.redhat.com/ubi8/ubi:8.9-1107.1706791207 AS build +FROM registry.access.redhat.com/ubi8/go-toolset:1.20.10-10 AS build ENV TNF_SRC_DIR=/usr/tnf - -# Install dependencies -RUN \ - mkdir ${TNF_SRC_DIR} \ - && dnf update --assumeyes --disableplugin=subscription-manager \ - && dnf install --assumeyes --disableplugin=subscription-manager \ - gcc \ - git \ - jq \ - cmake \ - wget \ - && dnf clean all --assumeyes --disableplugin=subscription-manager \ - && rm -rf /var/cache/yum - -# Install Go binary and set the PATH -ENV \ - GO_DL_URL=https://golang.org/dl \ - GO_BIN_TAR=go1.21.6.linux-amd64.tar.gz \ - GOPATH=/root/go -ENV GO_BIN_URL_x86_64=${GO_DL_URL}/${GO_BIN_TAR} -RUN \ - if [ "$(uname -m)" = x86_64 ]; then \ - wget --directory-prefix=${TEMP_DIR} ${GO_BIN_URL_x86_64} --quiet \ - && rm -rf /usr/local/go \ - && tar -C /usr/local -xzf ${TEMP_DIR}/${GO_BIN_TAR}; \ - else \ - echo "CPU architecture is not supported." && exit 1; \ - fi -ENV PATH=${PATH}:"/usr/local/go/bin":${GOPATH}/"bin" - -# Build the application -COPY . ${TNF_SRC_DIR} +COPY --chown=1001:1001 . ${TNF_SRC_DIR} WORKDIR ${TNF_SRC_DIR} RUN make build # Copy the app into an empty ubi minimal image. FROM registry.access.redhat.com/ubi8-minimal:8.9-1108.1706691034 ENV TNF_SRC_DIR=/usr/tnf -RUN mkdir ${TNF_SRC_DIR} - COPY --from=build ${TNF_SRC_DIR}/schemas ${TNF_SRC_DIR}/schemas COPY --from=build ${TNF_SRC_DIR}/gradetool ${TNF_SRC_DIR} - WORKDIR ${TNF_SRC_DIR} ENTRYPOINT ["./gradetool"] diff --git a/go.mod b/go.mod index 1244258..a5dce55 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/test-network-function/gradetool -go 1.21.6 +go 1.21 require ( github.com/spf13/cobra v1.8.0 From a0bea34c6400078d586282b9e4ab0483bfff3c5d Mon Sep 17 00:00:00 2001 From: David Rabkin Date: Mon, 5 Feb 2024 19:04:47 +0200 Subject: [PATCH 2/3] Use latest golang image --- Dockerfile | 9 +++++---- go.mod | 2 +- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/Dockerfile b/Dockerfile index 998f748..9bd444b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,13 +1,14 @@ -FROM registry.access.redhat.com/ubi8/go-toolset:1.20.10-10 AS build +FROM golang:1.21.6-alpine AS builder ENV TNF_SRC_DIR=/usr/tnf -COPY --chown=1001:1001 . ${TNF_SRC_DIR} +RUN apk add --no-cache make~=4.4.1 +COPY . ${TNF_SRC_DIR} WORKDIR ${TNF_SRC_DIR} RUN make build # Copy the app into an empty ubi minimal image. FROM registry.access.redhat.com/ubi8-minimal:8.9-1108.1706691034 ENV TNF_SRC_DIR=/usr/tnf -COPY --from=build ${TNF_SRC_DIR}/schemas ${TNF_SRC_DIR}/schemas -COPY --from=build ${TNF_SRC_DIR}/gradetool ${TNF_SRC_DIR} +COPY --from=builder ${TNF_SRC_DIR}/schemas ${TNF_SRC_DIR}/schemas +COPY --from=builder ${TNF_SRC_DIR}/gradetool ${TNF_SRC_DIR} WORKDIR ${TNF_SRC_DIR} ENTRYPOINT ["./gradetool"] diff --git a/go.mod b/go.mod index a5dce55..1244258 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/test-network-function/gradetool -go 1.21 +go 1.21.6 require ( github.com/spf13/cobra v1.8.0 From 15cae8c294d2a7624dfc2a92d36465bc9eee034a Mon Sep 17 00:00:00 2001 From: David Rabkin Date: Mon, 5 Feb 2024 19:07:52 +0200 Subject: [PATCH 3/3] Run Github CI on M1 --- .github/workflows/pre-main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pre-main.yml b/.github/workflows/pre-main.yml index f9498dc..467fbe1 100644 --- a/.github/workflows/pre-main.yml +++ b/.github/workflows/pre-main.yml @@ -13,7 +13,7 @@ jobs: runs-on: ${{ matrix.os }} strategy: matrix: - os: [ubuntu-22.04, macos-latest] + os: [ubuntu-22.04, macos-latest, macos-14] env: SHELL: /bin/bash