Skip to content

Commit 3fe931f

Browse files
authored
Merge pull request #11 from pattern-tech/chore/deployment
Chore: basic cleanup and docker image deployment
2 parents dc0a08a + 1968528 commit 3fe931f

8 files changed

Lines changed: 85 additions & 49 deletions

File tree

.env.example

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,4 @@
1-
# Get your OpenAI API Key here for chat models: https://platform.openai.com/account/api-keys
2-
OPENAI_API_KEY=****
3-
4-
# Get your Fireworks AI API Key here for reasoning models: https://fireworks.ai/account/api-keys
5-
FIREWORKS_API_KEY=****
6-
7-
# Generate a random secret: https://generate-secret.vercel.app/32 or `openssl rand -base64 32`
8-
AUTH_SECRET=****
9-
10-
# The following keys below are automatically created and
11-
# added to your environment when you deploy on vercel
12-
13-
# Instructions to create a Vercel Blob Store here: https://vercel.com/docs/storage/vercel-blob
14-
BLOB_READ_WRITE_TOKEN=****
15-
16-
# Instructions to create a database here: https://vercel.com/docs/storage/vercel-postgres/quickstart
17-
POSTGRES_URL=****
18-
19-
NEXT_PUBLIC_PROJECT_ID=
1+
NEXT_PUBLIC_WALLET_CONNECT_PROJECT_ID=
202
NEXTAUTH_SECRET=
21-
223
PATTERN_CORE_ENDPOINT=
4+
AUTH_TRUST_HOST=
Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
name: Lint and Typechecking
1+
name: CI
22
on:
33
pull_request:
44
branches: ['main', 'dev']
5+
types: [opened, edited, reopened]
56

67
jobs:
78
lint:
@@ -13,8 +14,6 @@ jobs:
1314
- uses: actions/checkout@v4
1415
- name: Install pnpm
1516
uses: pnpm/action-setup@v4
16-
with:
17-
version: 9
1817
- name: Use Node.js ${{ matrix.node-version }}
1918
uses: actions/setup-node@v4
2019
with:
@@ -34,8 +33,6 @@ jobs:
3433
- uses: actions/checkout@v4
3534
- name: Install pnpm
3635
uses: pnpm/action-setup@v4
37-
with:
38-
version: 9
3936
- name: Use Node.js ${{ matrix.node-version }}
4037
uses: actions/setup-node@v4
4138
with:
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: Docker image
2+
on:
3+
push:
4+
branches:
5+
- dev
6+
7+
jobs:
8+
build-and-push:
9+
runs-on: ubuntu-latest
10+
11+
permissions:
12+
packages: write
13+
14+
steps:
15+
- name: Checkout
16+
uses: actions/checkout@v4
17+
with:
18+
fetch-depth: 0
19+
20+
- name: Set up QEMU
21+
uses: docker/setup-qemu-action@v3
22+
23+
- name: Login to ghcr
24+
uses: docker/login-action@v3
25+
with:
26+
registry: ghcr.io
27+
username: ${{ github.repository_owner }}
28+
password: ${{ secrets.GITHUB_TOKEN }}
29+
30+
- name: Build and push
31+
uses: docker/build-push-action@v4
32+
with:
33+
context: .
34+
platforms: 'linux/amd64'
35+
push: true
36+
tags: pattern-tech/pattern-app:latest
37+
cache-from: type=gha
38+
cache-to: type=gha,mode=max

Dockerfile

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
FROM node:20-slim AS base
2+
ENV PNPM_HOME="/pnpm"
3+
ENV PATH="$PNPM_HOME:$PATH"
4+
RUN corepack enable
5+
COPY . /app
6+
WORKDIR /app
7+
8+
FROM base AS prod-deps
9+
RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --prod --frozen-lockfile
10+
11+
FROM base AS build
12+
RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --frozen-lockfile
13+
RUN pnpm build
14+
15+
FROM base
16+
COPY --from=prod-deps /app/node_modules /app/node_modules
17+
COPY --from=build /app/.next /app/.next
18+
COPY --from=build /app/public /app/public
19+
20+
EXPOSE 3000
21+
CMD ["pnpm", "start"]

app/(auth)/auth.ts

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,13 @@ import { authConfig } from './auth.config';
1111
/**
1212
* TODO: Move all configs into a validated configs module to avoid duplication
1313
*
14-
* https://github.com/pattern-tech/pattern-ui/issues/3
14+
* https://github.com/pattern-tech/pattern-app/issues/3
1515
*/
1616
export const nextAuthSecret = process.env.NEXTAUTH_SECRET;
1717
if (!nextAuthSecret) {
1818
throw new Error('NEXTAUTH_SECRET is not set');
1919
}
2020

21-
export const projectId = process.env.NEXT_PUBLIC_PROJECT_ID;
22-
if (!projectId) {
23-
throw new Error('NEXT_PUBLIC_PROJECT_ID is not set');
24-
}
25-
2621
const patternCoreEndpoint = process.env.PATTERN_CORE_ENDPOINT;
2722
if (!patternCoreEndpoint) {
2823
throw new Error('PATTERN_CORE_ENDPOINT is not set');
@@ -80,7 +75,7 @@ const providers = [
8075
/**
8176
* TODO: Handle errors accordingly, and show the user what went wrong
8277
*
83-
* https://github.com/pattern-tech/pattern-ui/issues/4
78+
* https://github.com/pattern-tech/pattern-app/issues/4
8479
*/
8580

8681
return null;

app/config/index.tsx

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,9 @@ import {
1616
import { getCsrfToken, getSession, signIn, signOut } from 'next-auth/react';
1717
import { getAddress } from 'viem';
1818

19-
export const projectId = process.env.NEXT_PUBLIC_PROJECT_ID;
20-
if (!projectId) throw new Error('Project ID is not defined');
19+
export const walletConnectProjectId =
20+
process.env.NEXT_PUBLIC_WALLET_CONNECT_PROJECT_ID;
21+
if (!walletConnectProjectId) throw new Error('Project ID is not defined');
2122

2223
export const metadata = {
2324
name: 'Pattern',
@@ -35,7 +36,7 @@ export const chains: [AppKitNetwork, ...AppKitNetwork[]] = [
3536

3637
export const wagmiAdapter = new WagmiAdapter({
3738
networks: chains,
38-
projectId,
39+
projectId: walletConnectProjectId,
3940
ssr: true,
4041
});
4142

@@ -57,7 +58,9 @@ export const siweConfig = createSIWEConfig({
5758
getMessageParams: async () => ({
5859
domain: typeof window !== 'undefined' ? window.location.host : '',
5960
uri: typeof window !== 'undefined' ? window.location.origin : '',
60-
chains: chains.map((chain: AppKitNetwork) => Number.parseInt(chain.id.toString())),
61+
chains: chains.map((chain: AppKitNetwork) =>
62+
Number.parseInt(chain.id.toString()),
63+
),
6164
}),
6265
createMessage: ({ address, ...args }: SIWECreateMessageArgs) =>
6366
formatMessage(args, normalizeAddress(address)),

app/context/index.tsx

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,26 @@
1-
"use client";
1+
'use client';
22

3-
import { createAppKit } from "@reown/appkit/react";
4-
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
5-
import React, { ReactNode } from "react";
6-
import { State, WagmiProvider } from "wagmi";
3+
import { createAppKit } from '@reown/appkit/react';
4+
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
5+
import React, { type ReactNode } from 'react';
6+
import { type State, WagmiProvider } from 'wagmi';
77

88
import {
99
chains,
1010
metadata,
11-
projectId,
11+
walletConnectProjectId,
1212
siweConfig,
1313
wagmiAdapter,
14-
} from "../config";
14+
} from '../config';
1515

1616
const queryClient = new QueryClient();
1717

18-
if (!projectId) throw new Error("Project ID is not defined");
18+
if (!walletConnectProjectId) throw new Error('Project ID is not defined');
1919

2020
createAppKit({
2121
adapters: [wagmiAdapter],
2222
networks: chains,
23-
projectId,
23+
projectId: walletConnectProjectId,
2424
siweConfig,
2525
metadata,
2626
features: {

package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
11
{
2-
"name": "ai-chatbot",
2+
"name": "pattern-app",
33
"version": "0.1.0",
44
"private": true,
55
"scripts": {
66
"dev": "next dev --turbo",
7-
"build": "tsx lib/db/migrate && next build",
7+
"build": "next build",
88
"start": "next start",
99
"lint": "next lint && biome lint --write --unsafe",
1010
"lint:fix": "next lint --fix && biome lint --write --unsafe",
1111
"format": "biome format --write",
1212
"db:generate": "drizzle-kit generate",
13-
"db:migrate": "npx tsx lib/db/migrate.ts",
1413
"db:studio": "drizzle-kit studio",
1514
"db:push": "drizzle-kit push",
1615
"db:pull": "drizzle-kit pull",
@@ -114,5 +113,6 @@
114113
"tailwindcss": "^3.4.1",
115114
"tsx": "^4.19.1",
116115
"typescript": "^5.6.3"
117-
}
116+
},
117+
"packageManager": "pnpm@9.14.1"
118118
}

0 commit comments

Comments
 (0)