diff --git a/.env.example b/.env.example index 708841c..3c44669 100644 --- a/.env.example +++ b/.env.example @@ -1,22 +1,4 @@ -# Get your OpenAI API Key here for chat models: https://platform.openai.com/account/api-keys -OPENAI_API_KEY=**** - -# Get your Fireworks AI API Key here for reasoning models: https://fireworks.ai/account/api-keys -FIREWORKS_API_KEY=**** - -# Generate a random secret: https://generate-secret.vercel.app/32 or `openssl rand -base64 32` -AUTH_SECRET=**** - -# The following keys below are automatically created and -# added to your environment when you deploy on vercel - -# Instructions to create a Vercel Blob Store here: https://vercel.com/docs/storage/vercel-blob -BLOB_READ_WRITE_TOKEN=**** - -# Instructions to create a database here: https://vercel.com/docs/storage/vercel-postgres/quickstart -POSTGRES_URL=**** - -NEXT_PUBLIC_PROJECT_ID= +NEXT_PUBLIC_WALLET_CONNECT_PROJECT_ID= NEXTAUTH_SECRET= - PATTERN_CORE_ENDPOINT= +AUTH_TRUST_HOST= diff --git a/.github/workflows/lint-and-typecheck.yml b/.github/workflows/ci.yml similarity index 91% rename from .github/workflows/lint-and-typecheck.yml rename to .github/workflows/ci.yml index b201d76..8fc51d2 100644 --- a/.github/workflows/lint-and-typecheck.yml +++ b/.github/workflows/ci.yml @@ -1,7 +1,8 @@ -name: Lint and Typechecking +name: CI on: pull_request: branches: ['main', 'dev'] + types: [opened, edited, reopened] jobs: lint: @@ -13,8 +14,6 @@ jobs: - uses: actions/checkout@v4 - name: Install pnpm uses: pnpm/action-setup@v4 - with: - version: 9 - name: Use Node.js ${{ matrix.node-version }} uses: actions/setup-node@v4 with: @@ -34,8 +33,6 @@ jobs: - uses: actions/checkout@v4 - name: Install pnpm uses: pnpm/action-setup@v4 - with: - version: 9 - name: Use Node.js ${{ matrix.node-version }} uses: actions/setup-node@v4 with: diff --git a/.github/workflows/docker-image.yaml b/.github/workflows/docker-image.yaml new file mode 100644 index 0000000..5dc5b97 --- /dev/null +++ b/.github/workflows/docker-image.yaml @@ -0,0 +1,38 @@ +name: Docker image +on: + push: + branches: + - dev + +jobs: + build-and-push: + runs-on: ubuntu-latest + + permissions: + packages: write + + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + + - name: Login to ghcr + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Build and push + uses: docker/build-push-action@v4 + with: + context: . + platforms: 'linux/amd64' + push: true + tags: pattern-tech/pattern-app:latest + cache-from: type=gha + cache-to: type=gha,mode=max diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..b00c875 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,21 @@ +FROM node:20-slim AS base +ENV PNPM_HOME="/pnpm" +ENV PATH="$PNPM_HOME:$PATH" +RUN corepack enable +COPY . /app +WORKDIR /app + +FROM base AS prod-deps +RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --prod --frozen-lockfile + +FROM base AS build +RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --frozen-lockfile +RUN pnpm build + +FROM base +COPY --from=prod-deps /app/node_modules /app/node_modules +COPY --from=build /app/.next /app/.next +COPY --from=build /app/public /app/public + +EXPOSE 3000 +CMD ["pnpm", "start"] diff --git a/app/(auth)/auth.ts b/app/(auth)/auth.ts index eea933f..7e5d089 100644 --- a/app/(auth)/auth.ts +++ b/app/(auth)/auth.ts @@ -11,18 +11,13 @@ import { authConfig } from './auth.config'; /** * TODO: Move all configs into a validated configs module to avoid duplication * - * https://github.com/pattern-tech/pattern-ui/issues/3 + * https://github.com/pattern-tech/pattern-app/issues/3 */ export const nextAuthSecret = process.env.NEXTAUTH_SECRET; if (!nextAuthSecret) { throw new Error('NEXTAUTH_SECRET is not set'); } -export const projectId = process.env.NEXT_PUBLIC_PROJECT_ID; -if (!projectId) { - throw new Error('NEXT_PUBLIC_PROJECT_ID is not set'); -} - const patternCoreEndpoint = process.env.PATTERN_CORE_ENDPOINT; if (!patternCoreEndpoint) { throw new Error('PATTERN_CORE_ENDPOINT is not set'); @@ -80,7 +75,7 @@ const providers = [ /** * TODO: Handle errors accordingly, and show the user what went wrong * - * https://github.com/pattern-tech/pattern-ui/issues/4 + * https://github.com/pattern-tech/pattern-app/issues/4 */ return null; diff --git a/app/config/index.tsx b/app/config/index.tsx index 237d2c9..89d626c 100644 --- a/app/config/index.tsx +++ b/app/config/index.tsx @@ -16,8 +16,9 @@ import { import { getCsrfToken, getSession, signIn, signOut } from 'next-auth/react'; import { getAddress } from 'viem'; -export const projectId = process.env.NEXT_PUBLIC_PROJECT_ID; -if (!projectId) throw new Error('Project ID is not defined'); +export const walletConnectProjectId = + process.env.NEXT_PUBLIC_WALLET_CONNECT_PROJECT_ID; +if (!walletConnectProjectId) throw new Error('Project ID is not defined'); export const metadata = { name: 'Pattern', @@ -35,7 +36,7 @@ export const chains: [AppKitNetwork, ...AppKitNetwork[]] = [ export const wagmiAdapter = new WagmiAdapter({ networks: chains, - projectId, + projectId: walletConnectProjectId, ssr: true, }); @@ -57,7 +58,9 @@ export const siweConfig = createSIWEConfig({ getMessageParams: async () => ({ domain: typeof window !== 'undefined' ? window.location.host : '', uri: typeof window !== 'undefined' ? window.location.origin : '', - chains: chains.map((chain: AppKitNetwork) => Number.parseInt(chain.id.toString())), + chains: chains.map((chain: AppKitNetwork) => + Number.parseInt(chain.id.toString()), + ), }), createMessage: ({ address, ...args }: SIWECreateMessageArgs) => formatMessage(args, normalizeAddress(address)), diff --git a/app/context/index.tsx b/app/context/index.tsx index 09ba47d..3ba250a 100644 --- a/app/context/index.tsx +++ b/app/context/index.tsx @@ -1,26 +1,26 @@ -"use client"; +'use client'; -import { createAppKit } from "@reown/appkit/react"; -import { QueryClient, QueryClientProvider } from "@tanstack/react-query"; -import React, { ReactNode } from "react"; -import { State, WagmiProvider } from "wagmi"; +import { createAppKit } from '@reown/appkit/react'; +import { QueryClient, QueryClientProvider } from '@tanstack/react-query'; +import React, { type ReactNode } from 'react'; +import { type State, WagmiProvider } from 'wagmi'; import { chains, metadata, - projectId, + walletConnectProjectId, siweConfig, wagmiAdapter, -} from "../config"; +} from '../config'; const queryClient = new QueryClient(); -if (!projectId) throw new Error("Project ID is not defined"); +if (!walletConnectProjectId) throw new Error('Project ID is not defined'); createAppKit({ adapters: [wagmiAdapter], networks: chains, - projectId, + projectId: walletConnectProjectId, siweConfig, metadata, features: { diff --git a/package.json b/package.json index 6c231a2..c345ecb 100644 --- a/package.json +++ b/package.json @@ -1,16 +1,15 @@ { - "name": "ai-chatbot", + "name": "pattern-app", "version": "0.1.0", "private": true, "scripts": { "dev": "next dev --turbo", - "build": "tsx lib/db/migrate && next build", + "build": "next build", "start": "next start", "lint": "next lint && biome lint --write --unsafe", "lint:fix": "next lint --fix && biome lint --write --unsafe", "format": "biome format --write", "db:generate": "drizzle-kit generate", - "db:migrate": "npx tsx lib/db/migrate.ts", "db:studio": "drizzle-kit studio", "db:push": "drizzle-kit push", "db:pull": "drizzle-kit pull", @@ -114,5 +113,6 @@ "tailwindcss": "^3.4.1", "tsx": "^4.19.1", "typescript": "^5.6.3" - } + }, + "packageManager": "pnpm@9.14.1" }