From 4468c8e7fa99cb6448411fa404a78b9174f3c813 Mon Sep 17 00:00:00 2001 From: vladupshot <154623109+vladupshot@users.noreply.github.com> Date: Fri, 19 Jan 2024 06:27:51 +1300 Subject: [PATCH 1/4] adjust pipeline --- .github/workflows/build_push_ecr.yml | 35 ++++++++++++++++------------ 1 file changed, 20 insertions(+), 15 deletions(-) diff --git a/.github/workflows/build_push_ecr.yml b/.github/workflows/build_push_ecr.yml index a97e202..a0e1ba6 100644 --- a/.github/workflows/build_push_ecr.yml +++ b/.github/workflows/build_push_ecr.yml @@ -5,17 +5,16 @@ name: Build and Push docker image to ECR on: push: branches: - - staging - - vlad/ora-190-ensure-all-repos-are-deployable-on-aws-cloud-with-a-merge + - main + pull_request: concurrency: - group: ${{ github.ref }} + group: ${{ github.ref }} cancel-in-progress: true jobs: - deploy-staging: + build-push: name: Build and Push docker image runs-on: ubuntu-latest - environment: staging steps: - name: Checkout @@ -33,22 +32,28 @@ jobs: uses: aws-actions/amazon-ecr-login@v1 - name: Build, tag, and push image to Amazon ECR - id: compute-node-build-image + id: build-push-image env: ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} - ECR_REPOSITORY: upshot-compute-node-staging - IMAGE_TAG: ${{ github.sha }} + ECR_REPOSITORY: ${{github.event.repository.name}} # Naming convention: ECR registry name == GITHUB repo name + MAIN_BRANCH: main # Images from this branch will be tagged as "latest" run: | + IMAGE_TAG="${GITHUB_SHA:0:8}" + EXTRA_IMAGE_TAGS="dev-latest" + + #! Add latest tag only if on MAIN_BRANCH branch + if [[ ${GITHUB_REF} == "refs/heads/${MAIN_BRANCH}" ]]; then + EXTRA_IMAGE_TAGS="${EXTRA_IMAGE_TAGS};latest" + fi + # Build a docker container and push it to ECR so that it can be deployed to ECS. - # To build it with particular BLS_EXTENSION version pass --build-arg "BLS_EXTENSION_VER=RELEASE_NAME" - # If BLS_EXTENSION_VER is not passed will be built with the latest available version docker build -f docker/Dockerfile \ --build-arg "GH_TOKEN=${{ secrets.GHCR_TOKEN }}" \ -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG . docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG - echo "image=$ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG" >> "$GITHUB_OUTPUT" - - # Tag and push with latest - docker tag $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG $ECR_REGISTRY/$ECR_REPOSITORY:latest - docker push $ECR_REGISTRY/$ECR_REPOSITORY:latest + # Build and PUSH additional tags + for tag in $(echo $EXTRA_IMAGE_TAGS| tr ";" "\n"); do + docker tag $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG $ECR_REGISTRY/$ECR_REPOSITORY:$tag + docker push $ECR_REGISTRY/$ECR_REPOSITORY:$tag + done From 62fe1942991c971385c359ee5ca5a1f4d184c317 Mon Sep 17 00:00:00 2001 From: vladupshot <154623109+vladupshot@users.noreply.github.com> Date: Fri, 19 Jan 2024 06:34:47 +1300 Subject: [PATCH 2/4] adjust docker --- docker/Dockerfile | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/docker/Dockerfile b/docker/Dockerfile index 0a6d4e7..ae591f8 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -23,7 +23,8 @@ RUN apt update && \ unzip \ ca-certificates \ gh && \ - rm -rf /var/cache/apt/* + rm -rf /var/cache/apt/* && \ + python3 -m pip install --upgrade pip # libssl-dev \ # - temporary use libssl 1.1 TODO: Should use fresher libssl # libssl 1.1 @@ -37,9 +38,8 @@ RUN GOMPLATE_VER="v3.11.6" && \ chmod 755 /usr/local/bin/gomplate # get the runtime -RUN curl -o ./runtime.tar.gz -sSL https://github.com/blocklessnetwork/runtime/releases/download/v0.3.1/blockless-runtime.ubuntu-20.04.x86_64.tar.gz -RUN mkdir /app/runtime && tar -xvkf ./runtime.tar.gz -C /app/runtime -RUN python3 -m pip install --upgrade pip +RUN curl -o ./runtime.tar.gz -sSL https://github.com/blocklessnetwork/runtime/releases/download/v0.3.1/blockless-runtime.ubuntu-20.04.x86_64.tar.gz && \ + mkdir /app/runtime && tar -xvkf ./runtime.tar.gz -C /app/runtime ARG GH_TOKEN ARG BLS_EXTENSION_VER From a6fc99aa1bf1fb301b7e1000f3070ab8a1f00c50 Mon Sep 17 00:00:00 2001 From: vladupshot <154623109+vladupshot@users.noreply.github.com> Date: Fri, 19 Jan 2024 06:43:56 +1300 Subject: [PATCH 3/4] remove not needed build --- .github/workflows/docker.yaml | 25 ------------------------- 1 file changed, 25 deletions(-) delete mode 100644 .github/workflows/docker.yaml diff --git a/.github/workflows/docker.yaml b/.github/workflows/docker.yaml deleted file mode 100644 index a0612a6..0000000 --- a/.github/workflows/docker.yaml +++ /dev/null @@ -1,25 +0,0 @@ -name: build docker images - -on: - release: - types: [created] - workflow_dispatch: - -jobs: - build: - runs-on: ubuntu-latest - steps: - - uses: actions/setup-go@v3 - with: - go-version: "1.21.0" - check-latest: true - - uses: actions/checkout@v2 - - name: Prepare Release Variables - id: vars - uses: ignite/cli/actions/release/vars@main - - name: build - run: | - GOOS=linux GOARCH=amd64 make - echo "${{ secrets.GHCR_TOKEN }}" | docker login ghcr.io -u "${{ secrets.GHCR_USER }}" --password-stdin - docker build . --tag ghcr.io/${{ github.repository }}:${{ steps.vars.outputs.tag_name }} -f docker/Dockerfile --build-arg "ghcr_token=${{ secrets.GHCR_TOKEN }}" - docker push ghcr.io/${{ github.repository }}:${{ steps.vars.outputs.tag_name }} From 3f8d55c5af125d8e6291d0cd65f9049f06352892 Mon Sep 17 00:00:00 2001 From: vladupshot <154623109+vladupshot@users.noreply.github.com> Date: Fri, 19 Jan 2024 06:49:53 +1300 Subject: [PATCH 4/4] formatting --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index fa21ecb..5cd2823 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,5 +1,5 @@ name: Build Pipeline for Test -'on': +on: - pull_request concurrency: group: ${{ github.head_ref || github.run_id }}