diff --git a/.github/workflows/testing-release.yml b/.github/workflows/testing-release.yml index f119745..6cd60d0 100644 --- a/.github/workflows/testing-release.yml +++ b/.github/workflows/testing-release.yml @@ -45,14 +45,14 @@ jobs: goarch: amd64 flags_cc: x86_64-linux-gnu-gcc flags_cxx: x86_64-linux-gnu-g++ - build_dst: build-linux-amd64 + build_dst: src - arch: linux/arm64 id: linux-arm64 goos: linux goarch: arm64 flags_cc: aarch64-linux-gnu-gcc flags_cxx: aarch64-linux-gnu-g++ - build_dst: build-linux-arm64 + build_dst: src steps: - name: Checkout github repo @@ -60,6 +60,12 @@ jobs: with: fetch-depth: 0 + - name: Login to Docker Hub + uses: docker/login-action@v3 + with: + username: ${{ secrets.ORG_DOCKERHUB_ERIGONTECH_USERNAME }} + password: ${{ secrets.ORG_DOCKERHUB_ERIGONTECH_TOKEN }} + - name: Set up QEMU uses: docker/setup-qemu-action@v3 @@ -71,9 +77,29 @@ jobs: run: | docker run --rm --platform ${{ matrix.arch }} \ -e GOOS=${{ matrix.goos }} -e GOARCH=${{ matrix.goarch }} \ - -w /app1/src -v $(pwd):/app1 golang:${{ env.GOLANG_BUILDER_VERSION }} \ + -w /app1/src \ + -v $(pwd):/app1 \ + golang:${{ env.GOLANG_BUILDER_VERSION }} \ /bin/bash -c "git config --global --add safe.directory . ; go build main.go; ls -lao" + - name: Build and push docker image for ${{ matrix.arch }} platform + id: docker_build + uses: docker/build-push-action@v6 + with: + context: . + file: ./Dockerfile + platforms: ${{ matrix.arch }} + build-args: | + BUILD_DST=${{ matrix.build_dst }} + GOLANG_BUILDER_VERSION=${{ env.GOLANG_BUILDER_VERSION }} + TARGET_BASE_VERSION=${{ env.TARGET_BASE_VERSION }} + BUILD_TAGS=${{ env.BUILD_TAGS }} + BUILD_TIMESTAMP=${{ steps.current_ts.outputs.date }} + VCS_REF_SHORT=${{ steps.GetShortCommitId.outputs.short_commit_id }} + VCS_REF_LONG=${{ github.sha }} + VERSION=${{ steps.GetVersion.outputs.ver }} + outputs: type=image,name=${{ env.DOCKERHUB_REPOSITORY }},push-by-digest=true,name-canonical=true,push=true + - name: Compress Artifact for the platform ${{ matrix.arch }} run: | tar czvf ./${{ env.APPLICATION}}-${{ matrix.id }}.tar.gz src/main @@ -92,6 +118,20 @@ jobs: pwd find . -ls + - name: Export digest + run: | + mkdir -p /tmp/digests + digest="${{ steps.docker_build.outputs.digest }}" + touch "/tmp/digests/${digest#sha256:}" + + - name: Upload digest + uses: actions/upload-artifact@v4 + with: + name: digests-${{ matrix.id }} + path: /tmp/digests/* + if-no-files-found: error + retention-days: 1 + publish-artifacts: needs: [ build ] runs-on: ubuntu-latest @@ -99,12 +139,51 @@ jobs: steps: - - name: Download all available Artifacts + - name: Get short last commit id + id: GetShortCommitId + run: echo "short_commit_id=${GITHUB_SHA:0:7}" >> $GITHUB_OUTPUT + + - name: Download tar.gz artifacts uses: actions/download-artifact@v4 with: path: . pattern: "${{ github.sha }}_*" merge-multiple: true + - name: Download docker digests + uses: actions/download-artifact@v4 + with: + path: /tmp/digests + pattern: digests-* + merge-multiple: true + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Get version from Github tag + id: GetVersion + run: echo ver=$( echo ${{ github.ref_name }} | sed -e 's,.*\/,,g' ) >> $GITHUB_OUTPUT + + - name: Docker meta + id: meta + uses: docker/metadata-action@v5 + with: + images: ${{ env.DOCKERHUB_REPOSITORY }} + tags: | + type=sha,enable=true,priority=100,prefix=sha-,suffix=,format=short + + - name: Login to Docker Hub + uses: docker/login-action@v3 + with: + username: ${{ secrets.ORG_DOCKERHUB_ERIGONTECH_USERNAME }} + password: ${{ secrets.ORG_DOCKERHUB_ERIGONTECH_TOKEN }} + + - name: Create manifest list and push + working-directory: /tmp/digests + run: | + docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \ + $(printf '${{ env.DOCKERHUB_REPOSITORY }}@sha256:%s ' *) + - name: Debug output - run: find . -ls \ No newline at end of file + run: | + find . -ls diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..ed03ea9 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,48 @@ +ARG TARGET_BASE_VERSION="bullseye-20240701" + +FROM debian:${TARGET_BASE_VERSION} + +ARG GOLANG_BUILDER_VERSION \ + BUILD_DST \ + BUILD_TIMESTAMP \ + VCS_REF_SHORT \ + VCS_REF_LONG \ + VERSION \ + USER=erigon \ + GROUP=erigon + +LABEL BUILDER_IMAGE_INFO=golang:${GOLANG_BUILDER_VERSION} \ + MAINTAINER="https://github.com/erigontech/erigon" \ + org.label-schema.build-date=${BUILD_TIMESTAMP} \ + org.label-schema.description="Erigon Ethereum Client" \ + org.label-schema.name="Erigon" \ + org.label-schema.schema-version="1.0" \ + org.label-schema.url="https://torquem.ch" \ + org.label-schema.vcs-ref-short=${VCS_REF_SHORT} \ + org.label-schema.vcs-ref=${VCS_REF_LONG} \ + org.label-schema.vcs-url="https://github.com/erigontech/erigon.git" \ + org.label-schema.vendor="Torquem" \ + org.label-schema.version=${VERSION} + +COPY ${BUILD_DST}/* /usr/local/bin/ + +RUN groupadd ${GROUP} && \ + useradd -d /home/${USER} -g ${GROUP} -m ${USER} + +VOLUME [ "/home/${USER}" ] +WORKDIR /home/${USER} + +USER ${USER} + +EXPOSE 8545 \ + 8551 \ + 8546 \ + 30303 \ + 30303/udp \ + 42069 \ + 42069/udp \ + 8080 \ + 9090 \ + 6060 + +ENTRYPOINT [ "/usr/local/bin/erigon" ] \ No newline at end of file