From 78572cc85ee7c79a68e66f9ab22e14da197377b4 Mon Sep 17 00:00:00 2001 From: Jamie Curnow Date: Mon, 9 Sep 2024 13:57:14 +1000 Subject: [PATCH] Fix gotools for non-amd64 --- docker/Dockerfile.acmesh-golang | 8 ++--- scripts/install-gotools | 57 +++++++++++++++++++++++++++++++++ 2 files changed, 59 insertions(+), 6 deletions(-) create mode 100755 scripts/install-gotools diff --git a/docker/Dockerfile.acmesh-golang b/docker/Dockerfile.acmesh-golang index 97e5e50..34bae20 100644 --- a/docker/Dockerfile.acmesh-golang +++ b/docker/Dockerfile.acmesh-golang @@ -29,15 +29,11 @@ RUN mkdir -p "$GOPATH/src" "$GOPATH/bin" \ && echo "====> ${TARGETPLATFORM}: $(go version)" WORKDIR /root - COPY ./files/.bashrc.acmesh-golang /root/.bashrc # Gotools -RUN cd /usr && wget -O- -nv https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s v1.56.2 -RUN go install github.com/kyoh86/richgo@latest \ - && go install github.com/mfridman/tparse@latest \ - && go install golang.org/x/vuln/cmd/govulncheck@latest \ - && rm -rf /root/.cache/go-build +COPY ./scripts/install-gotools /tmp/install-gotools +RUN /tmp/install-gotools LABEL org.label-schema.cmd="docker run --rm -ti nginxproxymanager/nginx-full:acmesh-golang" diff --git a/scripts/install-gotools b/scripts/install-gotools new file mode 100755 index 0000000..27c19a9 --- /dev/null +++ b/scripts/install-gotools @@ -0,0 +1,57 @@ +#!/bin/bash +set -e + +BLUE='\E[1;34m' +CYAN='\E[1;36m' +YELLOW='\E[1;33m' +GREEN='\E[1;32m' +RESET='\E[0m' + +GSA_VERSION=$(curl -sSfL "https://api.github.com/repos/Zxilly/go-size-analyzer/releases/latest" | jq -r '.tag_name') + +# Determine the correct binary file for the architecture given +case $TARGETPLATFORM in + linux/arm64) + ARCH=arm64 + ;; + + linux/arm/v7) + ARCH=arm + ;; + + *) + ARCH=amd64 + ;; +esac + +if [ "$ARCH" = "amd64" ]; then + echo -e "${BLUE}❯ ${CYAN}Installing golangci-lint ...${RESET}" + go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest + + echo -e "${BLUE}❯ ${CYAN}Installing richgo ...${RESET}" + go install github.com/kyoh86/richgo@latest + + echo -e "${BLUE}❯ ${CYAN}Installing govulncheck ...${RESET}" + go install golang.org/x/vuln/cmd/govulncheck@latest + + echo -e "${BLUE}❯ ${CYAN}Installing tparse ...${RESET}" + go install github.com/mfridman/tparse@latest + + echo -e "${BLUE}❯ ${CYAN}Installing go-junit-report ...${RESET}" + go install github.com/jstemmer/go-junit-report@latest + + echo -e "${BLUE}❯ ${CYAN}Installing go-test-coverage ...${RESET}" + go install github.com/vladopajic/go-test-coverage/v2@latest + + echo -e "${BLUE}❯ ${CYAN}Installing go-size-analyzer ...${RESET}" + wget -O "/tmp/go-size-analyzer_linux_${ARCH}.tar.gz" "https://github.com/Zxilly/go-size-analyzer/releases/download/${GSA_VERSION}/go-size-analyzer_linux_${ARCH}.tar.gz" + cd /usr/bin/ + tar -xzf "/tmp/go-size-analyzer_linux_${ARCH}.tar.gz" gsa + rm -rf "/tmp/go-size-analyzer_linux_${ARCH}.tar.gz" + + echo -e "${BLUE}❯ ${CYAN}Installing go-mod-upgrade ...${RESET}" + go install github.com/oligot/go-mod-upgrade@latest +fi + +rm -rf "$(go env GOPATH)/.cache/go-build" +echo -e "${BLUE}❯ ${GREEN}Tools install completed${RESET}"