Skip to content

Commit

Permalink
feat: build ink web app in ci
Browse files Browse the repository at this point in the history
  • Loading branch information
ink-victor committed Feb 5, 2025
1 parent 6dec51e commit a1d303e
Show file tree
Hide file tree
Showing 38 changed files with 935 additions and 429 deletions.
9 changes: 9 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
node_modules
.next
.git
.env*
!.env.production
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
55 changes: 55 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# Environment
NEXT_PUBLIC_ENVIRONMENT=

# Sentry
NEXT_PUBLIC_SENTRY_DSN=
SENTRY_AUTH_TOKEN=

# GTM
NEXT_PUBLIC_GTM_ID=

# Braze
BRAZE_INSTANCE_URL=
BRAZE_API_KEY=
BRAZE_GENERAL_WAITLIST_GROUP_ID=
BRAZE_DEVELOPERS_WAITLIST_GROUP_ID=

# OneTrust
NEXT_PUBLIC_ONE_TRUST_ID=

# Dune
NEXT_PUBLIC_DUNE_API_KEY=

# WalletConnect
NEXT_PUBLIC_WC_PROJECT_ID=

# hCaptcha
HCAPTCHA_SECRET=
NEXT_PUBLIC_HCAPTCHA_SITEKEY=

# Segment
NEXT_PUBLIC_SEGMENT_WRITE_KEY=

# Kraken Connect
NEXT_PUBLIC_KRAKEN_CLIENT_ID=
KRAKEN_CLIENT_SECRET=

# App Submission Bot
INK_APP_SUBMISSION_BOT_GITHUB_APP_ID=
INK_APP_SUBMISSION_BOT_GITHUB_PRIVATE_KEY=
INK_APP_SUBMISSION_BOT_GITHUB_INSTALLATION_ID=
INK_APP_SUBMISSION_TARGET_ORG=
INK_APP_SUBMISSION_TARGET_REPO=
INK_APP_SUBMISSION_TARGET_BRANCH=
INK_APP_SUBMISSION_SLACK_NOTIFICATION_CHANNEL=
INK_APP_SUBMISSION_SLACK_BOT_TOKEN=

# Smart Account Experiment
NEXT_PUBLIC_BUNDLER_URL=
NEXT_PUBLIC_PASSKEY_SERVER_URL=
NEXT_PUBLIC_PAYMASTER_URL=
NEXT_PUBLIC_GELATO_BRIDGE_URL=
NEXT_PUBLIC_FAUCET_API_URL=

# Testnet Faucet Experiment
MULTIPLIER_JWT_SECRET=
16 changes: 14 additions & 2 deletions .github/actions/base-setup/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,19 @@ runs:
uses: actions/setup-node@v4
with:
node-version: "20.x"
cache: "pnpm"

- name: Install dependencies
- name: Add pnpm store path to env var
id: pnpm-cache
shell: bash
run: pnpm install --frozen-lockfile
run: echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT

- name: Restore Cache
uses: actions/cache@v4
with:
path: |
${{ steps.pnpm-cache.outputs.STORE_PATH }}
**/node_modules
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
39 changes: 39 additions & 0 deletions .github/actions/image-build-push/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: image-build-push
description: Build and push a Docker image to GitHub Container Registry
inputs:
repository-name:
description: The name of the service to build and push
required: true
dockerfile-path:
description: The path to the Dockerfile for the service
required: true
github-token:
description: The GitHub token
required: true
docker-context:
description: The docker context path
required: true
outputs:
digest:
description: The digest of the built image
value: ${{ steps.build.outputs.digest }}
runs:
using: composite
steps:
- uses: docker/login-action@0d4c9c5ea7693da7b068278f7b52bda2a190a446
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ inputs.github-token }}
- id: metadata
uses: docker/metadata-action@8e5442c4ef9f78752691e2d8f8d19755c6f78e81
with:
images: ghcr.io/inkonchain/${{ inputs.repository-name }}
- id: build
uses: docker/build-push-action@1a162644f9a7e87d8f4b053101d1d9a712edc18c
with:
context: ${{ inputs.docker-context }}
file: ${{ inputs.dockerfile-path }}
push: true
tags: ${{ steps.metadata.outputs.tags }}
labels: ${{ steps.metadata.outputs.labels }}
24 changes: 19 additions & 5 deletions .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,35 @@ jobs:
with:
node-version: "20.x"
cache: "pnpm"
- name: Clear pnpm store and modules
run: |
rm -rf node_modules || true
rm -rf ~/.pnpm-store || true
pnpm store path && pnpm store prune || true

- name: Install dependencies
run: pnpm install --frozen-lockfile

- name: Add pnpm store path to env var
id: pnpm-cache
shell: bash
run: echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT

- name: Cache node modules
uses: actions/cache@v4
with:
path: |
${{ steps.pnpm-cache.outputs.STORE_PATH }}
**/node_modules
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
lint:
needs: install_modules
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/base-setup
name: Base Setup
- name: Install dependencies
shell: bash
run: pnpm install --frozen-lockfile
- name: Run linting
run: pnpm run lint

Expand Down
98 changes: 98 additions & 0 deletions .github/workflows/ship.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
name: ship
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
on:
push:
branches:
- main
- main2
paths:
- .github/workflows/ship.yml
- "**"
jobs:
image-build-push:
runs-on: ubuntu-latest
environment: production
steps:
- uses: actions/checkout@v4

- name: Generate .env.production file
run: |
cat << EOF > .env.production
# Environment
NEXT_PUBLIC_ENVIRONMENT=${{ vars.NEXT_PUBLIC_ENVIRONMENT }}
# Sentry
NEXT_PUBLIC_SENTRY_DSN=${{ secrets.NEXT_PUBLIC_SENTRY_DSN }}
SENTRY_AUTH_TOKEN=${{ secrets.SENTRY_AUTH_TOKEN }}
# GTM
NEXT_PUBLIC_GTM_ID=${{ secrets.NEXT_PUBLIC_GTM_ID }}
# Braze
BRAZE_INSTANCE_URL=${{ secrets.BRAZE_INSTANCE_URL }}
BRAZE_API_KEY=${{ secrets.BRAZE_API_KEY }}
BRAZE_GENERAL_WAITLIST_GROUP_ID=${{ secrets.BRAZE_GENERAL_WAITLIST_GROUP_ID }}
BRAZE_DEVELOPERS_WAITLIST_GROUP_ID=${{ secrets.BRAZE_DEVELOPERS_WAITLIST_GROUP_ID }}
# OneTrust
NEXT_PUBLIC_ONE_TRUST_ID=${{ secrets.NEXT_PUBLIC_ONE_TRUST_ID }}
# Dune
NEXT_PUBLIC_DUNE_API_KEY=${{ secrets.NEXT_PUBLIC_DUNE_API_KEY }}
# WalletConnect
NEXT_PUBLIC_WC_PROJECT_ID=${{ secrets.NEXT_PUBLIC_WC_PROJECT_ID }}
# hCaptcha
HCAPTCHA_SECRET=${{ secrets.HCAPTCHA_SECRET }}
NEXT_PUBLIC_HCAPTCHA_SITEKEY=${{ secrets.NEXT_PUBLIC_HCAPTCHA_SITEKEY }}
# Segment
NEXT_PUBLIC_SEGMENT_WRITE_KEY=${{ secrets.NEXT_PUBLIC_SEGMENT_WRITE_KEY }}
# Kraken Connect
NEXT_PUBLIC_KRAKEN_CLIENT_ID=${{ secrets.NEXT_PUBLIC_KRAKEN_CLIENT_ID }}
KRAKEN_CLIENT_SECRET=${{ secrets.KRAKEN_CLIENT_SECRET }}
# App Submission Bot
INK_APP_SUBMISSION_BOT_GITHUB_APP_ID=${{ secrets.INK_APP_SUBMISSION_BOT_GITHUB_APP_ID }}
INK_APP_SUBMISSION_BOT_GITHUB_PRIVATE_KEY=${{ secrets.INK_APP_SUBMISSION_BOT_GITHUB_PRIVATE_KEY }}
INK_APP_SUBMISSION_BOT_GITHUB_INSTALLATION_ID=${{ secrets.INK_APP_SUBMISSION_BOT_GITHUB_INSTALLATION_ID }}
INK_APP_SUBMISSION_TARGET_ORG=${{ secrets.INK_APP_SUBMISSION_TARGET_ORG }}
INK_APP_SUBMISSION_TARGET_REPO=${{ secrets.INK_APP_SUBMISSION_TARGET_REPO }}
INK_APP_SUBMISSION_TARGET_BRANCH=${{ secrets.INK_APP_SUBMISSION_TARGET_BRANCH }}
INK_APP_SUBMISSION_SLACK_NOTIFICATION_CHANNEL=${{ secrets.INK_APP_SUBMISSION_SLACK_NOTIFICATION_CHANNEL }}
INK_APP_SUBMISSION_SLACK_BOT_TOKEN=${{ secrets.INK_APP_SUBMISSION_SLACK_BOT_TOKEN }}
# Smart Account Experiment
NEXT_PUBLIC_BUNDLER_URL=${{ secrets.NEXT_PUBLIC_BUNDLER_URL }}
NEXT_PUBLIC_PASSKEY_SERVER_URL=${{ secrets.NEXT_PUBLIC_PASSKEY_SERVER_URL }}
NEXT_PUBLIC_PAYMASTER_URL=${{ secrets.NEXT_PUBLIC_PAYMASTER_URL }}
NEXT_PUBLIC_GELATO_BRIDGE_URL=${{ secrets.NEXT_PUBLIC_GELATO_BRIDGE_URL }}
NEXT_PUBLIC_FAUCET_API_URL=${{ secrets.NEXT_PUBLIC_FAUCET_API_URL }}
# Testnet Faucet Experiment
MULTIPLIER_JWT_SECRET=${{ secrets.MULTIPLIER_JWT_SECRET }}
EOF
- id: build-push
uses: ./.github/actions/image-build-push
with:
repository-name: ink-web-app
dockerfile-path: ./Dockerfile
docker-context: ./
github-token: ${{ secrets.GITHUB_TOKEN }}

# https://docs.github.com/en/rest/actions/workflows?apiVersion=2022-11-28#create-a-workflow-dispatch-event
- name: Trigger deployment
if: github.ref == 'refs/heads/main2'
run: |
curl -L \
-X POST \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer ${{ secrets.VICTOR_PAT_TOKEN }}" \
-H "X-GitHub-Api-Version: 2022-11-28" \
${{ secrets.TARGET_REPOSITORY_DISPATCH_URL }} \
-d '{"ref": "feat/ink-web-app-eks-app","inputs":{"digest":"${{ steps.build-push.outputs.digest }}"}}'
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@ next-env.d.ts

# Environment and local files
.env*
.env*.local
.env.sentry-build-plugin
!.env.example

# Debug logs
npm-debug.log*
Expand Down
33 changes: 33 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Build
FROM node:20 AS base

WORKDIR /app

RUN npm i -g [email protected]

COPY package.json pnpm-lock.yaml ./

RUN pnpm install --frozen-lockfile

COPY . .

RUN pnpm build

# Run
FROM node:20-alpine3.19 AS release

WORKDIR /app

RUN npm i -g [email protected]

RUN addgroup --system --gid 1001 nodejs && \
adduser --system --uid 1001 nextjs

COPY --from=base --chown=nextjs:nodejs /app/node_modules ./node_modules
COPY --from=base --chown=nextjs:nodejs /app/package.json ./package.json
COPY --from=base --chown=nextjs:nodejs /app/.next ./.next
COPY --from=base --chown=nextjs:nodejs /app/public ./public

USER nextjs

CMD ["pnpm", "start"]
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,3 +63,5 @@ Check out our [Next.js deployment documentation](https://nextjs.org/docs/deploym
# Setup

- Define the env variable `INK_DIRECTORY` in your .bashrc or .zshrc file to the directory where Ink specific .gitconfig is stored

# Deployment
12 changes: 7 additions & 5 deletions next.config.mjs → next.config.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import { withSentryConfig } from "@sentry/nextjs";
import createNextIntlPlugin from "next-intl/plugin";
import type { NextConfig } from "next";
import { env } from "@/env";
import { clientEnv } from "@/env-client";

const withNextIntl = createNextIntlPlugin();

/** @type {import('next').NextConfig} */
const nextConfig = {
const nextConfig: NextConfig = {
transpilePackages: ["three"],
images: {
unoptimized: true,
Expand All @@ -22,12 +24,12 @@ export default withSentryConfig(withNextIntl(nextConfig), {
// https://github.com/getsentry/sentry-webpack-plugin#options

org: "payward-inc",
project: "ink-web-app",
project: "ink-landingpage", // TODO: Create project ink-web-app

// Only print logs for uploading source maps in CI
silent: !process.env.CI,
silent: clientEnv.NEXT_PUBLIC_ENVIRONMENT !== "ci",

authToken: process.env.SENTRY_AUTH_TOKEN,
authToken: env.SENTRY_AUTH_TOKEN,
// For all available options, see:
// https://docs.sentry.io/platforms/javascript/guides/nextjs/manual-setup/

Expand Down
11 changes: 5 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,11 @@
"@react-three/postprocessing": "2.16.2",
"@reservoir0x/relay-kit-hooks": "1.4.16",
"@reservoir0x/relay-kit-ui": "2.4.0",
"@reservoir0x/relay-sdk": "1.5.0",
"@segment/analytics-next": "1.70.0",
"@sentry/nextjs": "8.38.0",
"@slack/web-api": "7.8.0",
"@t3-oss/env-nextjs": "0.12.0",
"@tanstack/react-query": "5.60.6",
"@types/react": "19.0.7",
"@types/react-dom": "19.0.3",
Expand All @@ -38,9 +40,9 @@
"@zerodev/sdk": "5.4.0-beta.0",
"class-variance-authority": "0.7.1",
"cookies-next": "4.2.1",
"dompurify": "3.2.3",
"ethers": "6.13.1",
"framer-motion": "12.0.0-alpha.1",
"isomorphic-dompurify": "2.21.0",
"jose": "5.9.6",
"leva": "0.9.35",
"lottie-react": "2.4.0",
Expand All @@ -61,7 +63,7 @@
"three": "0.165.0",
"viem": "2.22.11",
"wagmi": "2.14.9",
"zod": "3.23.8"
"zod": "3.24.1"
},
"devDependencies": {
"@playwright/test": "1.45.0",
Expand All @@ -86,11 +88,8 @@
"tailwindcss": "3.4.4",
"typescript": "5.7.3"
},
"packageManager": "pnpm@9.15.2",
"packageManager": "pnpm@9.12.1",
"pnpm": {
"patchedDependencies": {
"@rainbow-me/rainbowkit": "patches/@rainbow-me__rainbowkit.patch"
},
"overrides": {
"@types/react": "19.0.7",
"@types/react-dom": "19.0.3",
Expand Down
Loading

0 comments on commit a1d303e

Please sign in to comment.