From 5e4b8d856d72c4ecff717634f2df848109d59726 Mon Sep 17 00:00:00 2001 From: Victor Baranov Date: Fri, 27 Sep 2024 13:23:08 +0300 Subject: [PATCH] chore: Remove old UI from base Docker image (#10828) * chore: Remove old UI from base Docker image * Rename Dockerfile with old UI --- .github/workflows/release.yml | 29 ++++++++++ docker/Dockerfile | 19 +------ docker/oldUI.Dockerfile | 104 ++++++++++++++++++++++++++++++++++ 3 files changed, 135 insertions(+), 17 deletions(-) create mode 100644 docker/oldUI.Dockerfile diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 427836ce38..2057477e2e 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -203,6 +203,35 @@ jobs: RELEASE_VERSION=${{ env.RELEASE_VERSION }} SHRINK_INTERNAL_TRANSACTIONS_ENABLED=true + - name: Build & Push Docker image with an old UI (indexer + API) + uses: docker/build-push-action@v5 + with: + context: . + file: ./docker/oldUI.Dockerfile + push: true + cache-from: type=registry,ref=blockscout/blockscout:buildcache + cache-to: type=registry,ref=blockscout/blockscout:buildcache,mode=max + tags: blockscout/blockscout:${{ env.RELEASE_VERSION }}-with-old-ui + labels: ${{ steps.setup.outputs.docker-labels }} + platforms: | + linux/amd64 + linux/arm64/v8 + build-args: | + DISABLE_WEBAPP=false + API_V1_READ_METHODS_DISABLED=false + API_V1_WRITE_METHODS_DISABLED=false + CACHE_EXCHANGE_RATES_PERIOD= + CACHE_TOTAL_GAS_USAGE_COUNTER_ENABLED= + CACHE_ADDRESS_WITH_BALANCES_UPDATE_INTERVAL= + ADMIN_PANEL_ENABLED=false + DECODE_NOT_A_CONTRACT_CALLS=false + MIXPANEL_URL= + MIXPANEL_TOKEN= + AMPLITUDE_URL= + AMPLITUDE_API_KEY= + BLOCKSCOUT_VERSION=v${{ env.RELEASE_VERSION }}-beta + RELEASE_VERSION=${{ env.RELEASE_VERSION }} + # - name: Send release announcement to Slack workflow # id: slack # uses: slackapi/slack-github-action@v1.24.0 diff --git a/docker/Dockerfile b/docker/Dockerfile index 834c57ff43..edcc990471 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -46,25 +46,11 @@ ADD config ./config ADD rel ./rel ADD *.exs ./ -RUN apk add --update nodejs npm - -# Run forderground build and phoenix digest -RUN mix compile && npm install npm@latest - -# Add blockscout npm deps -RUN cd apps/block_scout_web/assets/ && \ - npm install && \ - npm run deploy && \ - cd /app/apps/explorer/ && \ - npm install && \ - apk update && \ - apk del --force-broken-world alpine-sdk gmp-dev automake libtool inotify-tools autoconf python3 - +# Run backend compilation +RUN mix compile RUN apk add --update git make -RUN mix phx.digest - RUN mkdir -p /opt/release \ && mix release blockscout \ && mv _build/${MIX_ENV}/rel/blockscout /opt/release @@ -94,7 +80,6 @@ RUN apk --no-cache --update add jq curl && \ WORKDIR /app COPY --from=builder --chown=${BLOCKSCOUT_USER}:${BLOCKSCOUT_GROUP} /opt/release/blockscout . -COPY --from=builder --chown=${BLOCKSCOUT_USER}:${BLOCKSCOUT_GROUP} /app/apps/explorer/node_modules ./node_modules COPY --from=builder --chown=${BLOCKSCOUT_USER}:${BLOCKSCOUT_GROUP} /app/config/config_helper.exs ./config/config_helper.exs COPY --from=builder --chown=${BLOCKSCOUT_USER}:${BLOCKSCOUT_GROUP} /app/config/config_helper.exs /app/releases/${RELEASE_VERSION}/config_helper.exs COPY --from=builder --chown=${BLOCKSCOUT_USER}:${BLOCKSCOUT_GROUP} /app/config/assets/precompiles-arbitrum.json ./config/assets/precompiles-arbitrum.json diff --git a/docker/oldUI.Dockerfile b/docker/oldUI.Dockerfile new file mode 100644 index 0000000000..8ee713ac2b --- /dev/null +++ b/docker/oldUI.Dockerfile @@ -0,0 +1,104 @@ +FROM hexpm/elixir:1.16.3-erlang-26.2.5.1-alpine-3.18.7 AS builder + +WORKDIR /app + +ENV MIX_ENV="prod" + +RUN apk --no-cache --update add alpine-sdk gmp-dev automake libtool inotify-tools autoconf python3 file gcompat + +RUN set -ex && \ + apk --update add libstdc++ curl ca-certificates gcompat + +ARG CACHE_EXCHANGE_RATES_PERIOD +ARG API_V1_READ_METHODS_DISABLED +ARG DISABLE_WEBAPP +ARG API_V1_WRITE_METHODS_DISABLED +ARG CACHE_TOTAL_GAS_USAGE_COUNTER_ENABLED +ARG ADMIN_PANEL_ENABLED +ARG CACHE_ADDRESS_WITH_BALANCES_UPDATE_INTERVAL +ARG SESSION_COOKIE_DOMAIN +ARG MIXPANEL_TOKEN +ARG MIXPANEL_URL +ARG AMPLITUDE_API_KEY +ARG AMPLITUDE_URL +ARG CHAIN_TYPE +ENV CHAIN_TYPE=${CHAIN_TYPE} +ARG BRIDGED_TOKENS_ENABLED +ENV BRIDGED_TOKENS_ENABLED=${BRIDGED_TOKENS_ENABLED} +ARG MUD_INDEXER_ENABLED +ENV MUD_INDEXER_ENABLED=${MUD_INDEXER_ENABLED} +ARG SHRINK_INTERNAL_TRANSACTIONS_ENABLED +ENV SHRINK_INTERNAL_TRANSACTIONS_ENABLED=${SHRINK_INTERNAL_TRANSACTIONS_ENABLED} + +# Cache elixir deps +ADD mix.exs mix.lock ./ +ADD apps/block_scout_web/mix.exs ./apps/block_scout_web/ +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_HOME=/opt/mix +RUN mix local.hex --force +RUN mix do deps.get, local.rebar --force, deps.compile + +ADD apps ./apps +ADD config ./config +ADD rel ./rel +ADD *.exs ./ + +RUN apk add --update nodejs npm + +# Run backend compilation and install latest npm +RUN mix compile && npm install npm@latest + +# Add blockscout npm deps +RUN cd apps/block_scout_web/assets/ && \ + npm install && \ + npm run deploy && \ + cd /app/apps/explorer/ && \ + npm install && \ + apk update && \ + apk del --force-broken-world alpine-sdk gmp-dev automake libtool inotify-tools autoconf python3 + + +RUN apk add --update git make + +RUN mix phx.digest + +RUN mkdir -p /opt/release \ + && mix release blockscout \ + && mv _build/${MIX_ENV}/rel/blockscout /opt/release + +############################################################## +FROM hexpm/elixir:1.16.3-erlang-26.2.5.1-alpine-3.18.7 + +ARG RELEASE_VERSION +ENV RELEASE_VERSION=${RELEASE_VERSION} +ARG CHAIN_TYPE +ENV CHAIN_TYPE=${CHAIN_TYPE} +ARG BRIDGED_TOKENS_ENABLED +ENV BRIDGED_TOKENS_ENABLED=${BRIDGED_TOKENS_ENABLED} +ARG SHRINK_INTERNAL_TRANSACTIONS_ENABLED +ENV SHRINK_INTERNAL_TRANSACTIONS_ENABLED=${SHRINK_INTERNAL_TRANSACTIONS_ENABLED} +ARG BLOCKSCOUT_VERSION +ENV BLOCKSCOUT_VERSION=${BLOCKSCOUT_VERSION} +ARG BLOCKSCOUT_USER=blockscout +ARG BLOCKSCOUT_GROUP=blockscout +ARG BLOCKSCOUT_UID=10001 +ARG BLOCKSCOUT_GID=10001 + +RUN apk --no-cache --update add jq curl && \ + addgroup --system --gid ${BLOCKSCOUT_GID} ${BLOCKSCOUT_GROUP} && \ + adduser --system --uid ${BLOCKSCOUT_UID} --ingroup ${BLOCKSCOUT_GROUP} --disabled-password ${BLOCKSCOUT_USER} + +WORKDIR /app + +COPY --from=builder --chown=${BLOCKSCOUT_USER}:${BLOCKSCOUT_GROUP} /opt/release/blockscout . +COPY --from=builder --chown=${BLOCKSCOUT_USER}:${BLOCKSCOUT_GROUP} /app/apps/explorer/node_modules ./node_modules +COPY --from=builder --chown=${BLOCKSCOUT_USER}:${BLOCKSCOUT_GROUP} /app/config/config_helper.exs ./config/config_helper.exs +COPY --from=builder --chown=${BLOCKSCOUT_USER}:${BLOCKSCOUT_GROUP} /app/config/config_helper.exs /app/releases/${RELEASE_VERSION}/config_helper.exs +COPY --from=builder --chown=${BLOCKSCOUT_USER}:${BLOCKSCOUT_GROUP} /app/config/assets/precompiles-arbitrum.json ./config/assets/precompiles-arbitrum.json + +RUN chown -R ${BLOCKSCOUT_USER}:${BLOCKSCOUT_GROUP} /app + +USER ${BLOCKSCOUT_USER}:${BLOCKSCOUT_GROUP}