From fb7d167ba75465135860dc430157fde05020aa48 Mon Sep 17 00:00:00 2001 From: Christopher Campbell Date: Tue, 27 Feb 2024 13:29:50 -0500 Subject: [PATCH 1/6] goreleaser needs separate dockerfile --- Dockerfile.release | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 Dockerfile.release diff --git a/Dockerfile.release b/Dockerfile.release new file mode 100644 index 0000000000..3bf9a55aac --- /dev/null +++ b/Dockerfile.release @@ -0,0 +1,14 @@ +FROM alpine:3.18 + +RUN apk update && apk add postgresql15-client + +EXPOSE 8123 + +COPY dist/zkevm-node /app/zkevm-node + +RUN addgroup -S zkevm-group \ + && adduser -S zkevm-user -G zkevm-group + +USER zkevm-user + +CMD ["/bin/sh", "-c", "/app/zkevm-node run"] From d9f42c6300757234cab6a81647b913b6f4261c21 Mon Sep 17 00:00:00 2001 From: Christopher Campbell Date: Tue, 27 Feb 2024 13:31:06 -0500 Subject: [PATCH 2/6] docker file ref --- .goreleaser-cdk.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.goreleaser-cdk.yaml b/.goreleaser-cdk.yaml index fb0147a3cd..834ea69a4a 100644 --- a/.goreleaser-cdk.yaml +++ b/.goreleaser-cdk.yaml @@ -32,7 +32,7 @@ archives: dockers: - image_templates: - 0xpolygon/{{ .ProjectName }}:{{ replace .Version "+" "-" }}-amd64 - dockerfile: Dockerfile + dockerfile: Dockerfile.release use: buildx goos: linux goarch: amd64 @@ -49,7 +49,7 @@ dockers: - image_templates: - 0xpolygon/{{ .ProjectName }}:{{ replace .Version "+" "-" }}-arm64 - dockerfile: Dockerfile + dockerfile: Dockerfile.release use: buildx goos: linux goarch: arm64 From 163326402bd0291264ed7cb6ab824c7b38723fd8 Mon Sep 17 00:00:00 2001 From: Christopher Campbell Date: Tue, 27 Feb 2024 14:40:18 -0500 Subject: [PATCH 3/6] include packr command with docker build --- .github/workflows/release.yml | 2 +- Dockerfile.release | 21 ++++++++++++++------- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 1abab96b22..e12cc8d978 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -22,7 +22,7 @@ jobs: - name: Set up Go uses: actions/setup-go@v5 with: - go-version: 1.21.x + go-version: 1.21 - name: Set up QEMU uses: docker/setup-qemu-action@v3 diff --git a/Dockerfile.release b/Dockerfile.release index 3bf9a55aac..6314bace28 100644 --- a/Dockerfile.release +++ b/Dockerfile.release @@ -1,14 +1,21 @@ -FROM alpine:3.18 +# CONTAINER FOR BUILDING BINARY +FROM golang:1.21 AS build -RUN apk update && apk add postgresql15-client +# INSTALL DEPENDENCIES +RUN go install github.com/gobuffalo/packr/v2/packr2@v2.8.3 +COPY go.mod go.sum /src/ +RUN cd /src && go mod download -EXPOSE 8123 - -COPY dist/zkevm-node /app/zkevm-node +# BUILD BINARY +COPY . /src +RUN cd /src/db && packr2 +RUN cd /src && make build +FROM alpine:3.18 +COPY --from=build /src/dist/zkevm-node /app/zkevm-node +RUN apk update && apk add postgresql15-client +EXPOSE 8123 RUN addgroup -S zkevm-group \ && adduser -S zkevm-user -G zkevm-group - USER zkevm-user - CMD ["/bin/sh", "-c", "/app/zkevm-node run"] From 3f427930ecd05e2250d0cec7c91207e3f1f8e191 Mon Sep 17 00:00:00 2001 From: Christopher Campbell Date: Tue, 27 Feb 2024 16:30:15 -0500 Subject: [PATCH 4/6] do the packr in releaser before hook --- .goreleaser-cdk.yaml | 6 ++++++ Dockerfile.release | 22 ++++++++-------------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/.goreleaser-cdk.yaml b/.goreleaser-cdk.yaml index 834ea69a4a..b0b8b03287 100644 --- a/.goreleaser-cdk.yaml +++ b/.goreleaser-cdk.yaml @@ -6,6 +6,12 @@ release: draft: true prerelease: auto +before: + hooks: + - go mod download + - go install github.com/gobuffalo/packr/v2/packr2@v2.8.3 + - ( cd db && packr2 ) + builds: - main: ./cmd/ binary: zkevm-node diff --git a/Dockerfile.release b/Dockerfile.release index 6314bace28..6a30b89917 100644 --- a/Dockerfile.release +++ b/Dockerfile.release @@ -1,21 +1,15 @@ -# CONTAINER FOR BUILDING BINARY -FROM golang:1.21 AS build - -# INSTALL DEPENDENCIES -RUN go install github.com/gobuffalo/packr/v2/packr2@v2.8.3 -COPY go.mod go.sum /src/ -RUN cd /src && go mod download +FROM alpine:3.18 -# BUILD BINARY -COPY . /src -RUN cd /src/db && packr2 -RUN cd /src && make build +COPY dist/zkevm-node /app/zkevm-node -FROM alpine:3.18 -COPY --from=build /src/dist/zkevm-node /app/zkevm-node -RUN apk update && apk add postgresql15-client EXPOSE 8123 + RUN addgroup -S zkevm-group \ && adduser -S zkevm-user -G zkevm-group + +RUN chown -R /app zkevm-user:zkevm-group + USER zkevm-user + CMD ["/bin/sh", "-c", "/app/zkevm-node run"] + From 604bb2dd84392d72a4120d3be7ad5bdc655bfb84 Mon Sep 17 00:00:00 2001 From: Christopher Campbell Date: Tue, 27 Feb 2024 16:35:47 -0500 Subject: [PATCH 5/6] gorelease build to dist dir --- .goreleaser-cdk.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.goreleaser-cdk.yaml b/.goreleaser-cdk.yaml index b0b8b03287..35bd0df8f7 100644 --- a/.goreleaser-cdk.yaml +++ b/.goreleaser-cdk.yaml @@ -14,7 +14,7 @@ before: builds: - main: ./cmd/ - binary: zkevm-node + binary: dist/zkevm-node goos: - linux - darwin From 2c3e12a477fa6d014212caee31e00415056b926e Mon Sep 17 00:00:00 2001 From: Victor Castell <0x@vcastellm.xyz> Date: Wed, 28 Feb 2024 11:53:19 +0100 Subject: [PATCH 6/6] Update Dockerfile.release --- Dockerfile.release | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile.release b/Dockerfile.release index 6a30b89917..16b4ca248d 100644 --- a/Dockerfile.release +++ b/Dockerfile.release @@ -11,5 +11,5 @@ RUN chown -R /app zkevm-user:zkevm-group USER zkevm-user -CMD ["/bin/sh", "-c", "/app/zkevm-node run"] +CMD ["/bin/sh", "-c", "/app/zkevm-node"]