From f5c2f771702e84d377b5dada216eefc72ac66847 Mon Sep 17 00:00:00 2001 From: Tarak Ben Youssef Date: Wed, 10 Jan 2024 20:27:11 +0100 Subject: [PATCH 01/26] delete relic dockerfile and enable cgo --- cmd/emulator/Dockerfile | 2 +- cmd/emulator/Dockerfile.relic | 55 ----------------------------------- 2 files changed, 1 insertion(+), 56 deletions(-) delete mode 100644 cmd/emulator/Dockerfile.relic diff --git a/cmd/emulator/Dockerfile b/cmd/emulator/Dockerfile index f378819b..aecf8aef 100644 --- a/cmd/emulator/Dockerfile +++ b/cmd/emulator/Dockerfile @@ -20,7 +20,7 @@ ARG TARGETARCH RUN --mount=type=ssh \ --mount=type=cache,target=/go/pkg/mod \ --mount=type=cache,target=/root/.cache/go-build \ - GO111MODULE=on CGO_ENABLED=0 GOOS=$TARGETOS GOARCH=$TARGETARCH \ + GO111MODULE=on CGO_ENABLED=1 GOOS=$TARGETOS GOARCH=$TARGETARCH \ go build -ldflags "-extldflags -static" -o ./app ./cmd/emulator ## Add the binary to a fresh distroless image diff --git a/cmd/emulator/Dockerfile.relic b/cmd/emulator/Dockerfile.relic deleted file mode 100644 index 62bfe8dc..00000000 --- a/cmd/emulator/Dockerfile.relic +++ /dev/null @@ -1,55 +0,0 @@ -# NOTE: Must be run in the context of the repo's root directory - -## (1) Build Relic first to maximize caching -FROM golang:1.13-alpine3.10 AS build-relic - -RUN apk update && apk add \ - build-base \ - cmake \ - bash - -RUN mkdir /build -WORKDIR /build - -# Copy over *only* files necessary for Relic -COPY crypto/relic ./relic -COPY crypto/relic_build.sh . - -# Build Relic (this places build artifacts in /build/relic/build) -# NOTE: The Relic build script uses Bash-specific features, so we explicitly run -# it with bash rather than the default shell. -RUN bash ./relic_build.sh - -## (2) Build the app binary -FROM golang:1.13-alpine3.10 AS build-app - -RUN apk update && apk add build-base - -# Build the app binary in /app -RUN mkdir /app -WORKDIR /app - -COPY go.mod . -COPY go.sum . -RUN go mod download - -COPY . . -# Copy over Relic build artifacts -COPY --from=build-relic /build/relic/build ./crypto/relic/build - -RUN GO111MODULE=on CGO_ENABLED=1 GOOOS=linux GOARCH=amd64 go build -o ./app ./cmd/flow - -## (3) Add the binary to a fresh Alpine image -FROM alpine:3.10 - -COPY --from=build-app /app/app /bin/app - -# Expose GRPC and HTTP ports -EXPOSE 8080 -EXPOSE 3569 - -# Run the CLI binary as the entrypoint -ENTRYPOINT ["/bin/app"] -# These arguments are separated from the entrypoint to simplify running other -# commands with this image. -CMD ["emulator", "start", "--init", "--persist"] From cb4bb0f921801406509f3c5056a31c52a5449aa9 Mon Sep 17 00:00:00 2001 From: Tarak Ben Youssef Date: Wed, 10 Jan 2024 21:47:50 +0100 Subject: [PATCH 02/26] add CC flag in go build --- cmd/emulator/Dockerfile | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/cmd/emulator/Dockerfile b/cmd/emulator/Dockerfile index aecf8aef..9420aed2 100644 --- a/cmd/emulator/Dockerfile +++ b/cmd/emulator/Dockerfile @@ -12,15 +12,20 @@ WORKDIR /app # add the pubkey of github.com to knownhosts, so ssh-agent doesn't bark RUN mkdir -p /root/.ssh && ssh-keyscan -t rsa github.com >> /root/.ssh/known_hosts RUN git config --global 'url.ssh://git@github.com/.insteadOf' https://github.com/ +RUN apt-get install gcc-arm-linux-gnueabi COPY . . ARG TARGETOS ARG TARGETARCH +ARG C_COMPILER +RUN if [ "$TARGETARCH" = "arm" ] ; then C_COMPILER="arm-linux-gnueabi-gcc" ; else C_COMPILER="gcc" ; fi + RUN --mount=type=ssh \ --mount=type=cache,target=/go/pkg/mod \ --mount=type=cache,target=/root/.cache/go-build \ GO111MODULE=on CGO_ENABLED=1 GOOS=$TARGETOS GOARCH=$TARGETARCH \ + CC=$C_COMPILER \ go build -ldflags "-extldflags -static" -o ./app ./cmd/emulator ## Add the binary to a fresh distroless image From 6fb4fc9594cffad58ff2baf9352633b6d7c2f3d7 Mon Sep 17 00:00:00 2001 From: Tarak Ben Youssef Date: Wed, 10 Jan 2024 21:55:56 +0100 Subject: [PATCH 03/26] tmp: enable docker job for fast checking --- .github/workflows/ci.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a3410f1f..8aeb90a8 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -54,8 +54,6 @@ jobs: args: --timeout=10m docker: - if: github.ref == 'refs/heads/master' || contains(github.ref, 'refs/tags/') - needs: test name: "Docker image" runs-on: ubuntu-latest steps: From a342592329afd12084b84cc88a256aca67cc2838 Mon Sep 17 00:00:00 2001 From: Tarak Ben Youssef Date: Wed, 10 Jan 2024 21:58:38 +0100 Subject: [PATCH 04/26] improve apt-get call --- cmd/emulator/Dockerfile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cmd/emulator/Dockerfile b/cmd/emulator/Dockerfile index 9420aed2..81ded84e 100644 --- a/cmd/emulator/Dockerfile +++ b/cmd/emulator/Dockerfile @@ -12,7 +12,8 @@ WORKDIR /app # add the pubkey of github.com to knownhosts, so ssh-agent doesn't bark RUN mkdir -p /root/.ssh && ssh-keyscan -t rsa github.com >> /root/.ssh/known_hosts RUN git config --global 'url.ssh://git@github.com/.insteadOf' https://github.com/ -RUN apt-get install gcc-arm-linux-gnueabi +RUN apt-get update +RUN apt-get -y install gcc-arm-linux-gnueabi COPY . . From e83f95feb4e823101995b6fc9df43b1bc7b149ee Mon Sep 17 00:00:00 2001 From: Tarak Ben Youssef Date: Wed, 10 Jan 2024 22:16:24 +0100 Subject: [PATCH 05/26] fix arm arch name --- cmd/emulator/Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cmd/emulator/Dockerfile b/cmd/emulator/Dockerfile index 81ded84e..4fd4f46b 100644 --- a/cmd/emulator/Dockerfile +++ b/cmd/emulator/Dockerfile @@ -13,14 +13,14 @@ WORKDIR /app RUN mkdir -p /root/.ssh && ssh-keyscan -t rsa github.com >> /root/.ssh/known_hosts RUN git config --global 'url.ssh://git@github.com/.insteadOf' https://github.com/ RUN apt-get update -RUN apt-get -y install gcc-arm-linux-gnueabi +RUN apt-get -y install apt-utils gcc-arm-linux-gnueabi COPY . . ARG TARGETOS ARG TARGETARCH ARG C_COMPILER -RUN if [ "$TARGETARCH" = "arm" ] ; then C_COMPILER="arm-linux-gnueabi-gcc" ; else C_COMPILER="gcc" ; fi +RUN if [ "$TARGETARCH" = "arm64" ] ; then C_COMPILER="arm-linux-gnueabi-gcc" ; else C_COMPILER="gcc" ; fi RUN --mount=type=ssh \ --mount=type=cache,target=/go/pkg/mod \ From 0a57ef59e6c0b91a64e25e378583a405f6f72340 Mon Sep 17 00:00:00 2001 From: Tarak Ben Youssef Date: Wed, 10 Jan 2024 22:49:58 +0100 Subject: [PATCH 06/26] improve setting C_COMPILER --- cmd/emulator/Dockerfile | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/cmd/emulator/Dockerfile b/cmd/emulator/Dockerfile index 4fd4f46b..a831bf77 100644 --- a/cmd/emulator/Dockerfile +++ b/cmd/emulator/Dockerfile @@ -19,14 +19,14 @@ COPY . . ARG TARGETOS ARG TARGETARCH -ARG C_COMPILER -RUN if [ "$TARGETARCH" = "arm64" ] ; then C_COMPILER="arm-linux-gnueabi-gcc" ; else C_COMPILER="gcc" ; fi - +ARG C_COMPILER="" +RUN if [ "$TARGETARCH" = "arm64" ] ; then C_COMPILER="arm-linux-gnueabi-gcc" ; \ + elif [ "$TARGETARCH" = "amd64" ] ; then C_COMPILER="gcc" ; fi RUN --mount=type=ssh \ --mount=type=cache,target=/go/pkg/mod \ --mount=type=cache,target=/root/.cache/go-build \ - GO111MODULE=on CGO_ENABLED=1 GOOS=$TARGETOS GOARCH=$TARGETARCH \ - CC=$C_COMPILER \ + GO111MODULE=on CGO_ENABLED=1 GOOS=$TARGETOS \ + GOARCH=$TARGETARCH CC=$C_COMPILER \ go build -ldflags "-extldflags -static" -o ./app ./cmd/emulator ## Add the binary to a fresh distroless image From 6a035661d9abe5bd2fab76b87d419bf668c9bdcc Mon Sep 17 00:00:00 2001 From: Tarak Ben Youssef Date: Wed, 10 Jan 2024 23:25:27 +0100 Subject: [PATCH 07/26] try another if else method --- cmd/emulator/Dockerfile | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/cmd/emulator/Dockerfile b/cmd/emulator/Dockerfile index a831bf77..f9899a00 100644 --- a/cmd/emulator/Dockerfile +++ b/cmd/emulator/Dockerfile @@ -19,15 +19,21 @@ COPY . . ARG TARGETOS ARG TARGETARCH -ARG C_COMPILER="" -RUN if [ "$TARGETARCH" = "arm64" ] ; then C_COMPILER="arm-linux-gnueabi-gcc" ; \ - elif [ "$TARGETARCH" = "amd64" ] ; then C_COMPILER="gcc" ; fi -RUN --mount=type=ssh \ +RUN if [ "$TARGETARCH" = "arm64" ] ; then \ + --mount=type=ssh \ --mount=type=cache,target=/go/pkg/mod \ --mount=type=cache,target=/root/.cache/go-build \ GO111MODULE=on CGO_ENABLED=1 GOOS=$TARGETOS \ - GOARCH=$TARGETARCH CC=$C_COMPILER \ - go build -ldflags "-extldflags -static" -o ./app ./cmd/emulator + GOARCH=$TARGETARCH CC=arm-linux-gnueabi-gcc \ + go build -ldflags "-extldflags -static" -o ./app ./cmd/emulator ; \ + elif [ "$TARGETARCH" = "amd64" ] ; then \ + --mount=type=ssh \ + --mount=type=cache,target=/go/pkg/mod \ + --mount=type=cache,target=/root/.cache/go-build \ + GO111MODULE=on CGO_ENABLED=1 GOOS=$TARGETOS \ + GOARCH=$TARGETARCH CC=gcc \ + go build -ldflags "-extldflags -static" -o ./app ./cmd/emulator ; \ + fi ## Add the binary to a fresh distroless image FROM gcr.io/distroless/static From 9a213752eff12561ef609f4081f6e5aba9640d34 Mon Sep 17 00:00:00 2001 From: Tarak Ben Youssef Date: Wed, 10 Jan 2024 23:59:37 +0100 Subject: [PATCH 08/26] multistage build --- cmd/emulator/Dockerfile | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/cmd/emulator/Dockerfile b/cmd/emulator/Dockerfile index f9899a00..6fee914e 100644 --- a/cmd/emulator/Dockerfile +++ b/cmd/emulator/Dockerfile @@ -19,21 +19,24 @@ COPY . . ARG TARGETOS ARG TARGETARCH -RUN if [ "$TARGETARCH" = "arm64" ] ; then \ - --mount=type=ssh \ + +FROM base AS build-amd64-target +RUN --mount=type=ssh \ --mount=type=cache,target=/go/pkg/mod \ --mount=type=cache,target=/root/.cache/go-build \ GO111MODULE=on CGO_ENABLED=1 GOOS=$TARGETOS \ - GOARCH=$TARGETARCH CC=arm-linux-gnueabi-gcc \ - go build -ldflags "-extldflags -static" -o ./app ./cmd/emulator ; \ - elif [ "$TARGETARCH" = "amd64" ] ; then \ - --mount=type=ssh \ + GOARCH=$TARGETARCH CC=arm-gcc \ + go build -ldflags "-extldflags -static" -o ./app ./cmd/emulator + +FROM base AS build-arm64-target +RUN --mount=type=ssh \ --mount=type=cache,target=/go/pkg/mod \ --mount=type=cache,target=/root/.cache/go-build \ GO111MODULE=on CGO_ENABLED=1 GOOS=$TARGETOS \ - GOARCH=$TARGETARCH CC=gcc \ - go build -ldflags "-extldflags -static" -o ./app ./cmd/emulator ; \ - fi + GOARCH=$TARGETARCH CC=arm-linux-gnueabi-gcc \ + go build -ldflags "-extldflags -static" -o ./app ./cmd/emulator + +FROM build-${TARGETARCH}-target AS final ## Add the binary to a fresh distroless image FROM gcr.io/distroless/static From 5eafc19ac2059f6c07937e53c1d17d0c6e4831a3 Mon Sep 17 00:00:00 2001 From: Tarak Ben Youssef Date: Thu, 11 Jan 2024 00:01:54 +0100 Subject: [PATCH 09/26] Revert "multistage build" This reverts commit 9a213752eff12561ef609f4081f6e5aba9640d34. --- cmd/emulator/Dockerfile | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/cmd/emulator/Dockerfile b/cmd/emulator/Dockerfile index 6fee914e..f9899a00 100644 --- a/cmd/emulator/Dockerfile +++ b/cmd/emulator/Dockerfile @@ -19,24 +19,21 @@ COPY . . ARG TARGETOS ARG TARGETARCH - -FROM base AS build-amd64-target -RUN --mount=type=ssh \ +RUN if [ "$TARGETARCH" = "arm64" ] ; then \ + --mount=type=ssh \ --mount=type=cache,target=/go/pkg/mod \ --mount=type=cache,target=/root/.cache/go-build \ GO111MODULE=on CGO_ENABLED=1 GOOS=$TARGETOS \ - GOARCH=$TARGETARCH CC=arm-gcc \ - go build -ldflags "-extldflags -static" -o ./app ./cmd/emulator - -FROM base AS build-arm64-target -RUN --mount=type=ssh \ + GOARCH=$TARGETARCH CC=arm-linux-gnueabi-gcc \ + go build -ldflags "-extldflags -static" -o ./app ./cmd/emulator ; \ + elif [ "$TARGETARCH" = "amd64" ] ; then \ + --mount=type=ssh \ --mount=type=cache,target=/go/pkg/mod \ --mount=type=cache,target=/root/.cache/go-build \ GO111MODULE=on CGO_ENABLED=1 GOOS=$TARGETOS \ - GOARCH=$TARGETARCH CC=arm-linux-gnueabi-gcc \ - go build -ldflags "-extldflags -static" -o ./app ./cmd/emulator - -FROM build-${TARGETARCH}-target AS final + GOARCH=$TARGETARCH CC=gcc \ + go build -ldflags "-extldflags -static" -o ./app ./cmd/emulator ; \ + fi ## Add the binary to a fresh distroless image FROM gcr.io/distroless/static From f7d033da526234f192eabe18fb58a13d007ac547 Mon Sep 17 00:00:00 2001 From: Tarak Ben Youssef Date: Thu, 11 Jan 2024 19:11:07 +0100 Subject: [PATCH 10/26] put mount commands upfront --- cmd/emulator/Dockerfile | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/cmd/emulator/Dockerfile b/cmd/emulator/Dockerfile index f9899a00..d87be8db 100644 --- a/cmd/emulator/Dockerfile +++ b/cmd/emulator/Dockerfile @@ -19,17 +19,14 @@ COPY . . ARG TARGETOS ARG TARGETARCH -RUN if [ "$TARGETARCH" = "arm64" ] ; then \ - --mount=type=ssh \ +RUN --mount=type=ssh \ --mount=type=cache,target=/go/pkg/mod \ --mount=type=cache,target=/root/.cache/go-build \ + if [ "$TARGETARCH" = "arm64" ] ; then \ GO111MODULE=on CGO_ENABLED=1 GOOS=$TARGETOS \ GOARCH=$TARGETARCH CC=arm-linux-gnueabi-gcc \ go build -ldflags "-extldflags -static" -o ./app ./cmd/emulator ; \ elif [ "$TARGETARCH" = "amd64" ] ; then \ - --mount=type=ssh \ - --mount=type=cache,target=/go/pkg/mod \ - --mount=type=cache,target=/root/.cache/go-build \ GO111MODULE=on CGO_ENABLED=1 GOOS=$TARGETOS \ GOARCH=$TARGETARCH CC=gcc \ go build -ldflags "-extldflags -static" -o ./app ./cmd/emulator ; \ From 9f50ee851e8fe0a08e26ef81bbea74aefe8ff062 Mon Sep 17 00:00:00 2001 From: Tarak Ben Youssef Date: Fri, 12 Jan 2024 02:31:00 +0100 Subject: [PATCH 11/26] use arm64 compiler --- cmd/emulator/Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cmd/emulator/Dockerfile b/cmd/emulator/Dockerfile index d87be8db..1e5f01f1 100644 --- a/cmd/emulator/Dockerfile +++ b/cmd/emulator/Dockerfile @@ -13,7 +13,7 @@ WORKDIR /app RUN mkdir -p /root/.ssh && ssh-keyscan -t rsa github.com >> /root/.ssh/known_hosts RUN git config --global 'url.ssh://git@github.com/.insteadOf' https://github.com/ RUN apt-get update -RUN apt-get -y install apt-utils gcc-arm-linux-gnueabi +RUN apt-get -y install apt-utils aarch64-linux-gnu-gcc COPY . . @@ -24,7 +24,7 @@ RUN --mount=type=ssh \ --mount=type=cache,target=/root/.cache/go-build \ if [ "$TARGETARCH" = "arm64" ] ; then \ GO111MODULE=on CGO_ENABLED=1 GOOS=$TARGETOS \ - GOARCH=$TARGETARCH CC=arm-linux-gnueabi-gcc \ + GOARCH=$TARGETARCH CC=aarch64-linux-gnu-gcc \ go build -ldflags "-extldflags -static" -o ./app ./cmd/emulator ; \ elif [ "$TARGETARCH" = "amd64" ] ; then \ GO111MODULE=on CGO_ENABLED=1 GOOS=$TARGETOS \ From bea5fc29bc07ecacc4d88d7b8e22b36b1acf0c83 Mon Sep 17 00:00:00 2001 From: Tarak Ben Youssef Date: Fri, 12 Jan 2024 02:45:17 +0100 Subject: [PATCH 12/26] remove arm64 compiler install --- cmd/emulator/Dockerfile | 2 -- 1 file changed, 2 deletions(-) diff --git a/cmd/emulator/Dockerfile b/cmd/emulator/Dockerfile index 1e5f01f1..4ca63013 100644 --- a/cmd/emulator/Dockerfile +++ b/cmd/emulator/Dockerfile @@ -12,8 +12,6 @@ WORKDIR /app # add the pubkey of github.com to knownhosts, so ssh-agent doesn't bark RUN mkdir -p /root/.ssh && ssh-keyscan -t rsa github.com >> /root/.ssh/known_hosts RUN git config --global 'url.ssh://git@github.com/.insteadOf' https://github.com/ -RUN apt-get update -RUN apt-get -y install apt-utils aarch64-linux-gnu-gcc COPY . . From e6eeda3ffe4dd268f6a641a8b40a27c3420e558a Mon Sep 17 00:00:00 2001 From: Tarak Ben Youssef Date: Fri, 12 Jan 2024 02:49:48 +0100 Subject: [PATCH 13/26] Revert "remove arm64 compiler install" This reverts commit bea5fc29bc07ecacc4d88d7b8e22b36b1acf0c83. --- cmd/emulator/Dockerfile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/cmd/emulator/Dockerfile b/cmd/emulator/Dockerfile index 4ca63013..1e5f01f1 100644 --- a/cmd/emulator/Dockerfile +++ b/cmd/emulator/Dockerfile @@ -12,6 +12,8 @@ WORKDIR /app # add the pubkey of github.com to knownhosts, so ssh-agent doesn't bark RUN mkdir -p /root/.ssh && ssh-keyscan -t rsa github.com >> /root/.ssh/known_hosts RUN git config --global 'url.ssh://git@github.com/.insteadOf' https://github.com/ +RUN apt-get update +RUN apt-get -y install apt-utils aarch64-linux-gnu-gcc COPY . . From 4007c301d0fe76323d1b27345d5ec26150b70681 Mon Sep 17 00:00:00 2001 From: Tarak Ben Youssef Date: Fri, 12 Jan 2024 02:52:40 +0100 Subject: [PATCH 14/26] use gcc-13 --- cmd/emulator/Dockerfile | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/cmd/emulator/Dockerfile b/cmd/emulator/Dockerfile index 1e5f01f1..d125b33c 100644 --- a/cmd/emulator/Dockerfile +++ b/cmd/emulator/Dockerfile @@ -12,8 +12,7 @@ WORKDIR /app # add the pubkey of github.com to knownhosts, so ssh-agent doesn't bark RUN mkdir -p /root/.ssh && ssh-keyscan -t rsa github.com >> /root/.ssh/known_hosts RUN git config --global 'url.ssh://git@github.com/.insteadOf' https://github.com/ -RUN apt-get update -RUN apt-get -y install apt-utils aarch64-linux-gnu-gcc +RUN apt-get update && apt-get install gcc-13 gcc-13-aarch64-linux-gnu COPY . . @@ -24,11 +23,11 @@ RUN --mount=type=ssh \ --mount=type=cache,target=/root/.cache/go-build \ if [ "$TARGETARCH" = "arm64" ] ; then \ GO111MODULE=on CGO_ENABLED=1 GOOS=$TARGETOS \ - GOARCH=$TARGETARCH CC=aarch64-linux-gnu-gcc \ + GOARCH=$TARGETARCH CC=gcc-13-aarch64-linux-gnu \ go build -ldflags "-extldflags -static" -o ./app ./cmd/emulator ; \ elif [ "$TARGETARCH" = "amd64" ] ; then \ GO111MODULE=on CGO_ENABLED=1 GOOS=$TARGETOS \ - GOARCH=$TARGETARCH CC=gcc \ + GOARCH=$TARGETARCH CC=gcc-13 \ go build -ldflags "-extldflags -static" -o ./app ./cmd/emulator ; \ fi From 47c0d0c1aea40a98756378bf43f021ac41d9a141 Mon Sep 17 00:00:00 2001 From: Tarak Ben Youssef Date: Fri, 12 Jan 2024 02:58:57 +0100 Subject: [PATCH 15/26] Revert "use gcc-13" This reverts commit 4007c301d0fe76323d1b27345d5ec26150b70681. --- cmd/emulator/Dockerfile | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/cmd/emulator/Dockerfile b/cmd/emulator/Dockerfile index d125b33c..1e5f01f1 100644 --- a/cmd/emulator/Dockerfile +++ b/cmd/emulator/Dockerfile @@ -12,7 +12,8 @@ WORKDIR /app # add the pubkey of github.com to knownhosts, so ssh-agent doesn't bark RUN mkdir -p /root/.ssh && ssh-keyscan -t rsa github.com >> /root/.ssh/known_hosts RUN git config --global 'url.ssh://git@github.com/.insteadOf' https://github.com/ -RUN apt-get update && apt-get install gcc-13 gcc-13-aarch64-linux-gnu +RUN apt-get update +RUN apt-get -y install apt-utils aarch64-linux-gnu-gcc COPY . . @@ -23,11 +24,11 @@ RUN --mount=type=ssh \ --mount=type=cache,target=/root/.cache/go-build \ if [ "$TARGETARCH" = "arm64" ] ; then \ GO111MODULE=on CGO_ENABLED=1 GOOS=$TARGETOS \ - GOARCH=$TARGETARCH CC=gcc-13-aarch64-linux-gnu \ + GOARCH=$TARGETARCH CC=aarch64-linux-gnu-gcc \ go build -ldflags "-extldflags -static" -o ./app ./cmd/emulator ; \ elif [ "$TARGETARCH" = "amd64" ] ; then \ GO111MODULE=on CGO_ENABLED=1 GOOS=$TARGETOS \ - GOARCH=$TARGETARCH CC=gcc-13 \ + GOARCH=$TARGETARCH CC=gcc \ go build -ldflags "-extldflags -static" -o ./app ./cmd/emulator ; \ fi From 4bcea13733e597cefb737459e123c0d765bcb82c Mon Sep 17 00:00:00 2001 From: Tarak Ben Youssef Date: Fri, 12 Jan 2024 03:00:20 +0100 Subject: [PATCH 16/26] update arm64 gcc name --- cmd/emulator/Dockerfile | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/cmd/emulator/Dockerfile b/cmd/emulator/Dockerfile index 1e5f01f1..899bd89a 100644 --- a/cmd/emulator/Dockerfile +++ b/cmd/emulator/Dockerfile @@ -12,8 +12,7 @@ WORKDIR /app # add the pubkey of github.com to knownhosts, so ssh-agent doesn't bark RUN mkdir -p /root/.ssh && ssh-keyscan -t rsa github.com >> /root/.ssh/known_hosts RUN git config --global 'url.ssh://git@github.com/.insteadOf' https://github.com/ -RUN apt-get update -RUN apt-get -y install apt-utils aarch64-linux-gnu-gcc +RUN apt-get update && apt-get -y install apt-utils gcc-aarch64-linux-gnu COPY . . @@ -24,7 +23,7 @@ RUN --mount=type=ssh \ --mount=type=cache,target=/root/.cache/go-build \ if [ "$TARGETARCH" = "arm64" ] ; then \ GO111MODULE=on CGO_ENABLED=1 GOOS=$TARGETOS \ - GOARCH=$TARGETARCH CC=aarch64-linux-gnu-gcc \ + GOARCH=$TARGETARCH CC=gcc-aarch64-linux-gnu \ go build -ldflags "-extldflags -static" -o ./app ./cmd/emulator ; \ elif [ "$TARGETARCH" = "amd64" ] ; then \ GO111MODULE=on CGO_ENABLED=1 GOOS=$TARGETOS \ From 3b1f20e841439af577775c4d2be1d9db530ceb84 Mon Sep 17 00:00:00 2001 From: Tarak Ben Youssef Date: Fri, 12 Jan 2024 03:20:45 +0100 Subject: [PATCH 17/26] add cc path --- cmd/emulator/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/emulator/Dockerfile b/cmd/emulator/Dockerfile index 899bd89a..2aaebd70 100644 --- a/cmd/emulator/Dockerfile +++ b/cmd/emulator/Dockerfile @@ -23,7 +23,7 @@ RUN --mount=type=ssh \ --mount=type=cache,target=/root/.cache/go-build \ if [ "$TARGETARCH" = "arm64" ] ; then \ GO111MODULE=on CGO_ENABLED=1 GOOS=$TARGETOS \ - GOARCH=$TARGETARCH CC=gcc-aarch64-linux-gnu \ + GOARCH=$TARGETARCH CC=/usr/bin/gcc-aarch64-linux-gnu \ go build -ldflags "-extldflags -static" -o ./app ./cmd/emulator ; \ elif [ "$TARGETARCH" = "amd64" ] ; then \ GO111MODULE=on CGO_ENABLED=1 GOOS=$TARGETOS \ From 587908732c174ab0c27393c51edb9a7cd5640bc0 Mon Sep 17 00:00:00 2001 From: Tarak Ben Youssef Date: Fri, 12 Jan 2024 03:24:54 +0100 Subject: [PATCH 18/26] debug --- cmd/emulator/Dockerfile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cmd/emulator/Dockerfile b/cmd/emulator/Dockerfile index 2aaebd70..714837e8 100644 --- a/cmd/emulator/Dockerfile +++ b/cmd/emulator/Dockerfile @@ -13,6 +13,7 @@ WORKDIR /app RUN mkdir -p /root/.ssh && ssh-keyscan -t rsa github.com >> /root/.ssh/known_hosts RUN git config --global 'url.ssh://git@github.com/.insteadOf' https://github.com/ RUN apt-get update && apt-get -y install apt-utils gcc-aarch64-linux-gnu +RUN echo $PATH && ls /usr/bin/ COPY . . @@ -23,7 +24,7 @@ RUN --mount=type=ssh \ --mount=type=cache,target=/root/.cache/go-build \ if [ "$TARGETARCH" = "arm64" ] ; then \ GO111MODULE=on CGO_ENABLED=1 GOOS=$TARGETOS \ - GOARCH=$TARGETARCH CC=/usr/bin/gcc-aarch64-linux-gnu \ + GOARCH=$TARGETARCH CC=gcc-aarch64-linux-gnu \ go build -ldflags "-extldflags -static" -o ./app ./cmd/emulator ; \ elif [ "$TARGETARCH" = "amd64" ] ; then \ GO111MODULE=on CGO_ENABLED=1 GOOS=$TARGETOS \ From d9d8d46a281635fb5d6187193c84387c74ace8d5 Mon Sep 17 00:00:00 2001 From: Tarak Ben Youssef Date: Fri, 12 Jan 2024 03:29:05 +0100 Subject: [PATCH 19/26] update arm64 gcc name --- cmd/emulator/Dockerfile | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/cmd/emulator/Dockerfile b/cmd/emulator/Dockerfile index 714837e8..62cf0ffc 100644 --- a/cmd/emulator/Dockerfile +++ b/cmd/emulator/Dockerfile @@ -13,7 +13,6 @@ WORKDIR /app RUN mkdir -p /root/.ssh && ssh-keyscan -t rsa github.com >> /root/.ssh/known_hosts RUN git config --global 'url.ssh://git@github.com/.insteadOf' https://github.com/ RUN apt-get update && apt-get -y install apt-utils gcc-aarch64-linux-gnu -RUN echo $PATH && ls /usr/bin/ COPY . . @@ -24,7 +23,7 @@ RUN --mount=type=ssh \ --mount=type=cache,target=/root/.cache/go-build \ if [ "$TARGETARCH" = "arm64" ] ; then \ GO111MODULE=on CGO_ENABLED=1 GOOS=$TARGETOS \ - GOARCH=$TARGETARCH CC=gcc-aarch64-linux-gnu \ + GOARCH=$TARGETARCH CC=aarch64-linux-gnu-gcc \ go build -ldflags "-extldflags -static" -o ./app ./cmd/emulator ; \ elif [ "$TARGETARCH" = "amd64" ] ; then \ GO111MODULE=on CGO_ENABLED=1 GOOS=$TARGETOS \ From 4106378dc8702f19ba08a5b16feeb42a6c6c37a0 Mon Sep 17 00:00:00 2001 From: Tarak Ben Youssef Date: Fri, 12 Jan 2024 03:50:44 +0100 Subject: [PATCH 20/26] use x86_64 gcc --- cmd/emulator/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/emulator/Dockerfile b/cmd/emulator/Dockerfile index 62cf0ffc..69b3ec94 100644 --- a/cmd/emulator/Dockerfile +++ b/cmd/emulator/Dockerfile @@ -27,7 +27,7 @@ RUN --mount=type=ssh \ go build -ldflags "-extldflags -static" -o ./app ./cmd/emulator ; \ elif [ "$TARGETARCH" = "amd64" ] ; then \ GO111MODULE=on CGO_ENABLED=1 GOOS=$TARGETOS \ - GOARCH=$TARGETARCH CC=gcc \ + GOARCH=$TARGETARCH CC=x86_64-linux-gnu-gcc \ go build -ldflags "-extldflags -static" -o ./app ./cmd/emulator ; \ fi From aa1a3e4a6ffeb0f9bb8b1c66896767d3fa5d5749 Mon Sep 17 00:00:00 2001 From: Tarak Ben Youssef Date: Fri, 12 Jan 2024 20:55:46 +0100 Subject: [PATCH 21/26] compile without adx instructions --- cmd/emulator/Dockerfile | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/cmd/emulator/Dockerfile b/cmd/emulator/Dockerfile index 69b3ec94..d94ab326 100644 --- a/cmd/emulator/Dockerfile +++ b/cmd/emulator/Dockerfile @@ -12,7 +12,7 @@ WORKDIR /app # add the pubkey of github.com to knownhosts, so ssh-agent doesn't bark RUN mkdir -p /root/.ssh && ssh-keyscan -t rsa github.com >> /root/.ssh/known_hosts RUN git config --global 'url.ssh://git@github.com/.insteadOf' https://github.com/ -RUN apt-get update && apt-get -y install apt-utils gcc-aarch64-linux-gnu +RUN apt-get update && apt-get -y install apt-utils gcc-aarch64-linux-gnu x86_64-linux-gnu-gcc COPY . . @@ -22,12 +22,12 @@ RUN --mount=type=ssh \ --mount=type=cache,target=/go/pkg/mod \ --mount=type=cache,target=/root/.cache/go-build \ if [ "$TARGETARCH" = "arm64" ] ; then \ - GO111MODULE=on CGO_ENABLED=1 GOOS=$TARGETOS \ - GOARCH=$TARGETARCH CC=aarch64-linux-gnu-gcc \ + GO111MODULE=on CGO_ENABLED=1 CGO_FLAGS="-O2 -D__BLST_PORTABLE__" \ + GOOS=$TARGETOS GOARCH=$TARGETARCH CC=aarch64-linux-gnu-gcc \ go build -ldflags "-extldflags -static" -o ./app ./cmd/emulator ; \ elif [ "$TARGETARCH" = "amd64" ] ; then \ - GO111MODULE=on CGO_ENABLED=1 GOOS=$TARGETOS \ - GOARCH=$TARGETARCH CC=x86_64-linux-gnu-gcc \ + GO111MODULE=on CGO_ENABLED=1 CGO_FLAGS="-O2 -D__BLST_PORTABLE__" \ + GOOS=$TARGETOS GOARCH=$TARGETARCH CC=x86_64-linux-gnu-gcc \ go build -ldflags "-extldflags -static" -o ./app ./cmd/emulator ; \ fi From d943ea0de94dbce9e68e9bd5cc3e61f86b0a8a69 Mon Sep 17 00:00:00 2001 From: Tarak Ben Youssef Date: Fri, 12 Jan 2024 20:59:23 +0100 Subject: [PATCH 22/26] update x86_64 gcc name --- cmd/emulator/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/emulator/Dockerfile b/cmd/emulator/Dockerfile index d94ab326..7c02fce1 100644 --- a/cmd/emulator/Dockerfile +++ b/cmd/emulator/Dockerfile @@ -12,7 +12,7 @@ WORKDIR /app # add the pubkey of github.com to knownhosts, so ssh-agent doesn't bark RUN mkdir -p /root/.ssh && ssh-keyscan -t rsa github.com >> /root/.ssh/known_hosts RUN git config --global 'url.ssh://git@github.com/.insteadOf' https://github.com/ -RUN apt-get update && apt-get -y install apt-utils gcc-aarch64-linux-gnu x86_64-linux-gnu-gcc +RUN apt-get update && apt-get -y install apt-utils gcc-aarch64-linux-gnu gcc-x86_64-linux-gnu COPY . . From 5a8082dcb633abce8cbf90d6c25875c00846799e Mon Sep 17 00:00:00 2001 From: Tarak Ben Youssef Date: Fri, 12 Jan 2024 21:01:13 +0100 Subject: [PATCH 23/26] remove installing gcc-x86_64-linux-gnu --- cmd/emulator/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/emulator/Dockerfile b/cmd/emulator/Dockerfile index 7c02fce1..92fb2256 100644 --- a/cmd/emulator/Dockerfile +++ b/cmd/emulator/Dockerfile @@ -12,7 +12,7 @@ WORKDIR /app # add the pubkey of github.com to knownhosts, so ssh-agent doesn't bark RUN mkdir -p /root/.ssh && ssh-keyscan -t rsa github.com >> /root/.ssh/known_hosts RUN git config --global 'url.ssh://git@github.com/.insteadOf' https://github.com/ -RUN apt-get update && apt-get -y install apt-utils gcc-aarch64-linux-gnu gcc-x86_64-linux-gnu +RUN apt-get update && apt-get -y install apt-utils gcc-aarch64-linux-gnu COPY . . From d44a5a80539dc46de20125e3192e9c369ee1940c Mon Sep 17 00:00:00 2001 From: Tarak Ben Youssef Date: Fri, 12 Jan 2024 21:07:10 +0100 Subject: [PATCH 24/26] Revert "tmp: enable docker job for fast checking" This reverts commit 6fb4fc9594cffad58ff2baf9352633b6d7c2f3d7. --- .github/workflows/ci.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8aeb90a8..a3410f1f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -54,6 +54,8 @@ jobs: args: --timeout=10m docker: + if: github.ref == 'refs/heads/master' || contains(github.ref, 'refs/tags/') + needs: test name: "Docker image" runs-on: ubuntu-latest steps: From 59f48e346456b41f323d0cd675e8bbf6b2c53640 Mon Sep 17 00:00:00 2001 From: Tarak Ben Youssef Date: Wed, 31 Jan 2024 01:38:44 +0100 Subject: [PATCH 25/26] refactor dockerfile go build --- cmd/emulator/Dockerfile | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/cmd/emulator/Dockerfile b/cmd/emulator/Dockerfile index 92fb2256..c2eb4ef5 100644 --- a/cmd/emulator/Dockerfile +++ b/cmd/emulator/Dockerfile @@ -18,18 +18,20 @@ COPY . . ARG TARGETOS ARG TARGETARCH +ENV GO111MODULE=on \ + CGO_ENABLED=1 \ + CGO_FLAGS="-O2 -D__BLST_PORTABLE__" \ + GOOS=$TARGETOS \ + GOARCH=$TARGETARCH RUN --mount=type=ssh \ --mount=type=cache,target=/go/pkg/mod \ --mount=type=cache,target=/root/.cache/go-build \ if [ "$TARGETARCH" = "arm64" ] ; then \ - GO111MODULE=on CGO_ENABLED=1 CGO_FLAGS="-O2 -D__BLST_PORTABLE__" \ - GOOS=$TARGETOS GOARCH=$TARGETARCH CC=aarch64-linux-gnu-gcc \ - go build -ldflags "-extldflags -static" -o ./app ./cmd/emulator ; \ + export CC=aarch64-linux-gnu-gcc; \ elif [ "$TARGETARCH" = "amd64" ] ; then \ - GO111MODULE=on CGO_ENABLED=1 CGO_FLAGS="-O2 -D__BLST_PORTABLE__" \ - GOOS=$TARGETOS GOARCH=$TARGETARCH CC=x86_64-linux-gnu-gcc \ + export CC=x86_64-linux-gnu-gcc; \ + fi; \ go build -ldflags "-extldflags -static" -o ./app ./cmd/emulator ; \ - fi ## Add the binary to a fresh distroless image FROM gcr.io/distroless/static From 6ea64e9d4826e4a02faf512ae84249cb85a5c556 Mon Sep 17 00:00:00 2001 From: Tarak Ben Youssef Date: Wed, 31 Jan 2024 20:29:12 +0100 Subject: [PATCH 26/26] fix dockerfile bug --- cmd/emulator/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/emulator/Dockerfile b/cmd/emulator/Dockerfile index c2eb4ef5..0ed9f8cf 100644 --- a/cmd/emulator/Dockerfile +++ b/cmd/emulator/Dockerfile @@ -31,7 +31,7 @@ RUN --mount=type=ssh \ elif [ "$TARGETARCH" = "amd64" ] ; then \ export CC=x86_64-linux-gnu-gcc; \ fi; \ - go build -ldflags "-extldflags -static" -o ./app ./cmd/emulator ; \ + go build -ldflags "-extldflags -static" -o ./app ./cmd/emulator ## Add the binary to a fresh distroless image FROM gcr.io/distroless/static