diff --git a/.gitea/workflows/build-and-release.yml b/.gitea/workflows/build-and-release.yml new file mode 100644 index 0000000..a71694d --- /dev/null +++ b/.gitea/workflows/build-and-release.yml @@ -0,0 +1,110 @@ +name: Build and Release + +on: + repository_dispatch: + types: [erigon_pulse_update] + +env: + DOCKER_IMAGE_NAME: ${{ vars.GITEA_REGISTRY_URL }}/erigon-pulse:${{ github.event.client_payload.ref }} + DOCKER_PLATFORMS: linux/amd64,linux/arm64 + ERIGON_REPO: ${{ vars.ERIGON_REPO_URL }} + +jobs: + compile_binaries: + runs-on: ubuntu-latest + steps: + - name: Checkout Erigon + uses: actions/checkout@v3 + with: + repository: ${{ env.ERIGON_REPO }} + ref: ${{ github.event.client_payload.ref }} + - name: Set up Go + uses: actions/setup-go@v4 + with: + go-version: '1.20' + - name: Build for Linux AMD64 + run: GOOS=linux GOARCH=amd64 go build -trimpath -tags nosqlite,noboltdb -o _build/linux/erigon-amd64 ./cmd/erigon + - name: Build for Linux ARM64 + run: GOOS=linux GOARCH=arm64 go build -trimpath -tags nosqlite,noboltdb -o _build/linux/erigon-arm64 ./cmd/erigon + - name: Upload artifacts + uses: actions/upload-artifact@v3 + with: + name: binaries + path: _build/ + + docker_build: + needs: compile_binaries + runs-on: ubuntu-latest + steps: + - name: Checkout Erigon + uses: actions/checkout@v3 + with: + repository: ${{ env.ERIGON_REPO }} + ref: ${{ github.event.client_payload.ref }} + - name: Download binaries + uses: actions/download-artifact@v3 + with: + name: binaries + path: _build/ + - name: Set up QEMU + uses: docker/setup-qemu-action@v2 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + - name: Login to Gitea Container Registry + uses: docker/login-action@v2 + with: + registry: ${{ vars.GITEA_REGISTRY_URL }} + username: ${{ gitea.actor }} + password: ${{ secrets.GITEA_TOKEN }} + - name: Build and push + uses: docker/build-push-action@v4 + with: + context: . + platforms: ${{ env.DOCKER_PLATFORMS }} + push: true + tags: ${{ env.DOCKER_IMAGE_NAME }} + build-args: | + BUILD_DATE=${{ github.event.client_payload.timestamp }} + VCS_REF=${{ github.event.client_payload.sha }} + VERSION=${{ github.event.client_payload.ref }} + + release: + needs: [compile_binaries, docker_build] + if: startsWith(github.event.client_payload.ref, 'refs/tags/') + runs-on: ubuntu-latest + steps: + - name: Download binaries + uses: actions/download-artifact@v3 + with: + name: binaries + path: _build/ + - name: Create Release + uses: softprops/action-gh-release@v1 + with: + files: | + _build/linux/erigon-amd64 + _build/linux/erigon-arm64 + body: | + **Docker Image** + - erigon multi-arch (amd64/arm64): `${{ env.DOCKER_IMAGE_NAME }}` + + ## Release Notes + _Release created by Gitea Actions (pending release notes)._ + tag_name: ${{ github.event.client_payload.ref }} + env: + GITHUB_TOKEN: ${{ secrets.GITEA_TOKEN }} + + docker_tag_latest: + needs: release + if: startsWith(github.event.client_payload.ref, 'refs/tags/') + runs-on: ubuntu-latest + steps: + - name: Login to Gitea Container Registry + uses: docker/login-action@v2 + with: + registry: ${{ vars.GITEA_REGISTRY_URL }} + username: ${{ gitea.actor }} + password: ${{ secrets.GITEA_TOKEN }} + - name: Tag latest + run: | + docker buildx imagetools create -t ${{ vars.GITEA_REGISTRY_URL }}/erigon-pulse:latest ${{ env.DOCKER_IMAGE_NAME }} \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..402c51d --- /dev/null +++ b/Dockerfile @@ -0,0 +1,28 @@ +FROM alpine:latest + +ARG TARGETARCH +ARG BUILD_DATE +ARG VCS_REF +ARG VERSION + +# Labels +LABEL org.label-schema.build-date=$BUILD_DATE \ + org.label-schema.name="Erigon" \ + org.label-schema.description="Erigon Ethereum client" \ + org.label-schema.url="https://github.com/ledgerwatch/erigon" \ + org.label-schema.vcs-ref=$VCS_REF \ + org.label-schema.vcs-url="https://github.com/ledgerwatch/erigon" \ + org.label-schema.vendor="Erigon" \ + org.label-schema.version=$VERSION \ + org.label-schema.schema-version="1.0" + +# Install dependencies +RUN apk add --no-cache ca-certificates libgcc + +# Copy the pre-built binary into the image +COPY _build/linux/erigon-$TARGETARCH /usr/local/bin/erigon + +# Expose default ports +EXPOSE 8545 8551 8546 30303 30303/udp + +ENTRYPOINT ["erigon"] \ No newline at end of file