From 6a92b9508509f6cb2bbbd7dc8a1944865b2d2582 Mon Sep 17 00:00:00 2001 From: Semen Medvedev Date: Thu, 22 Aug 2024 14:31:23 +0700 Subject: [PATCH 1/4] Add build by GitHub actions --- .github/steps/publish-image.sh | 31 +++++++++++++++++ .github/workflows/ci.yml | 61 ++++++++++++++++++++++++++++++++++ 2 files changed, 92 insertions(+) create mode 100755 .github/steps/publish-image.sh create mode 100644 .github/workflows/ci.yml diff --git a/.github/steps/publish-image.sh b/.github/steps/publish-image.sh new file mode 100755 index 0000000..181d3f0 --- /dev/null +++ b/.github/steps/publish-image.sh @@ -0,0 +1,31 @@ +#!/bin/bash +set -euo pipefail + +docker images +while getopts u:p:b:t: option +do + case "${option}" in + u) user=${OPTARG};; + p) password=${OPTARG};; + b) branch=${OPTARG};; + t) tag=${OPTARG};; + *) echo -e "usage: $0 \n [-u] docker hub user \n [-p] docker hub password \n [-b] current branch \n [-t] governance-cli tag" >&2 + exit 1 ;; + esac +done + +if [[ $branch == "main" ]]; then + TAG="stable" +else + TAG=$branch +fi + +docker login -u=$user -p=$password +docker push neonlabsorg/launch-script:$tag + +if [[ $TAG == "stable" ]] || [[ $TAG == ci-* ]] || [[ $TAG == v*.*.* ]]; then + docker tag neonlabsorg/launch-script:$tag neonlabsorg/launch-script:${TAG} + docker push neonlabsorg/launch-script:${TAG} +fi + +exit 0 \ No newline at end of file diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..7f8c4b2 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,61 @@ +name: ci + +on: [push] + +env: + SOLANA_REVISION: v1.10.29 + GITHUB_SHA: ${{ github.sha }} + BRANCH_NAME: ${{ github.head_ref || github.ref_name }} + DOCKER_HUB_PASSWORD: ${{ secrets.DHUBP }} + DOCKER_HUB_USER: ${{ secrets.DHUBU }} + +jobs: + neon-governance-deploy: + runs-on: build-runner + env: + NEON_GOVERNANCE_IMAGE: neonlabsorg/neon-governance:${GITHUB_SHA} + steps: + - uses: actions/checkout@v2 + - name: "Checkout submodules using a Personal Access Token" + run: | + git config --file .gitmodules --get-regexp url | while read url; do + git config --file=.gitmodules $(echo "$url" | sed -E "s/git@github.com:|https:\/\/github.com\//https:\/\/${{ secrets.CI_PAT }}:${{ secrets.CI_PAT }}@github.com\//") + done + git submodule sync + git submodule update --init --recursive + + - name: "Set up Docker Buildx" + id: buildx + uses: docker/setup-buildx-action@v2 + with: + version: v0.9.1 + install: true + + - name: "Cache Docker layers" + uses: actions/cache@v3 + with: + path: /tmp/.buildx-cache + key: ${{ runner.os }}-multi-buildx-${{ github.sha }} + restore-keys: | + ${{ runner.os }}-multi-buildx + + - name: "Build image" + uses: docker/build-push-action@v3 + with: + context: . + builder: ${{ steps.buildx.outputs.name }} + file: Dockerfile + target: base + push: false + load: true + tags: ${{ steps.prep.outputs.tagged_image }} + cache-from: type=local,src=/tmp/.buildx-cache + cache-to: type=local,mode=max,dest=/tmp/.buildx-cache-new + + - name: "Move cache" + run: | + rm -rf /tmp/.buildx-cache + mv /tmp/.buildx-cache-new /tmp/.buildx-cache + + - name: "Publish the Docker image" + run: ./.github/steps/publish-image.sh -u ${DOCKER_HUB_USER} -p ${DOCKER_HUB_PASSWORD} -b ${BRANCH_NAME} -t ${GITHUB_SHA} From 5b97f4021f94dff6588a7f0e1d6bad949e61001a Mon Sep 17 00:00:00 2001 From: Semen Medvedev Date: Thu, 22 Aug 2024 14:44:48 +0700 Subject: [PATCH 2/4] Change solana release to v1.14.24 --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 87fc7b0..1e30d5c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,7 +1,7 @@ # Install BPF SDK FROM solanalabs/rust:1.62.0 AS builder # Use hardcoded solana revision for install SDK to prevent long rebuild when use other SOLANA_REVISION -RUN sh -c "$(curl -sSfL https://release.solana.com/v1.10.29/install)" && \ +RUN sh -c "$(curl -sSfL https://release.solana.com/v1.14.24/install)" && \ /root/.local/share/solana/install/active_release/bin/sdk/bpf/scripts/install.sh ENV PATH=/root/.local/share/solana/install/active_release/bin:/usr/local/cargo/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin From f67ffd55163788c9d8181069b18609437ca25bc4 Mon Sep 17 00:00:00 2001 From: Semen Medvedev Date: Thu, 22 Aug 2024 15:15:26 +0700 Subject: [PATCH 3/4] Change docker image name inside publish script --- .github/steps/publish-image.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/steps/publish-image.sh b/.github/steps/publish-image.sh index 181d3f0..29a08d4 100755 --- a/.github/steps/publish-image.sh +++ b/.github/steps/publish-image.sh @@ -21,11 +21,11 @@ else fi docker login -u=$user -p=$password -docker push neonlabsorg/launch-script:$tag +docker push neonlabsorg/neon-governance:$tag if [[ $TAG == "stable" ]] || [[ $TAG == ci-* ]] || [[ $TAG == v*.*.* ]]; then - docker tag neonlabsorg/launch-script:$tag neonlabsorg/launch-script:${TAG} - docker push neonlabsorg/launch-script:${TAG} + docker tag neonlabsorg/neon-governance:$tag neonlabsorg/neon-governance:${TAG} + docker push neonlabsorg/neon-governance:${TAG} fi exit 0 \ No newline at end of file From 1daa226719e9037689051ed61612da57b91af830 Mon Sep 17 00:00:00 2001 From: Semen Medvedev Date: Thu, 22 Aug 2024 16:51:00 +0700 Subject: [PATCH 4/4] Fix docker image tag --- .github/workflows/ci.yml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7f8c4b2..9020a84 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -24,6 +24,13 @@ jobs: git submodule sync git submodule update --init --recursive + - name: "Prepare to build image" + id: prep + run: | + docker pull solanalabs/solana:${SOLANA_REVISION} + IMAGE="neonlabsorg/neon-governance" + echo ::set-output name=tagged_image::${IMAGE}:${GITHUB_SHA} + - name: "Set up Docker Buildx" id: buildx uses: docker/setup-buildx-action@v2