From be7ec1402b964fa2beb3b693546b27b4ce5c34e6 Mon Sep 17 00:00:00 2001 From: Marcin Date: Mon, 23 Oct 2023 07:02:40 +0200 Subject: [PATCH 1/5] A0-3351: New (dev) env for dashboard. --- .env | 3 ++ .github/actions/build-and-push/action.yaml | 1 + .github/actions/deploy/action.yaml | 7 ++- .../workflows/build-and-deploy-to-devnet.yaml | 48 +++++++++++++++++++ .../build-and-deploy-to-mainnet.yaml | 2 +- .../build-and-deploy-to-testnet.yaml | 8 +--- CONTRIBUTING.md | 22 +-------- src/config/networks.ts | 28 ++++++----- 8 files changed, 76 insertions(+), 43 deletions(-) create mode 100644 .github/workflows/build-and-deploy-to-devnet.yaml diff --git a/.env b/.env index d5062bbf38..b03f6559b3 100644 --- a/.env +++ b/.env @@ -16,6 +16,9 @@ VITE_TERMS_OF_USE="https://alephzero.org/dashboard-terms-of-use/" # Remove Testnet entry from the list of endpoints # VITE_DISABLE_TESTNET=1 +# Remove Devnet entry from the list of endpoints +# VITE_DISABLE_DEVNET=1 + # Enable custom endpoint feature in the endpoint list # VITE_ENABLE_CUSTOM_NETWORK=1 # VITE_CUSTOM_WS_ADDRESS=wss://ws.dev.azero.dev diff --git a/.github/actions/build-and-push/action.yaml b/.github/actions/build-and-push/action.yaml index cea633b092..3b60283f92 100644 --- a/.github/actions/build-and-push/action.yaml +++ b/.github/actions/build-and-push/action.yaml @@ -10,6 +10,7 @@ inputs: environment: type: choice options: + - devnet - testnet - mainnet required: true diff --git a/.github/actions/deploy/action.yaml b/.github/actions/deploy/action.yaml index 7ba8958674..57e7e9ddb6 100644 --- a/.github/actions/deploy/action.yaml +++ b/.github/actions/deploy/action.yaml @@ -9,6 +9,7 @@ inputs: environment: type: choice options: + - devnet - testnet - mainnet required: true @@ -25,7 +26,9 @@ runs: repository: Cardinal-Cryptography/aleph-apps token: ${{ inputs.github_token }} path: "aleph-apps" - ref: ${{ inputs.environment }} + # TODO uncomment before merge + # ref: ${{ inputs.environment == 'devnet' && 'main' || inputs.environment }} + ref: A0-3351 - name: KUSTOMIZE | Init kustomize uses: imranismail/setup-kustomize@v2 @@ -39,7 +42,7 @@ runs: run: | cd aleph-apps/aleph-zero-dashboard/overlays/${{ inputs.environment }}/eu-central-1 kustomize edit set image "aleph-zero-dashboard-image-placeholder=${{ env.DEPLOY_IMAGE }}" - + - name: GIT | Commit changes to aleph-apps repository uses: EndBug/add-and-commit@v5.1.0 env: diff --git a/.github/workflows/build-and-deploy-to-devnet.yaml b/.github/workflows/build-and-deploy-to-devnet.yaml new file mode 100644 index 0000000000..c58c92ab1a --- /dev/null +++ b/.github/workflows/build-and-deploy-to-devnet.yaml @@ -0,0 +1,48 @@ +name: Build, push and deploy Aleph Zero Dashboard to devnet + +on: + workflow_dispatch: + # remove before merge + push: + branches: + - A0-3351 + +jobs: + build-and-push: + name: Build and push + runs-on: ubuntu-20.04 + environment: + name: devnet + steps: + - name: GIT | Checkout + uses: actions/checkout@v3 + + - name: Build and push devnet image + uses: ./.github/actions/build-and-push + id: build-devnet + with: + environment: devnet + build_envs: 'VITE_DISABLE_MAINNET=1 VITE_DISABLE_TESTNET=1 VITE_DISABLE_FIAT=1' + aws_mainnet_access_key_id: ${{ secrets.AWS_MAINNET_ACCESS_KEY_ID }} + aws_mainnet_secret_access_key: ${{ secrets.AWS_MAINNET_SECRET_ACCESS_KEY }} + outputs: + image_tag: ${{ steps.build-devnet.outputs.image_tag }} + + deploy-to-devnet: + name: Deploy to devnet + runs-on: ubuntu-20.04 + needs: [build-and-push] + environment: + name: devnet + steps: + - name: GIT | Checkout + uses: actions/checkout@v3 + + - name: Deploy Aleph Zero Dashboard to Devnet + uses: ./.github/actions/deploy + id: deploy-devnet + with: + environment: devnet + kustomize_version: ${{ vars.KUSTOMIZE_VERSION }} + image_tag: ${{ needs.build-and-push.outputs.image_tag }} + github_token: ${{ secrets.CI_GH_TOKEN }} diff --git a/.github/workflows/build-and-deploy-to-mainnet.yaml b/.github/workflows/build-and-deploy-to-mainnet.yaml index 492eff3772..aefb7007bd 100644 --- a/.github/workflows/build-and-deploy-to-mainnet.yaml +++ b/.github/workflows/build-and-deploy-to-mainnet.yaml @@ -18,7 +18,7 @@ jobs: id: build_mainnet with: environment: mainnet - build_envs: 'VITE_DISABLE_FIAT=1 VITE_DISABLE_TESTNET=1' + build_envs: 'VITE_DISABLE_FIAT=1 VITE_DISABLE_TESTNET=1 VITE_DISABLE_DEVNET=1' aws_mainnet_access_key_id: ${{ secrets.AWS_MAINNET_ACCESS_KEY_ID }} aws_mainnet_secret_access_key: ${{ secrets.AWS_MAINNET_SECRET_ACCESS_KEY }} outputs: diff --git a/.github/workflows/build-and-deploy-to-testnet.yaml b/.github/workflows/build-and-deploy-to-testnet.yaml index 89c8938ba8..46332707d8 100644 --- a/.github/workflows/build-and-deploy-to-testnet.yaml +++ b/.github/workflows/build-and-deploy-to-testnet.yaml @@ -3,12 +3,6 @@ name: Build, push and deploy Aleph Zero Dashboard to testnet on: workflow_dispatch: - push: - paths-ignore: - - '*.md' - branches: - - master - jobs: build_and_push: name: Build and push @@ -24,7 +18,7 @@ jobs: id: build_testnet with: environment: testnet - build_envs: 'VITE_DISABLE_MAINNET=1 VITE_DISABLE_FIAT=1' + build_envs: 'VITE_DISABLE_MAINNET=1 VITE_DISABLE_FIAT=1 VITE_DISABLE_DEVNET=1' aws_mainnet_access_key_id: ${{ secrets.AWS_MAINNET_ACCESS_KEY_ID }} aws_mainnet_secret_access_key: ${{ secrets.AWS_MAINNET_SECRET_ACCESS_KEY }} outputs: diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 69425a631d..95d9d57fd4 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -17,27 +17,7 @@ Reach out to ross@parity.io for clarification of any content within this documen ## Environment Variables -Optionally apply the following environment variables in an environment file such as `.env` or with `yarn build` to customize the build of staking dashboard: - -``` -# disable all mentioning of fiat values and token prices -VITE_DISABLE_FIAT=1 - -# display an organization label in the network bar -VITE_ORGANISATION="© Parity Technologies" - -# provide a privacy policy url in the network bar -VITE_PRIVACY_URL=https://... - -# disable mainnet / testnet network (for e.g. testnet deployment) -VITE_DISABLE_MAINNET=1 -VITE_DISABLE_TESTNET=1 - -# add connection to a custom network (for example a feature net, local and devnet are avaliable by default in a development build) -VITE_ENABLE_CUSTOM_NETWORK=1 -VITE_CUSTOM_WS_ADDRESS=wss://ws.test.azero.dev - -``` +Optionally apply the following environment variables in an environment file, see [`.env`](.env) for example. ## Config Files diff --git a/src/config/networks.ts b/src/config/networks.ts index 1e8ea5edab..64286f09fa 100644 --- a/src/config/networks.ts +++ b/src/config/networks.ts @@ -189,11 +189,11 @@ if (import.meta.env.VITE_ENABLE_CUSTOM_NETWORK === '1') { NetworkList[azeroCustom.name] = azeroCustom; } -if (import.meta.env.MODE === 'development') { - const azeroLocal = { - name: 'Aleph Zero Local', +if (import.meta.env.VITE_DISABLE_DEVNET !== '1') { + const azeroDevnet = { + name: 'Aleph Zero Devnet', endpoints: { - rpc: 'ws://localhost:9944', + rpc: 'wss://ws.dev.azero.dev', lightClient: null, }, namespace: '', @@ -219,7 +219,7 @@ if (import.meta.env.MODE === 'development') { dark: 'rgb(0, 204, 171, 0.33)', }, }, - unit: 'LZERO', + unit: 'DZERO', units: 12, ss58: 42, brand: { @@ -235,7 +235,7 @@ if (import.meta.env.MODE === 'development') { }, }, api: { - unit: 'LZERO', + unit: 'DZERO', priceTicker: 'DOTUSDT', // this is for compatibility with binance endpoint, it's pinged for current token value, but we don't display that value }, params: { @@ -245,10 +245,15 @@ if (import.meta.env.MODE === 'development') { }, defaultFeeReserve: 0.1, } as const; - const azeroDevnet = { - name: 'Aleph Zero Devnet', + + NetworkList[azeroDevnet.name] = azeroDevnet; +} + +if (import.meta.env.MODE === 'development') { + const azeroLocal = { + name: 'Aleph Zero Local', endpoints: { - rpc: 'wss://ws.dev.azero.dev', + rpc: 'ws://localhost:9944', lightClient: null, }, namespace: '', @@ -274,7 +279,7 @@ if (import.meta.env.MODE === 'development') { dark: 'rgb(0, 204, 171, 0.33)', }, }, - unit: 'DZERO', + unit: 'LZERO', units: 12, ss58: 42, brand: { @@ -290,7 +295,7 @@ if (import.meta.env.MODE === 'development') { }, }, api: { - unit: 'DZERO', + unit: 'LZERO', priceTicker: 'DOTUSDT', // this is for compatibility with binance endpoint, it's pinged for current token value, but we don't display that value }, params: { @@ -302,5 +307,4 @@ if (import.meta.env.MODE === 'development') { } as const; NetworkList[azeroLocal.name] = azeroLocal; - NetworkList[azeroDevnet.name] = azeroDevnet; } From d2dbbf5ee9f743e3a87fcee5d23328c9d61b73a7 Mon Sep 17 00:00:00 2001 From: Marcin Date: Mon, 23 Oct 2023 07:06:38 +0200 Subject: [PATCH 2/5] A0-3351: Fix correct docker file and remove not used one --- Dockerfile | 14 -------------- docker/Dockerfile | 4 ++-- 2 files changed, 2 insertions(+), 16 deletions(-) delete mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile deleted file mode 100644 index 6156e66c65..0000000000 --- a/Dockerfile +++ /dev/null @@ -1,14 +0,0 @@ -FROM node:buster as BUILDER - -WORKDIR /app -COPY . . - -RUN yarn install -RUN export $BUILD_ENVS && yarn build - -# -------------------------------------------------- -FROM nginx - -COPY --from=BUILDER /app/build /usr/share/nginx/html - -EXPOSE 80 diff --git a/docker/Dockerfile b/docker/Dockerfile index d6d5802a15..5bbbc429f6 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -8,8 +8,8 @@ RUN apk add curl git gnupg ca-certificates WORKDIR /apps COPY . . -RUN npm install --legacy-peer-deps -RUN export $BUILD_ENVS && npm run build +RUN yarn install +RUN export $BUILD_ENVS && yarn build # =========================================================== FROM nginx:stable-alpine From b74a6f8e08f62cebf2f873869a7dd064e1ca3e71 Mon Sep 17 00:00:00 2001 From: Marcin Date: Mon, 23 Oct 2023 07:10:29 +0200 Subject: [PATCH 3/5] A0-3351: Testing in progress --- .github/actions/deploy/action.yaml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/actions/deploy/action.yaml b/.github/actions/deploy/action.yaml index 57e7e9ddb6..77a5994f2a 100644 --- a/.github/actions/deploy/action.yaml +++ b/.github/actions/deploy/action.yaml @@ -53,4 +53,6 @@ runs: message: 'Updating aleph-zero-dashboard ${{ inputs.environment }} docker image tag: ${{ inputs.image_tag }}' add: '*.yaml' cwd: 'aleph-apps' - branch: ${{ inputs.environment }} + # TODO uncomment before merge + # branch: ${{ inputs.environment == 'devnet' && 'main' || inputs.environment }} + branch: A0-3351 From 2976923b2dc4a847e1ff981158face450565c597 Mon Sep 17 00:00:00 2001 From: Marcin Date: Mon, 23 Oct 2023 14:31:17 +0200 Subject: [PATCH 4/5] A0-3351: Revert testing changes --- .github/actions/deploy/action.yaml | 8 ++------ .github/workflows/build-and-deploy-to-devnet.yaml | 3 +-- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/.github/actions/deploy/action.yaml b/.github/actions/deploy/action.yaml index 77a5994f2a..336ffcc365 100644 --- a/.github/actions/deploy/action.yaml +++ b/.github/actions/deploy/action.yaml @@ -26,9 +26,7 @@ runs: repository: Cardinal-Cryptography/aleph-apps token: ${{ inputs.github_token }} path: "aleph-apps" - # TODO uncomment before merge - # ref: ${{ inputs.environment == 'devnet' && 'main' || inputs.environment }} - ref: A0-3351 + ref: ${{ inputs.environment == 'devnet' && 'main' || inputs.environment }} - name: KUSTOMIZE | Init kustomize uses: imranismail/setup-kustomize@v2 @@ -53,6 +51,4 @@ runs: message: 'Updating aleph-zero-dashboard ${{ inputs.environment }} docker image tag: ${{ inputs.image_tag }}' add: '*.yaml' cwd: 'aleph-apps' - # TODO uncomment before merge - # branch: ${{ inputs.environment == 'devnet' && 'main' || inputs.environment }} - branch: A0-3351 + branch: ${{ inputs.environment == 'devnet' && 'main' || inputs.environment }} diff --git a/.github/workflows/build-and-deploy-to-devnet.yaml b/.github/workflows/build-and-deploy-to-devnet.yaml index c58c92ab1a..28e6330f17 100644 --- a/.github/workflows/build-and-deploy-to-devnet.yaml +++ b/.github/workflows/build-and-deploy-to-devnet.yaml @@ -2,10 +2,9 @@ name: Build, push and deploy Aleph Zero Dashboard to devnet on: workflow_dispatch: - # remove before merge push: branches: - - A0-3351 + - master jobs: build-and-push: From df4b55d4242f31f23b7976bc4e312afb61844117 Mon Sep 17 00:00:00 2001 From: Marcin Date: Tue, 24 Oct 2023 08:34:58 +0200 Subject: [PATCH 5/5] A0-3351: Review remarks --- .github/workflows/build-and-deploy-to-devnet.yaml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build-and-deploy-to-devnet.yaml b/.github/workflows/build-and-deploy-to-devnet.yaml index 28e6330f17..df08bce985 100644 --- a/.github/workflows/build-and-deploy-to-devnet.yaml +++ b/.github/workflows/build-and-deploy-to-devnet.yaml @@ -5,6 +5,9 @@ on: push: branches: - master + paths-ignore: + - ".github/**" + - "*.md" jobs: build-and-push: @@ -21,7 +24,7 @@ jobs: id: build-devnet with: environment: devnet - build_envs: 'VITE_DISABLE_MAINNET=1 VITE_DISABLE_TESTNET=1 VITE_DISABLE_FIAT=1' + build_envs: 'VITE_DISABLE_FIAT=1' aws_mainnet_access_key_id: ${{ secrets.AWS_MAINNET_ACCESS_KEY_ID }} aws_mainnet_secret_access_key: ${{ secrets.AWS_MAINNET_SECRET_ACCESS_KEY }} outputs: