From e1c2835499ed44d474f87c06924d1d32bcf36d2a Mon Sep 17 00:00:00 2001 From: Adam Clark Date: Tue, 4 Nov 2025 14:58:46 +0000 Subject: [PATCH 1/4] try this --- .github/workflows/build-push-ecr.yaml | 62 +++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 .github/workflows/build-push-ecr.yaml diff --git a/.github/workflows/build-push-ecr.yaml b/.github/workflows/build-push-ecr.yaml new file mode 100644 index 000000000..e4fc17555 --- /dev/null +++ b/.github/workflows/build-push-ecr.yaml @@ -0,0 +1,62 @@ +name: Build and Push to AWS ECR + +on: + pull_request: + types: [opened, synchronize, reopened, closed] + workflow_dispatch: + +env: + AWS_REGION: "us-west-2" + ECR_REPOSITORY: 352956043285.dkr.ecr.us-west-2.amazonaws.com/offchain-labs/blockscout + +permissions: + contents: write + id-token: write + +jobs: + build-and-push: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v4 + with: + submodules: recursive + + - name: Configure AWS credentials + uses: aws-actions/configure-aws-credentials@v4 + with: + role-to-assume: "arn:aws:iam::352956043285:role/github-actions" + role-session-name: GitHubActions-${{ github.run_id }} + aws-region: ${{ env.AWS_REGION }} + + - name: Login to Amazon ECR + id: login-ecr + uses: aws-actions/amazon-ecr-login@v2 + with: + registries: "352956043285" + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Extract metadata + id: meta + uses: docker/metadata-action@v5 + with: + images: ${{ steps.login-ecr.outputs.registry }}/${{ env.ECR_REPOSITORY }} + tags: | + type=sha,prefix=${{ github.event.pull_request.head.ref }}-,enable={{is_not_default_branch}} + type=sha,prefix=,enable={{is_default_branch}} + type=raw,value=latest,enable={{is_default_branch}} + + - name: Build and push Docker image + uses: docker/build-push-action@v6 + with: + context: . + file: ./Dockerfile + push: true + platforms: linux/amd64,linux/arm64 + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + cache-from: type=gha + cache-to: type=gha,mode=max From b8745595336bb838247a4d9fb8b79531143bbbf5 Mon Sep 17 00:00:00 2001 From: Adam Clark Date: Tue, 4 Nov 2025 15:05:46 +0000 Subject: [PATCH 2/4] a --- .github/workflows/build-push-ecr.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-push-ecr.yaml b/.github/workflows/build-push-ecr.yaml index e4fc17555..25ddf88b0 100644 --- a/.github/workflows/build-push-ecr.yaml +++ b/.github/workflows/build-push-ecr.yaml @@ -15,7 +15,7 @@ permissions: jobs: build-and-push: - runs-on: ubuntu-latest + runs-on: ocl-default steps: - name: Checkout code From dee70fa54f2b5b7d0ecdd9a9198df21c5e23fed3 Mon Sep 17 00:00:00 2001 From: Adam Clark Date: Tue, 4 Nov 2025 15:07:58 +0000 Subject: [PATCH 3/4] a --- .github/workflows/build-push-ecr.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-push-ecr.yaml b/.github/workflows/build-push-ecr.yaml index 25ddf88b0..c886ab3a0 100644 --- a/.github/workflows/build-push-ecr.yaml +++ b/.github/workflows/build-push-ecr.yaml @@ -26,8 +26,8 @@ jobs: - name: Configure AWS credentials uses: aws-actions/configure-aws-credentials@v4 with: + role-session-name: "SREApplications" role-to-assume: "arn:aws:iam::352956043285:role/github-actions" - role-session-name: GitHubActions-${{ github.run_id }} aws-region: ${{ env.AWS_REGION }} - name: Login to Amazon ECR From 4eb54ac7c356bccede16b9669c4856bc5e8ab2f2 Mon Sep 17 00:00:00 2001 From: Adam Clark Date: Wed, 5 Nov 2025 09:39:48 +0000 Subject: [PATCH 4/4] a --- .github/workflows/build-push-ecr.yaml | 62 --------------------------- docker/Dockerfile | 17 ++++---- 2 files changed, 9 insertions(+), 70 deletions(-) delete mode 100644 .github/workflows/build-push-ecr.yaml diff --git a/.github/workflows/build-push-ecr.yaml b/.github/workflows/build-push-ecr.yaml deleted file mode 100644 index c886ab3a0..000000000 --- a/.github/workflows/build-push-ecr.yaml +++ /dev/null @@ -1,62 +0,0 @@ -name: Build and Push to AWS ECR - -on: - pull_request: - types: [opened, synchronize, reopened, closed] - workflow_dispatch: - -env: - AWS_REGION: "us-west-2" - ECR_REPOSITORY: 352956043285.dkr.ecr.us-west-2.amazonaws.com/offchain-labs/blockscout - -permissions: - contents: write - id-token: write - -jobs: - build-and-push: - runs-on: ocl-default - - steps: - - name: Checkout code - uses: actions/checkout@v4 - with: - submodules: recursive - - - name: Configure AWS credentials - uses: aws-actions/configure-aws-credentials@v4 - with: - role-session-name: "SREApplications" - role-to-assume: "arn:aws:iam::352956043285:role/github-actions" - aws-region: ${{ env.AWS_REGION }} - - - name: Login to Amazon ECR - id: login-ecr - uses: aws-actions/amazon-ecr-login@v2 - with: - registries: "352956043285" - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v3 - - - name: Extract metadata - id: meta - uses: docker/metadata-action@v5 - with: - images: ${{ steps.login-ecr.outputs.registry }}/${{ env.ECR_REPOSITORY }} - tags: | - type=sha,prefix=${{ github.event.pull_request.head.ref }}-,enable={{is_not_default_branch}} - type=sha,prefix=,enable={{is_default_branch}} - type=raw,value=latest,enable={{is_default_branch}} - - - name: Build and push Docker image - uses: docker/build-push-action@v6 - with: - context: . - file: ./Dockerfile - push: true - platforms: linux/amd64,linux/arm64 - tags: ${{ steps.meta.outputs.tags }} - labels: ${{ steps.meta.outputs.labels }} - cache-from: type=gha - cache-to: type=gha,mode=max diff --git a/docker/Dockerfile b/docker/Dockerfile index b4fa2377a..d49fcc096 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -2,11 +2,10 @@ FROM hexpm/elixir:1.14.5-erlang-25.3.2.4-alpine-3.18.2 AS builder WORKDIR /app -RUN apk --no-cache --update add alpine-sdk gmp-dev automake libtool inotify-tools autoconf python3 file gcompat +RUN apk --no-cache --update add \ + alpine-sdk gmp-dev automake libtool inotify-tools autoconf python3 file gcompat libstdc++ curl ca-certificates git make bash -ENV PORT=4000 \ - MIX_ENV="prod" \ - SECRET_KEY_BASE="RMgI4C1HSkxsEjdhtGMfwAHfyT6CKWXOgzCboJflfSm4jeAlic52io05KB6mqzc5" +ENV SECRET_KEY_BASE="RMgI4C1HSkxsEjdhtGMfwAHfyT6CKWXOgzCboJflfSm4jeAlic52io05KB6mqzc5" RUN apk --update add libstdc++ curl ca-certificates gcompat @@ -35,9 +34,11 @@ ADD apps/explorer/mix.exs ./apps/explorer/ ADD apps/ethereum_jsonrpc/mix.exs ./apps/ethereum_jsonrpc/ ADD apps/indexer/mix.exs ./apps/indexer/ +ENV MIX_ENV="prod" ENV MIX_HOME=/opt/mix +RUN ls _build RUN mix local.hex --force -RUN mix do deps.get, local.rebar --force, deps.compile +RUN mix do deps.get, local.rebar --force, deps.compile --skip-umbrella-children ADD apps ./apps ADD config ./config @@ -67,14 +68,14 @@ RUN cd /app/apps/explorer/ && \ apk --update del --force-broken-world alpine-sdk gmp-dev automake libtool inotify-tools autoconf python3 \ || echo failed removing apks -RUN apk add --update git make +RUN apk add --update git make RUN export "CFLAGS=-I/usr/local/include -L/usr/local/lib" && cd deps/ex_secp256k1 && mix deps.get && mix compile RUN mix phx.digest RUN mkdir -p /opt/release \ - && mix release blockscout \ - && mv _build/${MIX_ENV}/rel/blockscout /opt/release + && mix release blockscout \ + && mv _build/${MIX_ENV}/rel/blockscout /opt/release ############################################################## FROM hexpm/elixir:1.14.5-erlang-25.3.2.4-alpine-3.18.2