From 5b030a7d9236c4339ccd361da1eeadcd35c0f716 Mon Sep 17 00:00:00 2001 From: Henry Avetisyan Date: Thu, 17 Oct 2024 18:03:23 -0700 Subject: [PATCH] docker build fixes for go 1.22 - no GO111MODULE support (#2771) Signed-off-by: Henry Avetisyan --- .github/workflows/docker-build-publish.yaml | 4 ---- docker/util/Dockerfile | 5 ++--- docker/util/athenz-mvn-base/Dockerfile | 7 ------- docker/util/rdl-athenz-go-model/Dockerfile | 8 ++++---- docker/util/rdl-athenz-java-client/Dockerfile | 8 ++++---- docker/util/rdl-athenz-java-model/Dockerfile | 8 ++++---- docker/util/rdl-athenz-server/Dockerfile | 8 ++++---- go.mod | 1 + go.sum | 4 ++++ 9 files changed, 23 insertions(+), 30 deletions(-) diff --git a/.github/workflows/docker-build-publish.yaml b/.github/workflows/docker-build-publish.yaml index cbb28c3f696..47b3a9bea7d 100644 --- a/.github/workflows/docker-build-publish.yaml +++ b/.github/workflows/docker-build-publish.yaml @@ -98,10 +98,6 @@ jobs: architecture: ${{ env.JAVA_ARCH }} cache: 'maven' - # - name: Build with Maven - # id: build-maven - # run: mvn --batch-mode --update-snapshots package -DskipTests=true - - name: Extract Docker metadata id: meta uses: docker/metadata-action@v4 diff --git a/docker/util/Dockerfile b/docker/util/Dockerfile index e18a139f8d4..45636b26233 100644 --- a/docker/util/Dockerfile +++ b/docker/util/Dockerfile @@ -40,13 +40,12 @@ RUN addgroup --system --gid ${GID} athenz-utils && \ adduser --system --disabled-password --no-create-home --shell /sbin/nologin --uid ${UID} --ingroup athenz-utils athenz-utils # fix to have rdl binary available to be used by client generators. -RUN GO111MODULE=off go get -u github.com/ardielle/ardielle-tools/... \ +RUN go install github.com/ardielle/ardielle-tools/...@latest \ && mkdir -p /root/go/src/github.com/AthenZ/athenz/clients/go/zms/bin && cp /root/go/bin/rdl /root/go/src/github.com/AthenZ/athenz/clients/go/zms/bin \ && mkdir -p /root/go/src/github.com/AthenZ/athenz/clients/go/zts/bin && cp /root/go/bin/rdl /root/go/src/github.com/AthenZ/athenz/clients/go/zts/bin \ && mkdir -p /root/go/src/github.com/AthenZ/athenz/clients/go/msd/bin && cp /root/go/bin/rdl /root/go/src/github.com/AthenZ/athenz/clients/go/msd/bin -RUN GO111MODULE=on \ - CGO_ENABLED=0 \ +RUN CGO_ENABLED=0 \ CGO_CXXFLAGS="-g -Ofast -march=native" \ CGO_FFLAGS="-g -Ofast -march=native" \ CGO_LDFLAGS="-g -Ofast -march=native" \ diff --git a/docker/util/athenz-mvn-base/Dockerfile b/docker/util/athenz-mvn-base/Dockerfile index e5428ed78aa..1e7ddf03cdc 100644 --- a/docker/util/athenz-mvn-base/Dockerfile +++ b/docker/util/athenz-mvn-base/Dockerfile @@ -34,7 +34,6 @@ COPY --from=rdl-go-model /usr/bin/rdl-gen-athenz-go-model /usr/bin/rdl-gen-athen # copy pom.xml WORKDIR /athenz COPY pom.xml . -# cat pom.xml | grep ".*" | awk -F'[><]' '{ printf "COPY ./%s/pom.xml ./%s/pom.xml\n", $3, $3 }' COPY ./rdl/rdl-gen-athenz-server/pom.xml ./rdl/rdl-gen-athenz-server/pom.xml COPY ./rdl/rdl-gen-athenz-go-model/pom.xml ./rdl/rdl-gen-athenz-go-model/pom.xml COPY ./rdl/rdl-gen-athenz-go-client/pom.xml ./rdl/rdl-gen-athenz-go-client/pom.xml @@ -86,10 +85,4 @@ COPY ./assembly/zts/pom.xml ./assembly/zts/pom.xml COPY ./assembly/ui/pom.xml ./assembly/ui/pom.xml COPY ./assembly/utils/pom.xml ./assembly/utils/pom.xml -# RUN mvn -U -B dependency:resolve --fail-never -# RUN mvn -U -B dependency:resolve --fail-never -DexcludeGroupIds=com.yahoo.athenz - RUN mvn -U -B dependency:go-offline --fail-never -DdockerBuild=true -# RUN mvn -U -B dependency:go-offline --fail-never -DexcludeGroupIds=com.yahoo.athenz - -# docker run -it --name athenz-base-mvn athenz-base-mvn sh; docker rm athenz-base-mvn diff --git a/docker/util/rdl-athenz-go-model/Dockerfile b/docker/util/rdl-athenz-go-model/Dockerfile index ad8ae2d88f9..cd8db7e7c21 100644 --- a/docker/util/rdl-athenz-go-model/Dockerfile +++ b/docker/util/rdl-athenz-go-model/Dockerfile @@ -7,12 +7,14 @@ RUN set -eux && apt-get update \ WORKDIR ${GOPATH}/src/github.com/AthenZ/athenz/rdl/rdl-gen-athenz-go-model -RUN GO111MODULE=off go get -u github.com/ardielle/ardielle-go/... \ - && GO111MODULE=off go get -u github.com/ardielle/ardielle-tools/... \ +RUN go install github.com/ardielle/ardielle-tools/...@latest \ && mv ${GOPATH}/bin/rdl /usr/bin/rdl COPY . . +RUN go mod init github.com/AthenZ/athenz/rdl/rdl-gen-athenz-go-model \ + && go get -u github.com/ardielle/ardielle-go/... + RUN if [ $(go env GOARCH) = "amd64" ]; then \ CGO_ENABLED=1 \ CGO_CXXFLAGS="-g -Ofast -march=native" \ @@ -20,7 +22,6 @@ RUN if [ $(go env GOARCH) = "amd64" ]; then \ CGO_LDFLAGS="-g -Ofast -march=native" \ GOOS=$(go env GOOS) \ GOARCH=$(go env GOARCH) \ - GO111MODULE=off \ go build --ldflags '-s -w -linkmode "external" -extldflags "-static -fPIC -m64 -pthread -std=c++11 -lstdc++"' -a -tags "cgo netgo" -installsuffix "cgo netgo" -o "${APP_NAME}" \ && upx -9 -o "/usr/bin/${APP_NAME}" "${APP_NAME}"; \ elif [ $(go env GOARCH) = "arm64" ]; then \ @@ -30,7 +31,6 @@ RUN if [ $(go env GOARCH) = "amd64" ]; then \ CGO_LDFLAGS="-g -Ofast -march=native" \ GOOS=$(go env GOOS) \ GOARCH=$(go env GOARCH) \ - GO111MODULE=off \ go build --ldflags '-s -w -linkmode "external" -extldflags "-static -fPIC -march=armv8-a -pthread -std=c++11 -lstdc++"' -a -tags "cgo netgo" -installsuffix "cgo netgo" -o "${APP_NAME}" \ && upx -9 -o "/usr/bin/${APP_NAME}" "${APP_NAME}"; \ fi diff --git a/docker/util/rdl-athenz-java-client/Dockerfile b/docker/util/rdl-athenz-java-client/Dockerfile index 4230c4099d8..e40e1c2fc25 100644 --- a/docker/util/rdl-athenz-java-client/Dockerfile +++ b/docker/util/rdl-athenz-java-client/Dockerfile @@ -7,12 +7,14 @@ RUN set -eux && apt-get update \ WORKDIR ${GOPATH}/src/github.com/AthenZ/athenz/rdl/rdl-gen-athenz-java-client -RUN GO111MODULE=off go get -u github.com/ardielle/ardielle-go/... \ - && GO111MODULE=off go get -u github.com/ardielle/ardielle-tools/... \ +RUN go install github.com/ardielle/ardielle-tools/...@latest \ && mv ${GOPATH}/bin/rdl /usr/bin/rdl COPY . . +RUN go mod init github.com/AthenZ/athenz/rdl/rdl-gen-athenz-java-client \ + && go get -u github.com/ardielle/ardielle-go/... + RUN if [ $(go env GOARCH) = "amd64" ]; then \ CGO_ENABLED=1 \ CGO_CXXFLAGS="-g -Ofast -march=native" \ @@ -20,7 +22,6 @@ RUN if [ $(go env GOARCH) = "amd64" ]; then \ CGO_LDFLAGS="-g -Ofast -march=native" \ GOOS=$(go env GOOS) \ GOARCH=$(go env GOARCH) \ - GO111MODULE=off \ go build --ldflags '-s -w -linkmode "external" -extldflags "-static -fPIC -m64 -pthread -std=c++11 -lstdc++"' -a -tags "cgo netgo" -installsuffix "cgo netgo" -o "${APP_NAME}" \ && upx -9 -o "/usr/bin/${APP_NAME}" "${APP_NAME}"; \ elif [ $(go env GOARCH) = "arm64" ]; then \ @@ -30,7 +31,6 @@ RUN if [ $(go env GOARCH) = "amd64" ]; then \ CGO_LDFLAGS="-g -Ofast -march=native" \ GOOS=$(go env GOOS) \ GOARCH=$(go env GOARCH) \ - GO111MODULE=off \ go build --ldflags '-s -w -linkmode "external" -extldflags "-static -fPIC -march=armv8-a -pthread -std=c++11 -lstdc++"' -a -tags "cgo netgo" -installsuffix "cgo netgo" -o "${APP_NAME}" \ && upx -9 -o "/usr/bin/${APP_NAME}" "${APP_NAME}"; \ fi diff --git a/docker/util/rdl-athenz-java-model/Dockerfile b/docker/util/rdl-athenz-java-model/Dockerfile index 33c865faa00..92c5788ddcc 100644 --- a/docker/util/rdl-athenz-java-model/Dockerfile +++ b/docker/util/rdl-athenz-java-model/Dockerfile @@ -7,12 +7,14 @@ RUN set -eux && apt-get update \ WORKDIR ${GOPATH}/src/github.com/AthenZ/athenz/rdl/rdl-gen-athenz-java-model -RUN GO111MODULE=off go get -u github.com/ardielle/ardielle-go/... \ - && GO111MODULE=off go get -u github.com/ardielle/ardielle-tools/... \ +RUN go install github.com/ardielle/ardielle-tools/...@latest \ && mv ${GOPATH}/bin/rdl /usr/bin/rdl COPY . . +RUN go mod init github.com/AthenZ/athenz/rdl/rdl-gen-athenz-java-model \ + && go get -u github.com/ardielle/ardielle-go/... + RUN if [ $(go env GOARCH) = "amd64" ]; then \ CGO_ENABLED=1 \ CGO_CXXFLAGS="-g -Ofast -march=native" \ @@ -20,7 +22,6 @@ RUN if [ $(go env GOARCH) = "amd64" ]; then \ CGO_LDFLAGS="-g -Ofast -march=native" \ GOOS=$(go env GOOS) \ GOARCH=$(go env GOARCH) \ - GO111MODULE=off \ go build --ldflags '-s -w -linkmode "external" -extldflags "-static -fPIC -m64 -pthread -std=c++11 -lstdc++"' -a -tags "cgo netgo" -installsuffix "cgo netgo" -o "${APP_NAME}" \ && upx -9 -o "/usr/bin/${APP_NAME}" "${APP_NAME}"; \ elif [ $(go env GOARCH) = "arm64" ]; then \ @@ -30,7 +31,6 @@ RUN if [ $(go env GOARCH) = "amd64" ]; then \ CGO_LDFLAGS="-g -Ofast -march=native" \ GOOS=$(go env GOOS) \ GOARCH=$(go env GOARCH) \ - GO111MODULE=off \ go build --ldflags '-s -w -linkmode "external" -extldflags "-static -fPIC -march=armv8-a -pthread -std=c++11 -lstdc++"' -a -tags "cgo netgo" -installsuffix "cgo netgo" -o "${APP_NAME}" \ && upx -9 -o "/usr/bin/${APP_NAME}" "${APP_NAME}"; \ fi diff --git a/docker/util/rdl-athenz-server/Dockerfile b/docker/util/rdl-athenz-server/Dockerfile index 221ab34516b..4f95a6c0e16 100644 --- a/docker/util/rdl-athenz-server/Dockerfile +++ b/docker/util/rdl-athenz-server/Dockerfile @@ -7,12 +7,14 @@ RUN set -eux && apt-get update \ WORKDIR ${GOPATH}/src/github.com/AthenZ/athenz/rdl/rdl-gen-athenz-server -RUN GO111MODULE=off go get -u github.com/ardielle/ardielle-go/... \ - && GO111MODULE=off go get -u github.com/ardielle/ardielle-tools/... \ +RUN go install github.com/ardielle/ardielle-tools/...@latest \ && mv ${GOPATH}/bin/rdl /usr/bin/rdl COPY . . +RUN go mod init github.com/AthenZ/athenz/rdl/rdl-gen-athenz-server \ + && go get -u github.com/ardielle/ardielle-go/... + RUN if [ $(go env GOARCH) = "amd64" ]; then \ CGO_ENABLED=1 \ CGO_CXXFLAGS="-g -Ofast -march=native" \ @@ -20,7 +22,6 @@ RUN if [ $(go env GOARCH) = "amd64" ]; then \ CGO_LDFLAGS="-g -Ofast -march=native" \ GOOS=$(go env GOOS) \ GOARCH=$(go env GOARCH) \ - GO111MODULE=off \ go build --ldflags '-s -w -linkmode "external" -extldflags "-static -fPIC -m64 -pthread -std=c++11 -lstdc++"' -a -tags "cgo netgo" -installsuffix "cgo netgo" -o "${APP_NAME}" \ && upx -9 -o "/usr/bin/${APP_NAME}" "${APP_NAME}"; \ elif [ $(go env GOARCH) = "arm64" ]; then \ @@ -30,7 +31,6 @@ RUN if [ $(go env GOARCH) = "amd64" ]; then \ CGO_LDFLAGS="-g -Ofast -march=native" \ GOOS=$(go env GOOS) \ GOARCH=$(go env GOARCH) \ - GO111MODULE=off \ go build --ldflags '-s -w -linkmode "external" -extldflags "-static -fPIC -march=armv8-a -pthread -std=c++11 -lstdc++"' -a -tags "cgo netgo" -installsuffix "cgo netgo" -o "${APP_NAME}" \ && upx -9 -o "/usr/bin/${APP_NAME}" "${APP_NAME}"; \ fi diff --git a/go.mod b/go.mod index 5582768062d..bbb299eaa83 100644 --- a/go.mod +++ b/go.mod @@ -43,6 +43,7 @@ require ( cloud.google.com/go/compute v1.28.0 // indirect cloud.google.com/go/compute/metadata v0.5.0 // indirect cloud.google.com/go/iam v1.2.0 // indirect + github.com/ardielle/ardielle-tools v1.5.4 // indirect github.com/aws/aws-sdk-go v1.55.5 // indirect github.com/aws/aws-sdk-go-v2/credentials v1.17.28 // indirect github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.16.12 // indirect diff --git a/go.sum b/go.sum index f0a51899957..27f7679e6a7 100644 --- a/go.sum +++ b/go.sum @@ -14,6 +14,8 @@ cloud.google.com/go/secretmanager v1.14.1/go.mod h1:L+gO+u2JA9CCyXpSR8gDH0o8EV7i github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/ardielle/ardielle-go v1.5.2 h1:TilHTpHIQJ27R1Tl/iITBzMwiUGSlVfiVhwDNGM3Zj4= github.com/ardielle/ardielle-go v1.5.2/go.mod h1:I4hy1n795cUhaVt/ojz83SNVCYIGsAFAONtv2Dr7HUI= +github.com/ardielle/ardielle-tools v1.5.4 h1:2uL/7wZRUF4LGV7r2eTaaeyhkBoqdiqEitSXMd6k8F8= +github.com/ardielle/ardielle-tools v1.5.4/go.mod h1:oZN+JRMnqGiIhrzkRN9l26Cej9dEx4jeNG6A+AdkShk= github.com/aws/aws-sdk-go v1.55.5/go.mod h1:eRwEWoyTWFMVYVQzKMNHWP5/RV4xIUGMQfXQHfHkpNU= github.com/aws/aws-sdk-go-v2 v1.30.4 h1:frhcagrVNrzmT95RJImMHgabt99vkXGslubDaDagTk8= github.com/aws/aws-sdk-go-v2 v1.30.4/go.mod h1:CT+ZPWXbYrci8chcARI3OmI/qgd+f6WtuLOoaIA8PR0= @@ -125,6 +127,8 @@ github.com/googleapis/gax-go/v2 v2.13.0 h1:yitjD5f7jQHhyDsnhKEBU52NdvvdSeGzlAnDP github.com/googleapis/gax-go/v2 v2.13.0/go.mod h1:Z/fvTZXF8/uw7Xu5GuslPw+bplx6SS338j1Is2S+B7A= github.com/gorilla/mux v1.8.1 h1:TuBL49tXwgrFYWhqrNgrUNEY92u81SPhu7sTdzQEiWY= github.com/gorilla/mux v1.8.1/go.mod h1:AKf9I4AEqPTmMytcMc0KkNouC66V3BtZ4qD5fmWSiMQ= +github.com/jawher/mow.cli v1.0.4/go.mod h1:5hQj2V8g+qYmLUVWqu4Wuja1pI57M83EChYLVZ0sMKk= +github.com/jawher/mow.cli v1.2.0 h1:e6ViPPy+82A/NFF/cfbq3Lr6q4JHKT9tyHwTCcUQgQw= github.com/jawher/mow.cli v1.2.0/go.mod h1:y+pcA3jBAdo/GIZx/0rFjw/K2bVEODP9rfZOfaiq8Ko= github.com/jmespath/go-jmespath v0.4.0/go.mod h1:T8mJZnbsbmF+m6zOOFylbeCJqk5+pHWvzYPziyZiYoo= github.com/jmespath/go-jmespath/internal/testify v1.5.1/go.mod h1:L3OGu8Wl2/fWfCI6z80xFu9LTZmf1ZRjMHUOPmWr69U=