diff --git a/.github/workflows/build.debank.yml b/.github/workflows/build.debank.yml new file mode 100644 index 0000000000..1904902bce --- /dev/null +++ b/.github/workflows/build.debank.yml @@ -0,0 +1,43 @@ +name: "Build artifacts" + +on: + pull_request: + branches: + - 'debank' + workflow_dispatch: + +env: + REGISTRY: 294354037686.dkr.ecr.ap-northeast-1.amazonaws.com + IMAGE: blockchain-geth + DOCKERFILE: Dockerfile.debank + +jobs: + build-and-package: + runs-on: [self-hosted, default-go-builder] + steps: + - name: Checkout code + uses: actions/checkout@v2 + with: + ref: ${{ github.event.pull_request.head.sha }} + + - uses: tibdex/github-app-token@v1 + id: generate-token + with: + app_id: ${{ secrets.RELEASE_MANAGER_APP_ID }} + private_key: ${{ secrets.RELEASE_MANAGER_APP_SECRET }} + + - name: Set env + run: | + echo "REVISION=$(git rev-parse --short HEAD)" >> $GITHUB_ENV + + - name: Build image and push to ECR + run: | + docker build --build-arg ACCESS_TOKEN=${{ steps.generate-token.outputs.token }} -t ${REGISTRY}/${IMAGE}:${REVISION} -f ${DOCKERFILE} . + docker push ${REGISTRY}/${IMAGE}:${REVISION} + docker run --name dryrun --rm ${REGISTRY}/${IMAGE}:${REVISION} version + docker rmi ${REGISTRY}/${IMAGE}:${REVISION} + + - name: Lark Notification + continue-on-error: true + run: | + notiv3 "Blockchain go-ethereum image pushed 🎉" ${REGISTRY}/${IMAGE}:${REVISION} diff --git a/.github/workflows/release.debank.yml b/.github/workflows/release.debank.yml new file mode 100644 index 0000000000..42101053c9 --- /dev/null +++ b/.github/workflows/release.debank.yml @@ -0,0 +1,43 @@ +name: "Release artifacts" + +on: + release: + types: + - created + workflow_dispatch: + +env: + REGISTRY: 294354037686.dkr.ecr.ap-northeast-1.amazonaws.com + IMAGE: blockchain-geth + DOCKERFILE: Dockerfile.debank + +jobs: + build-and-package: + runs-on: [self-hosted, default-go-builder] + steps: + - name: Checkout code + uses: actions/checkout@v2 + with: + ref: ${{ github.event.pull_request.head.sha }} + + - uses: tibdex/github-app-token@v1 + id: generate-token + with: + app_id: ${{ secrets.RELEASE_MANAGER_APP_ID }} + private_key: ${{ secrets.RELEASE_MANAGER_APP_SECRET }} + + - name: Set env + run: | + echo "REVISION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV + + - name: Build image and push to ECR + run: | + docker build --build-arg ACCESS_TOKEN=${{ steps.generate-token.outputs.token }} -t ${REGISTRY}/${IMAGE}:${REVISION} -f ${DOCKERFILE} . + docker push ${REGISTRY}/${IMAGE}:${REVISION} + docker run --name dryrun --rm ${REGISTRY}/${IMAGE}:${REVISION} version + docker rmi ${REGISTRY}/${IMAGE}:${REVISION} + + - name: Lark Notification + continue-on-error: true + run: | + notiv3 "Blockchain go-ethereum image pushed 🎉" ${REGISTRY}/${IMAGE}:${REVISION} diff --git a/Dockerfile.debank b/Dockerfile.debank new file mode 100644 index 0000000000..3e984c6acf --- /dev/null +++ b/Dockerfile.debank @@ -0,0 +1,53 @@ +# builder image + + +FROM ubuntu:23.04 as builder + +ARG ACCESS_TOKEN + +SHELL ["/bin/bash", "-c"] + +RUN apt-get update -q -y && apt-get upgrade -q -y +RUN DEBIAN_FRONTEND=noninteractive apt-get install -y tzdata +RUN DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends build-essential ca-certificates curl libjemalloc-dev liblz4-dev libsnappy-dev libzstd-dev libudev-dev git +RUN git config --global url."https://x-access-token:${ACCESS_TOKEN}@github.com".insteadOf "https://github.com" + +# golang +RUN curl -sL -o /tmp/go.tar.gz https://dl.google.com/go/$(curl -sL https://golang.org/VERSION?m=text).linux-amd64.tar.gz && \ + pushd /usr/local/ && \ + tar xfz /tmp/go.tar.gz && \ + cd /usr/local/bin/ && \ + ln -sf ../go/bin/* . && \ + popd && \ + rm /tmp/go.tar.gz + +RUN apt autoremove && apt autoclean + +WORKDIR /go-ethereum + +COPY .git /go-ethereum/.git + +COPY . . + + +WORKDIR /go-ethereum + +COPY go.mod . +COPY go.sum . +RUN go mod download + +RUN make geth + +FROM ubuntu:23.04 + +RUN apt-get update && apt-get install -y ca-certificates wget libsnappy-dev libjemalloc-dev + + +WORKDIR /app + +COPY --from=builder /go-ethereum/build/bin /app + + +EXPOSE 8545 8546 33688 33688/udp + +ENTRYPOINT ["/app/geth"]