Skip to content

Commit

Permalink
Review: meTokens ₍wᵢₜₕ gᵣₐₙᵤₗₐᵣ 𝄴ₒₘₘᵢₜₛ₎ (MetaFam#1552)
Browse files Browse the repository at this point in the history
* linting 🃡

* removing MetaMask specificity 🃢

* moving `StrictMode` to Next.js 🃣

* compressing & commafying 🃤

* upgrading eslint 👘

* removing preface from guild name 🃥

* removing unnecessary ESLint `no-console` directives 🌂

* fixing a typo in a comment 🃦

* updating GraphQL codegen for paid subgraph 🦏

* replacing Discord invite link 📌

* passing through The Graph API token to Docker ♾

* setting Docker ARG to set ENV 📟

* missed a file rename in frontend Docker config 🦀

* adding ts-node to fix Docker build issue ⸙

* trying to narrow down the 500 error's source in the test instance ⛄

* exposing The Graph API token on Cloud Run 🦃

* more logging to try & find server error 🐠

* more logging 🧱

* trying to run Node.js in development mode on Cloud Run 🎁

* reconfiguring frontend Dockerfile to also run the dev environment 🌿

* dev mode seems to function 🧨

* 768MiB wasn't enough memory 🍁

* 1GiB wasn't enough memory 🔱

* 1.5GiB was interpreted as 1GiB 🥃

* 1536MiB wasn't enough memory 👾

* 2GiB wasn't enough memory 🧲

* 3GiB wasn't enough memory 🆎

* 4GiB might have been enough, but it still doesn't load 🧻

* 5GiB requires two CPUs 📝

* giving up on dev server; unexplained HTTP 429s 🎨

* disabling Honeybadger in test instances 📮

* trying an `ErrorBoundary` to gather more info 🕷

* setting GraphQL endpoint 🇲🇰

* exposing environment variables ⛈

* trying to expose `` 📻

* the Next compiled version still references `node_modules` 🦢

* removing Alchemy API key from sources ⛺

* trying a different Docker build action 💉

* removing logging 🍿

* switching to Docker Buildx 👠

* missed an escaped newline 🗿

* trying a newer gcloud setup action 🦝

* hopefully fixing authentication 📴

* bunch of changes to the meTokens profile section 🦜

* need credentials file 🐆

* hunting for layout load error & pushing debug statements to testing 🥁

* updating eslint 💓

* trying to debug the missing Breadchain Coop 🧀

* apparently chose the wrong changeset 🐚

* removing logging 🥀
  • Loading branch information
dysbulic authored and alalonde committed May 15, 2023
1 parent 963f848 commit 2921a47
Show file tree
Hide file tree
Showing 68 changed files with 3,222 additions and 2,112 deletions.
10 changes: 5 additions & 5 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
node_modules
packages/**/node_modules
packages/**/dist
packages/**/build
node_modules/
packages/**/node_modules/
packages/**/dist/
packages/**/build/
npm-debug.log
.env*
**/.env*
2 changes: 1 addition & 1 deletion .eslintignore
Original file line number Diff line number Diff line change
@@ -1 +1 @@
.eslintrc.js
.eslintrc.cjs
2 changes: 1 addition & 1 deletion .eslintrc.js → .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ module.exports = {
tsconfigRootDir: __dirname,
ecmaVersion: 6,
},
ignorePatterns: ['packages/web/next.config.js'],
ignorePatterns: ['packages/web/next.config.js', '**/jest.config.js'],
plugins: ['simple-import-sort'],
settings: {
'import/resolver': {
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/gcp-deploy-frontend.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# This is used to deploy the frontend at metagame.wtf and test.metagame.wtf
# This is used to deploy the frontend at metagame.wtf and test.metagame.wtf
# Eventually we will switch the associated backend deployments over to Google Cloud
# as well, at which time we can just use the single gcp_deploy.yaml file
# for both PR deployments AND our stage/prod environments
Expand Down
114 changes: 66 additions & 48 deletions .github/workflows/gcp-deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,15 @@ on:
- synchronize

env:
# This controls whether the Next.js runs in development or
# production mode. For debugging test instance only bugs.
FRONTEND_TARGET: production # development
PROJECT_ID: metagame-thegame
REGISTRY_REGION: us-east4
REGISTRY_REPO: thegame
DEPLOYMENT_DOMAIN: a.run.app
CLOUDRUN_SUFFIX: mjhnbmqqna-uk
DEPLOYMENT_ENV: Test-PR-${{github.event.number}}
DEPLOYMENT_NAME: Test-PR-${{github.event.number}}
DB_NAME: hasura-pr-${{github.event.number}}
BACKEND_SERVICE: backend-pr-${{github.event.number}}
FRONTEND_SERVICE: frontend-pr-${{github.event.number}}
Expand All @@ -45,7 +48,7 @@ jobs:
with:
step: start
token: ${{github.token}}
env: ${{env.DEPLOYMENT_ENV}}
env: ${{env.DEPLOYMENT_NAME}}
desc: "Test instance deployment for PR #${{github.event.number}} of ${{github.event.pull_request.head.label}} by ${{github.event.pull_request.user.login}}"
ref: ${{github.head_ref}}
auto_inactive: false
Expand Down Expand Up @@ -95,6 +98,7 @@ jobs:
BACKEND_TAG: ${{env.BACKEND_TAG}}
HASURA_TAG: ${{env.HASURA_TAG}}
FRONTEND_TAG: ${{env.FRONTEND_TAG}}
FRONTEND_TARGET: ${{env.FRONTEND_TARGET}}

steps:
- name: First Intepolation of Variables
Expand All @@ -111,6 +115,7 @@ jobs:
echo "FRONTEND_URL=\
https://${{env.FRONTEND_SERVICE}}-${{env.CLOUDRUN_SUFFIX}}.${{env.DEPLOYMENT_DOMAIN}}" >> $GITHUB_ENV
echo "DB_PASSWORD=$(head -c 48 /dev/urandom | tr -cd [:alnum:])" >> $GITHUB_ENV
echo "FRONTEND_TARGET=${{env.FRONTEND_TARGET}}" >> $GITHUB_ENV
- name: Those Variables May Now Be Interpolated
id: second
Expand Down Expand Up @@ -243,18 +248,12 @@ jobs:

steps:
- name: "Checkout: ${{github.event.pull_request.head.label}}"
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
ref: ${{github.event.pull_request.head.sha}}

- name: "Build Container Image: ${{needs.env.outputs.BACKEND_TAG}}"
uses: mattes/cached-docker-build-action@v1
with:
args: |
. -f docker/backend/Dockerfile \
--tag ${{needs.env.outputs.BACKEND_TAG}} \
--build-arg GRAPHQL_URL=${{needs.env.outputs.GRAPHQL_URL}}
cache_key: "${{github.event.inputs.cache_key}}-${{hashFiles('packages/backend/**', 'packages/utils/**', 'package.json')}}"
- name: Set Up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: "Login to Registry: ${{needs.env.outputs.DOCKER_REGISTRY}}"
uses: docker/login-action@v2
Expand All @@ -263,8 +262,15 @@ jobs:
username: _json_key
password: ${{secrets.GCP_SA_KEY}}

- name: "Push Container Image: ${{needs.env.outputs.BACKEND_TAG}}"
run: docker push ${{needs.env.outputs.BACKEND_TAG}}
- name: "Build & Push Container Image: ${{needs.env.outputs.BACKEND_TAG}}"
uses: docker/build-push-action@v4
with:
file: docker/backend/Dockerfile
tags: ${{needs.env.outputs.BACKEND_TAG}}
build-args: |
GRAPHQL_URL=${{needs.env.outputs.GRAPHQL_URL}} \
THE_GRAPH_API_TOKEN=${{secrets.THE_GRAPH_API_TOKEN}}
push: true

deploy-backend:
name: Deploy Backend
Expand Down Expand Up @@ -294,7 +300,8 @@ jobs:
--set-env-vars GITHUB_API_TOKEN=${{secrets.GH_API_TOKEN}} \
--set-env-vars SOURCECRED_LEDGER_BRANCH=master \
--set-env-vars GRAPHQL_URL=${{needs.env.outputs.GRAPHQL_URL}} \
--set-env-vars DISCORD_BOT_TOKEN=${{secrets.DISCORD_BOT_TOKEN}}
--set-env-vars DISCORD_BOT_TOKEN=${{secrets.DISCORD_BOT_TOKEN}} \
--set-env-vars THE_GRAPH_API_TOKEN=${{secrets.THE_GRAPH_API_TOKEN}}
undeploy-hasura:
name: Undeploy Hasura
Expand Down Expand Up @@ -346,19 +353,12 @@ jobs:

steps:
- name: "Checkout: ${{github.event.pull_request.head.label}}"
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
ref: ${{github.event.pull_request.head.sha}}

- name: "Build Container Image: ${{needs.env.outputs.HASURA_TAG}}"
uses: mattes/cached-docker-build-action@v1
with:
args: |
./hasura -f hasura/Dockerfile \
--tag ${{needs.env.outputs.HASURA_TAG}} \
--build-arg BACKEND_HOST=${{needs.env.outputs.BACKEND_HOST}} \
--build-arg BACKEND_PROTOCOL=https
cache_key: "${{github.event.inputs.cache_key}}-${{hashFiles('hasura/**', 'package.json')}}"
- name: Set Up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: "Login to Registry: ${{needs.env.outputs.DOCKER_REGISTRY}}"
uses: docker/login-action@v2
Expand All @@ -367,8 +367,17 @@ jobs:
username: _json_key
password: ${{secrets.GCP_SA_KEY}}

- name: "Push Container Image: ${{needs.env.outputs.HASURA_TAG}}"
run: docker push ${{needs.env.outputs.HASURA_TAG}}
- name: "Build & Push Container Image: ${{needs.env.outputs.HASURA_TAG}}"
uses: docker/build-push-action@v4
with:
file: hasura/Dockerfile
context: hasura
tags: ${{needs.env.outputs.HASURA_TAG}}
build-args: |
BACKEND_HOST=${{needs.env.outputs.BACKEND_HOST}}
BACKEND_PROTOCOL=https
push: true


deploy-hasura:
name: Deploy Hasura
Expand Down Expand Up @@ -448,21 +457,12 @@ jobs:

steps:
- name: "Checkout: ${{github.event.pull_request.head.label}}"
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
ref: ${{github.event.pull_request.head.sha}}

- name: "Build Container Image: ${{needs.env.outputs.FRONTEND_TAG}}"
uses: mattes/cached-docker-build-action@v1
with:
args: |
. -f docker/frontend/Dockerfile \
--tag ${{needs.env.outputs.FRONTEND_TAG}} \
--build-arg APP_ENV=${{needs.env.outputs.APP_ENV}} \
--build-arg GRAPHQL_URL=${{needs.env.outputs.GRAPHQL_URL}} \
--build-arg NEXT_PUBLIC_FRONTEND_URL=${{needs.env.outputs.FRONTEND_URL}} \
--build-arg NEXT_PUBLIC_YOUTUBE_API_KEY=${{secrets.YOUTUBE_API_KEY}}
cache_key: "${{github.event.inputs.cache_key}}-${{hashFiles('packages/web/**', 'packages/design-system/**', 'packages/utils/**', 'package.json')}}"
- name: Set Up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: "Login to Registry: ${{needs.env.outputs.DOCKER_REGISTRY}}"
uses: docker/login-action@v2
Expand All @@ -471,38 +471,56 @@ jobs:
username: _json_key
password: ${{secrets.GCP_SA_KEY}}

- name: "Push Container Image: ${{needs.env.outputs.FRONTEND_TAG}}"
run: docker push ${{needs.env.outputs.FRONTEND_TAG}}
- name: "Build & Push Container Image: ${{needs.env.outputs.FRONTEND_TAG}}"
uses: docker/build-push-action@v4
with:
file: docker/frontend/Dockerfile
tags: ${{needs.env.outputs.FRONTEND_TAG}}
build-args: |
APP_ENV=${{needs.env.outputs.APP_ENV}}
GRAPHQL_URL=${{needs.env.outputs.GRAPHQL_URL}}
NEXT_PUBLIC_FRONTEND_URL=${{needs.env.outputs.FRONTEND_URL}}
NEXT_PUBLIC_YOUTUBE_API_KEY=${{secrets.YOUTUBE_API_KEY}}
TARGET=${{needs.env.outputs.FRONTEND_TARGET}}
push: true

deploy-frontend:
name: Deploy Frontend
runs-on: ubuntu-latest
needs: [env, build-frontend]

steps:
- name: Set Up gcloud CLI
uses: google-github-actions/[email protected].0
- name: Authenticate to Google Cloud
uses: google-github-actions/[email protected].0
with:
project_id: ${{needs.env.outputs.PROJECT_ID}}
service_account_key: ${{secrets.GCP_SA_KEY}}
export_default_credentials: true
credentials_json: ${{secrets.GCP_SA_KEY}}
create_credentials_file: true

- name: Set Up gcloud CLI
uses: google-github-actions/[email protected]

- name: "Deploy Container Image: ${{needs.env.outputs.FRONTEND_SERVICE}}"
# this is running a shell script of unknown provision that's failing
# the deployment, however, isn't
continue-on-error: true
run: |
gcloud -q run deploy ${{needs.env.outputs.FRONTEND_SERVICE}} \
--image ${{needs.env.outputs.FRONTEND_TAG}} \
--region ${{needs.env.outputs.CLOUDRUN_REGION}} \
--port ${{needs.env.outputs.FRONTEND_PORT}} \
--cpu 1 \
--memory 512Mi \
--cpu ${{needs.env.outputs.FRONTEND_TARGET == 'development' && '2' || '1'}} \
--memory ${{needs.env.outputs.FRONTEND_TARGET == 'development' && '5Gi' || '512Mi'}} \
--ingress all \
--max-instances 1 \
--allow-unauthenticated \
--set-env-vars NEXT_PUBLIC_APP_ENV=${{secrets.APP_ENV}} \
--set-env-vars WEB3_STORAGE_TOKEN=${{secrets.WEB3_STORAGE_TOKEN}} \
--set-env-vars OPENSEA_API_KEY=${{secrets.OPENSEA_API_KEY}} \
--set-env-vars NEXT_PUBLIC_APP_ENV=${{needs.env.outputs.APP_ENV}} \
--set-env-vars NEXT_PUBLIC_IMGIX_TOKEN=${{secrets.IMGIX_TOKEN}} \
--set-env-vars NEXT_PUBLIC_YOUTUBE_API_KEY=${{secrets.YOUTUBE_API_KEY}} \
--set-env-vars NEXT_PUBLIC_HONEYBADGER_API_KEY=${{secrets.HONEYBADGER_API_KEY}} \
--set-env-vars NEXT_PUBLIC_USERBACK_TOKEN=${{secrets.USERBACK_TOKEN}} \
--set-env-vars NEXT_PUBLIC_GRAPHQL_URL=${{needs.env.outputs.GRAPHQL_URL}} \
--set-env-vars NEXT_PUBLIC_FRONTEND_URL=${{needs.env.outputs.FRONTEND_URL}}
Expand Down Expand Up @@ -542,7 +560,7 @@ jobs:
with:
step: finish
token: ${{github.token}}
env: ${{env.DEPLOYMENT_ENV}}
env: ${{env.DEPLOYMENT_NAME}}
env_url: ${{needs.env.outputs.FRONTEND_URL}}
status: ${{env.result == 'skipped' && 'cancelled' || env.result}}
deployment_id: ${{needs.start-deployment.outputs.deployment_id}}
2 changes: 2 additions & 0 deletions docker/backend/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,12 @@ COPY packages/@types ./packages/@types/
ARG GRAPHQL_HOST=hasura
ARG GRAPHQL_DOMAIN=onrender.com
ARG GRAPHQL_URL=https://$GRAPHQL_HOST.$GRAPHQL_DOMAIN/v1/graphql
ARG THE_GRAPH_API_TOKEN=unspecified

ENV GRAPHQL_URL $GRAPHQL_URL
ENV HASURA_GRAPHQL_ADMIN_SECRET metagame_secret
ENV CERAMIC_URL https://ceramic.metagame.wtf
ENV THE_GRAPH_API_TOKEN $THE_GRAPH_API_TOKEN

# Build
RUN yarn backend:build
Expand Down
Loading

0 comments on commit 2921a47

Please sign in to comment.