From 9d06192f0a7ef5e1a07c00e8ec661332d2521649 Mon Sep 17 00:00:00 2001 From: "Felix C. Morency" <1102868+fmorency@users.noreply.github.com> Date: Tue, 19 Nov 2024 10:56:31 -0500 Subject: [PATCH 01/18] ci: testnet docker image --- .github/workflows/docker.yml | 43 ++++++++++++++++++ .gitignore | 4 +- Dockerfile | 86 ++++++++++++++++++++++++++++++++++++ next.config.js | 1 + package.json | 6 +-- 5 files changed, 134 insertions(+), 6 deletions(-) create mode 100644 .github/workflows/docker.yml create mode 100644 Dockerfile diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml new file mode 100644 index 00000000..2020a1c5 --- /dev/null +++ b/.github/workflows/docker.yml @@ -0,0 +1,43 @@ +name: Build and Push Docker Image + +on: + push +# branches: +# - main + +jobs: + build-and-push: + runs-on: ubuntu-latest + environment: testnet + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Log in to Docker Hub + uses: docker/login-action@v3 + with: + username: ${{ vars.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Build and push Docker image + uses: docker/build-push-action@v6 + with: + context: . + push: true + tags: liftedinit/manifest-app-testnet:latest + build-args: | + "NEXT_PUBLIC_CHAIN=${{ vars.NEXT_PUBLIC_CHAIN }}" + "NEXT_PUBLIC_CHAIN_ID=${{ vars.NEXT_PUBLIC_CHAIN_ID }}" + "NEXT_PUBLIC_TESTNET_CHAIN_ID=${{ vars.NEXT_PUBLIC_TESTNET_CHAIN_ID }}" + "NEXT_PUBLIC_MAINNET_RPC_URL=${{ vars.NEXT_PUBLIC_MAINNET_RPC_URL }}" + "NEXT_PUBLIC_TESTNET_RPC_URL=${{ vars.NEXT_PUBLIC_TESTNET_RPC_URL }}" + "NEXT_PUBLIC_MAINNET_API_URL=${{ vars.NEXT_PUBLIC_MAINNET_API_URL }}" + "NEXT_PUBLIC_TESTNET_API_URL=${{ vars.NEXT_PUBLIC_TESTNET_API_URL }}" + secrets: | + "ably_api_key=${{ secrets.NEXT_PUBLIC_ABLY_API_KEY }}" + "walletconnect_key=${{ secrets.NEXT_PUBLIC_WALLETCONNECT_KEY }}" + "web3auth_key=${{ secrets.NEXT_PUBLIC_WEB3_CLIENT_ID }}" diff --git a/.gitignore b/.gitignore index d4819365..d9e2efa5 100644 --- a/.gitignore +++ b/.gitignore @@ -26,9 +26,7 @@ yarn-error.log* .pnpm-debug.log* # local env files -.env*.local -.env -/.env +.env* # vercel .vercel diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..a6235f3c --- /dev/null +++ b/Dockerfile @@ -0,0 +1,86 @@ +# syntax=docker.io/docker/dockerfile:1 + +FROM oven/bun:slim AS base +RUN --mount=type=secret,id=ably_api_key,env=NEXT_PUBLIC_ABLY_API_KEY \ + --mount=type=secret,id=walletconnect_key,env=NEXT_PUBLIC_WALLETCONNECT_KEY \ + --mount=type=secret,id=web3auth_key,env=NEXT_PUBLIC_WEB3_CLIENT_ID + +ARG NEXT_PUBLIC_CHAIN +ARG NEXT_PUBLIC_CHAIN_ID +ARG NEXT_PUBLIC_TESTNET_CHAIN_ID +ARG NEXT_PUBLIC_MAINNET_RPC_URL +ARG NEXT_PUBLIC_TESTNET_RPC_URL +ARG NEXT_PUBLIC_MAINNET_API_URL +ARG NEXT_PUBLIC_TESTNET_API_URL + +ENV NEXT_PUBLIC_CHAIN=${NEXT_PUBLIC_CHAIN} +ENV NEXT_PUBLIC_CHAIN_ID=${NEXT_PUBLIC_CHAIN_ID} +ENV NEXT_PUBLIC_TESTNET_CHAIN_ID=${NEXT_PUBLIC_TESTNET_CHAIN_ID} +ENV NEXT_PUBLIC_MAINNET_RPC_URL=${NEXT_PUBLIC_MAINNET_RPC_URL} +ENV NEXT_PUBLIC_TESTNET_RPC_URL=${NEXT_PUBLIC_TESTNET_RPC_URL} +ENV NEXT_PUBLIC_MAINNET_API_URL=${NEXT_PUBLIC_MAINNET_API_URL} +ENV NEXT_PUBLIC_TESTNET_API_URL=${NEXT_PUBLIC_TESTNET_API_URL} + + +# Install dependencies only when needed +FROM base AS deps +WORKDIR /app + +# Install dependencies based on the preferred package manager +COPY package.json yarn.lock* package-lock.json* pnpm-lock.yaml* .npmrc* bun.lockb ./ +RUN \ + if [ -f yarn.lock ]; then yarn --frozen-lockfile; \ + elif [ -f package-lock.json ]; then npm ci; \ + elif [ -f pnpm-lock.yaml ]; then corepack enable pnpm && pnpm i --frozen-lockfile; \ + elif [ -f bun.lockb ]; then bun install --no-save; \ + else echo "Lockfile not found." && exit 1; \ + fi + + +# Rebuild the source code only when needed +FROM base AS builder +WORKDIR /app +COPY --from=deps /app/node_modules ./node_modules +COPY . . + +# Next.js collects completely anonymous telemetry data about general usage. +# Learn more here: https://nextjs.org/telemetry +# Uncomment the following line in case you want to disable telemetry during the build. +ENV NEXT_TELEMETRY_DISABLED=1 + +RUN \ + if [ -f yarn.lock ]; then yarn run build; \ + elif [ -f package-lock.json ]; then npm run build; \ + elif [ -f pnpm-lock.yaml ]; then corepack enable pnpm && pnpm run build; \ + elif [ -f bun.lockb ]; then bun run build; \ + else echo "Lockfile not found." && exit 1; \ + fi + +# Production image, copy all the files and run next +FROM base AS runner +WORKDIR /app + +ENV NODE_ENV=production +# Uncomment the following line in case you want to disable telemetry during runtime. +ENV NEXT_TELEMETRY_DISABLED=1 + +RUN addgroup --system --gid 1001 nodejs +RUN adduser --system --uid 1001 nextjs + +COPY --from=builder /app/public ./public + +# Automatically leverage output traces to reduce image size +# https://nextjs.org/docs/advanced-features/output-file-tracing +COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./ +COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static + +USER nextjs + +EXPOSE 3000 + +ENV PORT=3000 + +# server.js is created by next build from the standalone output +# https://nextjs.org/docs/pages/api-reference/next-config-js/output +ENV HOSTNAME="0.0.0.0" +CMD ["node", "server.js"] diff --git a/next.config.js b/next.config.js index 73968472..c58d0fbe 100644 --- a/next.config.js +++ b/next.config.js @@ -1,5 +1,6 @@ /** @type {import('next').NextConfig} */ const nextConfig = { + output: 'standalone', reactStrictMode: true, swcMinify: true, typescript: { diff --git a/package.json b/package.json index 3e98d793..c87d2145 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,5 @@ { - "name": "@chalabi/manifest-app", + "name": "@liftedinit/manifest-app", "version": "0.0.1", "private": false, "description": "An application to interact with the Manifest Chain", @@ -15,11 +15,11 @@ "test:coverage:lcov": "bun run test:coverage --coverage-reporter=lcov --coverage-dir ./coverage", "coverage:upload": "codecov" }, - "author": "Joseph Chalabi", + "author": "The Lifted Initiative", "license": "MIT", "repository": { "type": "git", - "url": "https://github.com/chalabi2/manifest-app" + "url": "https://github.com/liftedinit/manifest-app" }, "resolutions": { "react": "18.2.0", From b74eb4e30916b7c34cebd6f6088058486cb91d75 Mon Sep 17 00:00:00 2001 From: "Felix C. Morency" <1102868+fmorency@users.noreply.github.com> Date: Tue, 19 Nov 2024 11:02:49 -0500 Subject: [PATCH 02/18] ci: run on PR (test) --- .github/workflows/docker.yml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 2020a1c5..9df809da 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -1,9 +1,10 @@ name: Build and Push Docker Image -on: - push +#on: +# push: # branches: # - main +on: [push, pull_request] jobs: build-and-push: @@ -28,7 +29,7 @@ jobs: with: context: . push: true - tags: liftedinit/manifest-app-testnet:latest + tags: lifted/manifest-app:testnet build-args: | "NEXT_PUBLIC_CHAIN=${{ vars.NEXT_PUBLIC_CHAIN }}" "NEXT_PUBLIC_CHAIN_ID=${{ vars.NEXT_PUBLIC_CHAIN_ID }}" From 59f98d5578f8ec9666469adf5f401d46fe790762 Mon Sep 17 00:00:00 2001 From: "Felix C. Morency" <1102868+fmorency@users.noreply.github.com> Date: Tue, 19 Nov 2024 11:04:12 -0500 Subject: [PATCH 03/18] fix: ci environment --- .github/workflows/docker.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 9df809da..54970b43 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -9,7 +9,7 @@ on: [push, pull_request] jobs: build-and-push: runs-on: ubuntu-latest - environment: testnet + environment: "Production - Testnet" steps: - name: Checkout repository From 45195d5d04adf401231ef445373ed6cebb51b31e Mon Sep 17 00:00:00 2001 From: "Felix C. Morency" <1102868+fmorency@users.noreply.github.com> Date: Tue, 19 Nov 2024 11:10:52 -0500 Subject: [PATCH 04/18] fix: prettier --- .github/workflows/docker.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 54970b43..ea587589 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -9,7 +9,7 @@ on: [push, pull_request] jobs: build-and-push: runs-on: ubuntu-latest - environment: "Production - Testnet" + environment: 'Production - Testnet' steps: - name: Checkout repository From f4c615b20fd5298a81579742583138f6515f7791 Mon Sep 17 00:00:00 2001 From: "Felix C. Morency" <1102868+fmorency@users.noreply.github.com> Date: Tue, 19 Nov 2024 11:13:20 -0500 Subject: [PATCH 05/18] build: debug --- .github/workflows/docker.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index ea587589..5a6f18de 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -18,6 +18,9 @@ jobs: - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 + - name: List env + run: env + - name: Log in to Docker Hub uses: docker/login-action@v3 with: From a4c7088cba063ff23c4ec263649547660dfc6d6f Mon Sep 17 00:00:00 2001 From: "Felix C. Morency" <1102868+fmorency@users.noreply.github.com> Date: Tue, 19 Nov 2024 11:17:53 -0500 Subject: [PATCH 06/18] build: remove debug --- .github/workflows/docker.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 5a6f18de..ea587589 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -18,9 +18,6 @@ jobs: - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 - - name: List env - run: env - - name: Log in to Docker Hub uses: docker/login-action@v3 with: From c8c0153cba6e03cbd1c15be779ef42a8ccb586d2 Mon Sep 17 00:00:00 2001 From: "Felix C. Morency" <1102868+fmorency@users.noreply.github.com> Date: Tue, 19 Nov 2024 11:26:55 -0500 Subject: [PATCH 07/18] ci: debug vars --- .github/workflows/docker.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index ea587589..bad3b8ad 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -24,6 +24,9 @@ jobs: username: ${{ vars.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} + - name: debug vars + run: env + - name: Build and push Docker image uses: docker/build-push-action@v6 with: From c6115f1994b3d66a10cea82c9e392e58cf8978dc Mon Sep 17 00:00:00 2001 From: "Felix C. Morency" <1102868+fmorency@users.noreply.github.com> Date: Tue, 19 Nov 2024 11:36:02 -0500 Subject: [PATCH 08/18] fix(ci): vars and secrets, maybe --- .github/workflows/docker.yml | 34 +++++++++++++++++++++------------- 1 file changed, 21 insertions(+), 13 deletions(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index bad3b8ad..15a34356 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -24,24 +24,32 @@ jobs: username: ${{ vars.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} - - name: debug vars - run: env - - name: Build and push Docker image uses: docker/build-push-action@v6 + env: + NEXT_PUBLIC_CHAIN: ${{ vars.NEXT_PUBLIC_CHAIN }} + NEXT_PUBLIC_CHAIN_ID: ${{ vars.NEXT_PUBLIC_CHAIN_ID }} + NEXT_PUBLIC_TESTNET_CHAIN_ID: ${{ vars.NEXT_PUBLIC_TESTNET_CHAIN_ID }} + NEXT_PUBLIC_MAINNET_RPC_URL: ${{ vars.NEXT_PUBLIC_MAINNET_RPC_URL }} + NEXT_PUBLIC_TESTNET_RPC_URL: ${{ vars.NEXT_PUBLIC_TESTNET_RPC_URL }} + NEXT_PUBLIC_MAINNET_API_URL: ${{ vars.NEXT_PUBLIC_MAINNET_API_URL }} + NEXT_PUBLIC_TESTNET_API_URL: ${{ vars.NEXT_PUBLIC_TESTNET_API_URL }} + ABLY_API_KEY: ${{ secrets.NEXT_PUBLIC_ABLY_API_KEY }} + WALLETCONNECT_KEY: ${{ secrets.NEXT_PUBLIC_WALLETCONNECT_KEY }} + WEB3_CLIENT_ID: ${{ secrets.NEXT_PUBLIC_WEB3_CLIENT_ID }} with: context: . push: true tags: lifted/manifest-app:testnet build-args: | - "NEXT_PUBLIC_CHAIN=${{ vars.NEXT_PUBLIC_CHAIN }}" - "NEXT_PUBLIC_CHAIN_ID=${{ vars.NEXT_PUBLIC_CHAIN_ID }}" - "NEXT_PUBLIC_TESTNET_CHAIN_ID=${{ vars.NEXT_PUBLIC_TESTNET_CHAIN_ID }}" - "NEXT_PUBLIC_MAINNET_RPC_URL=${{ vars.NEXT_PUBLIC_MAINNET_RPC_URL }}" - "NEXT_PUBLIC_TESTNET_RPC_URL=${{ vars.NEXT_PUBLIC_TESTNET_RPC_URL }}" - "NEXT_PUBLIC_MAINNET_API_URL=${{ vars.NEXT_PUBLIC_MAINNET_API_URL }}" - "NEXT_PUBLIC_TESTNET_API_URL=${{ vars.NEXT_PUBLIC_TESTNET_API_URL }}" + "NEXT_PUBLIC_CHAIN=$NEXT_PUBLIC_CHAIN" + "NEXT_PUBLIC_CHAIN_ID=$NEXT_PUBLIC_CHAIN_ID" + "NEXT_PUBLIC_TESTNET_CHAIN_ID=$NEXT_PUBLIC_TESTNET_CHAIN_ID" + "NEXT_PUBLIC_MAINNET_RPC_URL=$NEXT_PUBLIC_MAINNET_RPC_URL" + "NEXT_PUBLIC_TESTNET_RPC_URL=$NEXT_PUBLIC_TESTNET_RPC_URL" + "NEXT_PUBLIC_MAINNET_API_URL=$NEXT_PUBLIC_MAINNET_API_URL" + "NEXT_PUBLIC_TESTNET_API_URL=$NEXT_PUBLIC_TESTNET_API_URL" secrets: | - "ably_api_key=${{ secrets.NEXT_PUBLIC_ABLY_API_KEY }}" - "walletconnect_key=${{ secrets.NEXT_PUBLIC_WALLETCONNECT_KEY }}" - "web3auth_key=${{ secrets.NEXT_PUBLIC_WEB3_CLIENT_ID }}" + "ably_api_key=$ABLY_API_KEY" + "walletconnect_key=$WALLETCONNECT_KEY" + "web3auth_key=$WEB3_CLIENT_ID" From 2255b9a492d8c1e8b8e87d19e8b68c7f68179c18 Mon Sep 17 00:00:00 2001 From: "Felix C. Morency" <1102868+fmorency@users.noreply.github.com> Date: Tue, 19 Nov 2024 11:45:26 -0500 Subject: [PATCH 09/18] ci: debug --- Dockerfile | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/Dockerfile b/Dockerfile index a6235f3c..49f02a9b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -21,6 +21,14 @@ ENV NEXT_PUBLIC_TESTNET_RPC_URL=${NEXT_PUBLIC_TESTNET_RPC_URL} ENV NEXT_PUBLIC_MAINNET_API_URL=${NEXT_PUBLIC_MAINNET_API_URL} ENV NEXT_PUBLIC_TESTNET_API_URL=${NEXT_PUBLIC_TESTNET_API_URL} +RUN echo Base: $NEXT_PUBLIC_CHAIN +RUN echo Base: $NEXT_PUBLIC_CHAIN_ID +RUN echo Base: $NEXT_PUBLIC_TESTNET_CHAIN_ID +RUN echo Base: $NEXT_PUBLIC_MAINNET_RPC_URL +RUN echo Base: $NEXT_PUBLIC_TESTNET_RPC_URL +RUN echo Base: $NEXT_PUBLIC_MAINNET_API_URL +RUN echo Base: $NEXT_PUBLIC_TESTNET_API_URL + # Install dependencies only when needed FROM base AS deps @@ -48,6 +56,14 @@ COPY . . # Uncomment the following line in case you want to disable telemetry during the build. ENV NEXT_TELEMETRY_DISABLED=1 +RUN echo Builder: $NEXT_PUBLIC_CHAIN +RUN echo Builder: $NEXT_PUBLIC_CHAIN_ID +RUN echo Builder: $NEXT_PUBLIC_TESTNET_CHAIN_ID +RUN echo Builder: $NEXT_PUBLIC_MAINNET_RPC_URL +RUN echo Builder: $NEXT_PUBLIC_TESTNET_RPC_URL +RUN echo Builder: $NEXT_PUBLIC_MAINNET_API_URL +RUN echo Builder: $NEXT_PUBLIC_TESTNET_API_URL + RUN \ if [ -f yarn.lock ]; then yarn run build; \ elif [ -f package-lock.json ]; then npm run build; \ From c804128cf1798d80159d0eb177026823c23c1965 Mon Sep 17 00:00:00 2001 From: "Felix C. Morency" <1102868+fmorency@users.noreply.github.com> Date: Tue, 19 Nov 2024 11:47:52 -0500 Subject: [PATCH 10/18] ci: debug --- .github/workflows/docker.yml | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 15a34356..d0b2547a 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -24,6 +24,30 @@ jobs: username: ${{ vars.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} + - name: Print env + env: + NEXT_PUBLIC_CHAIN: ${{ vars.NEXT_PUBLIC_CHAIN }} + NEXT_PUBLIC_CHAIN_ID: ${{ vars.NEXT_PUBLIC_CHAIN_ID }} + NEXT_PUBLIC_TESTNET_CHAIN_ID: ${{ vars.NEXT_PUBLIC_TESTNET_CHAIN_ID }} + NEXT_PUBLIC_MAINNET_RPC_URL: ${{ vars.NEXT_PUBLIC_MAINNET_RPC_URL }} + NEXT_PUBLIC_TESTNET_RPC_URL: ${{ vars.NEXT_PUBLIC_TESTNET_RPC_URL }} + NEXT_PUBLIC_MAINNET_API_URL: ${{ vars.NEXT_PUBLIC_MAINNET_API_URL }} + NEXT_PUBLIC_TESTNET_API_URL: ${{ vars.NEXT_PUBLIC_TESTNET_API_URL }} + ABLY_API_KEY: ${{ secrets.NEXT_PUBLIC_ABLY_API_KEY }} + WALLETCONNECT_KEY: ${{ secrets.NEXT_PUBLIC_WALLETCONNECT_KEY }} + WEB3_CLIENT_ID: ${{ secrets.NEXT_PUBLIC_WEB3_CLIENT_ID }} + run: | + echo $NEXT_PUBLIC_CHAIN + echo $NEXT_PUBLIC_CHAIN_ID + echo $NEXT_PUBLIC_TESTNET_CHAIN_ID + echo $NEXT_PUBLIC_MAINNET_RPC_URL + echo $NEXT_PUBLIC_TESTNET_RPC_URL + echo $NEXT_PUBLIC_MAINNET_API_URL + echo $NEXT_PUBLIC_TESTNET_API_URL + echo $ABLY_API_KEY + echo $WALLETCONNECT_KEY + echo $WEB3_CLIENT_ID + - name: Build and push Docker image uses: docker/build-push-action@v6 env: From 429a9a9ccd49a259fe17235c42e53c4226024f17 Mon Sep 17 00:00:00 2001 From: "Felix C. Morency" <1102868+fmorency@users.noreply.github.com> Date: Tue, 19 Nov 2024 11:50:44 -0500 Subject: [PATCH 11/18] ci: debug --- .github/workflows/docker.yml | 26 +------------------------- 1 file changed, 1 insertion(+), 25 deletions(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index d0b2547a..64465fa0 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -24,30 +24,6 @@ jobs: username: ${{ vars.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} - - name: Print env - env: - NEXT_PUBLIC_CHAIN: ${{ vars.NEXT_PUBLIC_CHAIN }} - NEXT_PUBLIC_CHAIN_ID: ${{ vars.NEXT_PUBLIC_CHAIN_ID }} - NEXT_PUBLIC_TESTNET_CHAIN_ID: ${{ vars.NEXT_PUBLIC_TESTNET_CHAIN_ID }} - NEXT_PUBLIC_MAINNET_RPC_URL: ${{ vars.NEXT_PUBLIC_MAINNET_RPC_URL }} - NEXT_PUBLIC_TESTNET_RPC_URL: ${{ vars.NEXT_PUBLIC_TESTNET_RPC_URL }} - NEXT_PUBLIC_MAINNET_API_URL: ${{ vars.NEXT_PUBLIC_MAINNET_API_URL }} - NEXT_PUBLIC_TESTNET_API_URL: ${{ vars.NEXT_PUBLIC_TESTNET_API_URL }} - ABLY_API_KEY: ${{ secrets.NEXT_PUBLIC_ABLY_API_KEY }} - WALLETCONNECT_KEY: ${{ secrets.NEXT_PUBLIC_WALLETCONNECT_KEY }} - WEB3_CLIENT_ID: ${{ secrets.NEXT_PUBLIC_WEB3_CLIENT_ID }} - run: | - echo $NEXT_PUBLIC_CHAIN - echo $NEXT_PUBLIC_CHAIN_ID - echo $NEXT_PUBLIC_TESTNET_CHAIN_ID - echo $NEXT_PUBLIC_MAINNET_RPC_URL - echo $NEXT_PUBLIC_TESTNET_RPC_URL - echo $NEXT_PUBLIC_MAINNET_API_URL - echo $NEXT_PUBLIC_TESTNET_API_URL - echo $ABLY_API_KEY - echo $WALLETCONNECT_KEY - echo $WEB3_CLIENT_ID - - name: Build and push Docker image uses: docker/build-push-action@v6 env: @@ -66,7 +42,7 @@ jobs: push: true tags: lifted/manifest-app:testnet build-args: | - "NEXT_PUBLIC_CHAIN=$NEXT_PUBLIC_CHAIN" + "NEXT_PUBLIC_CHAIN=${{ vars.NEXT_PUBLIC_CHAIN }}" "NEXT_PUBLIC_CHAIN_ID=$NEXT_PUBLIC_CHAIN_ID" "NEXT_PUBLIC_TESTNET_CHAIN_ID=$NEXT_PUBLIC_TESTNET_CHAIN_ID" "NEXT_PUBLIC_MAINNET_RPC_URL=$NEXT_PUBLIC_MAINNET_RPC_URL" From 60e8caf9347188a7671bf6a75f8643fcfc3b0163 Mon Sep 17 00:00:00 2001 From: "Felix C. Morency" <1102868+fmorency@users.noreply.github.com> Date: Tue, 19 Nov 2024 11:53:59 -0500 Subject: [PATCH 12/18] ci: debug --- .github/workflows/docker.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 64465fa0..85567d2d 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -43,12 +43,12 @@ jobs: tags: lifted/manifest-app:testnet build-args: | "NEXT_PUBLIC_CHAIN=${{ vars.NEXT_PUBLIC_CHAIN }}" - "NEXT_PUBLIC_CHAIN_ID=$NEXT_PUBLIC_CHAIN_ID" - "NEXT_PUBLIC_TESTNET_CHAIN_ID=$NEXT_PUBLIC_TESTNET_CHAIN_ID" - "NEXT_PUBLIC_MAINNET_RPC_URL=$NEXT_PUBLIC_MAINNET_RPC_URL" - "NEXT_PUBLIC_TESTNET_RPC_URL=$NEXT_PUBLIC_TESTNET_RPC_URL" - "NEXT_PUBLIC_MAINNET_API_URL=$NEXT_PUBLIC_MAINNET_API_URL" - "NEXT_PUBLIC_TESTNET_API_URL=$NEXT_PUBLIC_TESTNET_API_URL" + "NEXT_PUBLIC_CHAIN_ID=${{ vars.NEXT_PUBLIC_CHAIN_ID }}" + "NEXT_PUBLIC_TESTNET_CHAIN_ID=${{ vars.NEXT_PUBLIC_TESTNET_CHAIN_ID }}" + "NEXT_PUBLIC_MAINNET_RPC_URL=${{ vars.NEXT_PUBLIC_MAINNET_RPC_URL }}" + "NEXT_PUBLIC_TESTNET_RPC_URL=${{ vars.NEXT_PUBLIC_TESTNET_RPC_URL }}" + "NEXT_PUBLIC_MAINNET_API_URL=${{ vars.NEXT_PUBLIC_MAINNET_API_URL }}" + "NEXT_PUBLIC_TESTNET_API_URL=${{ vars.NEXT_PUBLIC_TESTNET_API_URL }}" secrets: | "ably_api_key=$ABLY_API_KEY" "walletconnect_key=$WALLETCONNECT_KEY" From f55163656998a2562bf8575b9934ec34003e3add Mon Sep 17 00:00:00 2001 From: "Felix C. Morency" <1102868+fmorency@users.noreply.github.com> Date: Tue, 19 Nov 2024 11:58:14 -0500 Subject: [PATCH 13/18] ci: more debug --- Dockerfile | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/Dockerfile b/Dockerfile index 49f02a9b..b65a1cff 100644 --- a/Dockerfile +++ b/Dockerfile @@ -21,13 +21,13 @@ ENV NEXT_PUBLIC_TESTNET_RPC_URL=${NEXT_PUBLIC_TESTNET_RPC_URL} ENV NEXT_PUBLIC_MAINNET_API_URL=${NEXT_PUBLIC_MAINNET_API_URL} ENV NEXT_PUBLIC_TESTNET_API_URL=${NEXT_PUBLIC_TESTNET_API_URL} -RUN echo Base: $NEXT_PUBLIC_CHAIN -RUN echo Base: $NEXT_PUBLIC_CHAIN_ID -RUN echo Base: $NEXT_PUBLIC_TESTNET_CHAIN_ID -RUN echo Base: $NEXT_PUBLIC_MAINNET_RPC_URL -RUN echo Base: $NEXT_PUBLIC_TESTNET_RPC_URL -RUN echo Base: $NEXT_PUBLIC_MAINNET_API_URL -RUN echo Base: $NEXT_PUBLIC_TESTNET_API_URL +RUN echo "Base: $NEXT_PUBLIC_CHAIN" +RUN echo "Base: $NEXT_PUBLIC_CHAIN_ID" +RUN echo "Base: $NEXT_PUBLIC_TESTNET_CHAIN_ID" +RUN echo "Base: $NEXT_PUBLIC_MAINNET_RPC_URL" +RUN echo "Base: $NEXT_PUBLIC_TESTNET_RPC_URL" +RUN echo "Base: $NEXT_PUBLIC_MAINNET_API_URL" +RUN echo "Base: $NEXT_PUBLIC_TESTNET_API_URL" # Install dependencies only when needed @@ -56,13 +56,13 @@ COPY . . # Uncomment the following line in case you want to disable telemetry during the build. ENV NEXT_TELEMETRY_DISABLED=1 -RUN echo Builder: $NEXT_PUBLIC_CHAIN -RUN echo Builder: $NEXT_PUBLIC_CHAIN_ID -RUN echo Builder: $NEXT_PUBLIC_TESTNET_CHAIN_ID -RUN echo Builder: $NEXT_PUBLIC_MAINNET_RPC_URL -RUN echo Builder: $NEXT_PUBLIC_TESTNET_RPC_URL -RUN echo Builder: $NEXT_PUBLIC_MAINNET_API_URL -RUN echo Builder: $NEXT_PUBLIC_TESTNET_API_URL +RUN echo "Builder: $NEXT_PUBLIC_CHAIN" +RUN echo "Builder: $NEXT_PUBLIC_CHAIN_ID" +RUN echo "Builder: $NEXT_PUBLIC_TESTNET_CHAIN_ID" +RUN echo "Builder: $NEXT_PUBLIC_MAINNET_RPC_URL" +RUN echo "Builder: $NEXT_PUBLIC_TESTNET_RPC_URL" +RUN echo "Builder: $NEXT_PUBLIC_MAINNET_API_URL" +RUN echo "Builder: $NEXT_PUBLIC_TESTNET_API_URL" RUN \ if [ -f yarn.lock ]; then yarn run build; \ From f2c42534170dfa2a83f73a78f3c8ae732a2bddb9 Mon Sep 17 00:00:00 2001 From: "Felix C. Morency" <1102868+fmorency@users.noreply.github.com> Date: Tue, 19 Nov 2024 13:49:43 -0500 Subject: [PATCH 14/18] ci: fix --- .github/workflows/docker.yml | 42 +++++++++++++----------------------- Dockerfile | 36 ------------------------------- 2 files changed, 15 insertions(+), 63 deletions(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 85567d2d..bcf75893 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -12,9 +12,6 @@ jobs: environment: 'Production - Testnet' steps: - - name: Checkout repository - uses: actions/checkout@v4 - - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 @@ -24,32 +21,23 @@ jobs: username: ${{ vars.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} + - name: Create .env file + run: | + touch .env + echo "NEXT_PUBLIC_CHAIN=${{ vars.NEXT_PUBLIC_CHAIN }}" >> .env + echo "NEXT_PUBLIC_CHAIN_ID=${{ vars.NEXT_PUBLIC_CHAIN_ID }}" >> .env + echo "NEXT_PUBLIC_TESTNET_CHAIN_ID=${{ vars.NEXT_PUBLIC_TESTNET_CHAIN_ID }}" >> .env + echo "NEXT_PUBLIC_MAINNET_RPC_URL=${{ vars.NEXT_PUBLIC_MAINNET_RPC_URL }}" >> .env + echo "NEXT_PUBLIC_TESTNET_RPC_URL=${{ vars.NEXT_PUBLIC_TESTNET_RPC_URL }}" >> .env + echo "NEXT_PUBLIC_MAINNET_API_URL=${{ vars.NEXT_PUBLIC_MAINNET_API_URL }}" >> .env + echo "NEXT_PUBLIC_TESTNET_API_URL=${{ vars.NEXT_PUBLIC_TESTNET_API_URL }}" >> .env + echo "NEXT_PUBLIC_ABLY_API_KEY=${{ secrets.NEXT_PUBLIC_ABLY_API_KEY }}" >> .env + echo "NEXT_PUBLIC_WALLETCONNECT_KEY=${{ secrets.NEXT_PUBLIC_WALLETCONNECT_KEY }}" >> .env + echo "NEXT_PUBLIC_WEB3_CLIENT_ID=${{ secrets.NEXT_PUBLIC_WEB3_CLIENT_ID }}" >> .env + cat .env + - name: Build and push Docker image uses: docker/build-push-action@v6 - env: - NEXT_PUBLIC_CHAIN: ${{ vars.NEXT_PUBLIC_CHAIN }} - NEXT_PUBLIC_CHAIN_ID: ${{ vars.NEXT_PUBLIC_CHAIN_ID }} - NEXT_PUBLIC_TESTNET_CHAIN_ID: ${{ vars.NEXT_PUBLIC_TESTNET_CHAIN_ID }} - NEXT_PUBLIC_MAINNET_RPC_URL: ${{ vars.NEXT_PUBLIC_MAINNET_RPC_URL }} - NEXT_PUBLIC_TESTNET_RPC_URL: ${{ vars.NEXT_PUBLIC_TESTNET_RPC_URL }} - NEXT_PUBLIC_MAINNET_API_URL: ${{ vars.NEXT_PUBLIC_MAINNET_API_URL }} - NEXT_PUBLIC_TESTNET_API_URL: ${{ vars.NEXT_PUBLIC_TESTNET_API_URL }} - ABLY_API_KEY: ${{ secrets.NEXT_PUBLIC_ABLY_API_KEY }} - WALLETCONNECT_KEY: ${{ secrets.NEXT_PUBLIC_WALLETCONNECT_KEY }} - WEB3_CLIENT_ID: ${{ secrets.NEXT_PUBLIC_WEB3_CLIENT_ID }} with: - context: . push: true tags: lifted/manifest-app:testnet - build-args: | - "NEXT_PUBLIC_CHAIN=${{ vars.NEXT_PUBLIC_CHAIN }}" - "NEXT_PUBLIC_CHAIN_ID=${{ vars.NEXT_PUBLIC_CHAIN_ID }}" - "NEXT_PUBLIC_TESTNET_CHAIN_ID=${{ vars.NEXT_PUBLIC_TESTNET_CHAIN_ID }}" - "NEXT_PUBLIC_MAINNET_RPC_URL=${{ vars.NEXT_PUBLIC_MAINNET_RPC_URL }}" - "NEXT_PUBLIC_TESTNET_RPC_URL=${{ vars.NEXT_PUBLIC_TESTNET_RPC_URL }}" - "NEXT_PUBLIC_MAINNET_API_URL=${{ vars.NEXT_PUBLIC_MAINNET_API_URL }}" - "NEXT_PUBLIC_TESTNET_API_URL=${{ vars.NEXT_PUBLIC_TESTNET_API_URL }}" - secrets: | - "ably_api_key=$ABLY_API_KEY" - "walletconnect_key=$WALLETCONNECT_KEY" - "web3auth_key=$WEB3_CLIENT_ID" diff --git a/Dockerfile b/Dockerfile index b65a1cff..470925fd 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,34 +1,6 @@ # syntax=docker.io/docker/dockerfile:1 FROM oven/bun:slim AS base -RUN --mount=type=secret,id=ably_api_key,env=NEXT_PUBLIC_ABLY_API_KEY \ - --mount=type=secret,id=walletconnect_key,env=NEXT_PUBLIC_WALLETCONNECT_KEY \ - --mount=type=secret,id=web3auth_key,env=NEXT_PUBLIC_WEB3_CLIENT_ID - -ARG NEXT_PUBLIC_CHAIN -ARG NEXT_PUBLIC_CHAIN_ID -ARG NEXT_PUBLIC_TESTNET_CHAIN_ID -ARG NEXT_PUBLIC_MAINNET_RPC_URL -ARG NEXT_PUBLIC_TESTNET_RPC_URL -ARG NEXT_PUBLIC_MAINNET_API_URL -ARG NEXT_PUBLIC_TESTNET_API_URL - -ENV NEXT_PUBLIC_CHAIN=${NEXT_PUBLIC_CHAIN} -ENV NEXT_PUBLIC_CHAIN_ID=${NEXT_PUBLIC_CHAIN_ID} -ENV NEXT_PUBLIC_TESTNET_CHAIN_ID=${NEXT_PUBLIC_TESTNET_CHAIN_ID} -ENV NEXT_PUBLIC_MAINNET_RPC_URL=${NEXT_PUBLIC_MAINNET_RPC_URL} -ENV NEXT_PUBLIC_TESTNET_RPC_URL=${NEXT_PUBLIC_TESTNET_RPC_URL} -ENV NEXT_PUBLIC_MAINNET_API_URL=${NEXT_PUBLIC_MAINNET_API_URL} -ENV NEXT_PUBLIC_TESTNET_API_URL=${NEXT_PUBLIC_TESTNET_API_URL} - -RUN echo "Base: $NEXT_PUBLIC_CHAIN" -RUN echo "Base: $NEXT_PUBLIC_CHAIN_ID" -RUN echo "Base: $NEXT_PUBLIC_TESTNET_CHAIN_ID" -RUN echo "Base: $NEXT_PUBLIC_MAINNET_RPC_URL" -RUN echo "Base: $NEXT_PUBLIC_TESTNET_RPC_URL" -RUN echo "Base: $NEXT_PUBLIC_MAINNET_API_URL" -RUN echo "Base: $NEXT_PUBLIC_TESTNET_API_URL" - # Install dependencies only when needed FROM base AS deps @@ -56,14 +28,6 @@ COPY . . # Uncomment the following line in case you want to disable telemetry during the build. ENV NEXT_TELEMETRY_DISABLED=1 -RUN echo "Builder: $NEXT_PUBLIC_CHAIN" -RUN echo "Builder: $NEXT_PUBLIC_CHAIN_ID" -RUN echo "Builder: $NEXT_PUBLIC_TESTNET_CHAIN_ID" -RUN echo "Builder: $NEXT_PUBLIC_MAINNET_RPC_URL" -RUN echo "Builder: $NEXT_PUBLIC_TESTNET_RPC_URL" -RUN echo "Builder: $NEXT_PUBLIC_MAINNET_API_URL" -RUN echo "Builder: $NEXT_PUBLIC_TESTNET_API_URL" - RUN \ if [ -f yarn.lock ]; then yarn run build; \ elif [ -f package-lock.json ]; then npm run build; \ From 1921ad9916fd96fe7464e47d8141cff7309462ac Mon Sep 17 00:00:00 2001 From: "Felix C. Morency" <1102868+fmorency@users.noreply.github.com> Date: Tue, 19 Nov 2024 14:05:43 -0500 Subject: [PATCH 15/18] ci: env --- Dockerfile | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Dockerfile b/Dockerfile index 470925fd..a0225e15 100644 --- a/Dockerfile +++ b/Dockerfile @@ -23,6 +23,9 @@ WORKDIR /app COPY --from=deps /app/node_modules ./node_modules COPY . . +RUN \ + if [ -f .env ]; then echo ".env file found, continuing..."; else echo ".env file not found, exiting..."; exit 1; fi + # Next.js collects completely anonymous telemetry data about general usage. # Learn more here: https://nextjs.org/telemetry # Uncomment the following line in case you want to disable telemetry during the build. From 8f9f9fa3a4fdb63da1ff6283aed8e54f785d3371 Mon Sep 17 00:00:00 2001 From: "Felix C. Morency" <1102868+fmorency@users.noreply.github.com> Date: Tue, 19 Nov 2024 14:08:29 -0500 Subject: [PATCH 16/18] ci: context --- .github/workflows/docker.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index bcf75893..405a727d 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -4,7 +4,7 @@ name: Build and Push Docker Image # push: # branches: # - main -on: [push, pull_request] +on: [push] jobs: build-and-push: @@ -12,6 +12,9 @@ jobs: environment: 'Production - Testnet' steps: + - name: Checkout code + uses: actions/checkout@v4 + - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 @@ -39,5 +42,6 @@ jobs: - name: Build and push Docker image uses: docker/build-push-action@v6 with: + context: . push: true tags: lifted/manifest-app:testnet From 46271d950448a3653cbdad6288514c66f7d82cf7 Mon Sep 17 00:00:00 2001 From: "Felix C. Morency" <1102868+fmorency@users.noreply.github.com> Date: Tue, 19 Nov 2024 14:21:01 -0500 Subject: [PATCH 17/18] ci: rm env --- Dockerfile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Dockerfile b/Dockerfile index a0225e15..e9a420e3 100644 --- a/Dockerfile +++ b/Dockerfile @@ -39,6 +39,8 @@ RUN \ else echo "Lockfile not found." && exit 1; \ fi +RUN rm -rf .env + # Production image, copy all the files and run next FROM base AS runner WORKDIR /app From 5f09ad1a7eb29a07203ddbb4f4a43b3f1534b43e Mon Sep 17 00:00:00 2001 From: "Felix C. Morency" <1102868+fmorency@users.noreply.github.com> Date: Tue, 19 Nov 2024 14:31:20 -0500 Subject: [PATCH 18/18] ci: scope --- .github/workflows/docker.yml | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 405a727d..b543e4cf 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -1,10 +1,9 @@ name: Build and Push Docker Image -#on: -# push: -# branches: -# - main -on: [push] +on: + push: + branches: + - main jobs: build-and-push: