From dea382a8c9489bc370301f903c82ab1f469fce2b Mon Sep 17 00:00:00 2001 From: Stanley Cheung Date: Fri, 20 Feb 2026 20:56:49 +0800 Subject: [PATCH] fix: build arg params --- apps/web/.dockerignore | 12 ++++ apps/web/.env.example | 19 ------- apps/web/Dockerfile | 36 ++++++++++++ apps/web/drizzle.config.ts | 23 -------- apps/web/next-env.d.ts | 2 +- apps/web/src/app/api/sounds/search/route.ts | 5 +- apps/web/src/env/web.ts | 8 --- apps/web/src/lib/db/index.ts | 19 ------- apps/web/src/lib/db/schema.ts | 62 --------------------- apps/web/src/lib/rate-limit.ts | 6 +- 10 files changed, 54 insertions(+), 138 deletions(-) create mode 100644 apps/web/.dockerignore create mode 100644 apps/web/Dockerfile delete mode 100644 apps/web/drizzle.config.ts delete mode 100644 apps/web/src/lib/db/index.ts delete mode 100644 apps/web/src/lib/db/schema.ts diff --git a/apps/web/.dockerignore b/apps/web/.dockerignore new file mode 100644 index 00000000..bb7f8e61 --- /dev/null +++ b/apps/web/.dockerignore @@ -0,0 +1,12 @@ +node_modules +.next +coverage +storybook-static +playwright-report +test-results +.git +.gitignore +Dockerfile* +*.log +.env +.env.local diff --git a/apps/web/.env.example b/apps/web/.env.example index 18f38c64..886c9f8f 100644 --- a/apps/web/.env.example +++ b/apps/web/.env.example @@ -1,21 +1,2 @@ -# Environment variables example -# Copy this file to .env.local and update the values as needed - -# Node -NODE_ENV=development - # Public NEXT_PUBLIC_AUTH_API_BASE_URL=https://localhost:3000/api - -# Server -DATABASE_URL="postgresql://vibecut:vibecut@localhost:5432/vibecut" - -UPSTASH_REDIS_REST_URL=http://localhost:8079 -UPSTASH_REDIS_REST_TOKEN=example_token_here - -MARBLE_WORKSPACE_KEY=your_workspace_key_here - -FREESOUND_CLIENT_ID=your_client_id_here -FREESOUND_API_KEY=your_api_key_here - -MODAL_TRANSCRIPTION_URL=your_modal_url_here diff --git a/apps/web/Dockerfile b/apps/web/Dockerfile new file mode 100644 index 00000000..c936badc --- /dev/null +++ b/apps/web/Dockerfile @@ -0,0 +1,36 @@ +# syntax=docker/dockerfile:1 + +FROM node:20-bookworm-slim AS deps +WORKDIR /app + +COPY package.json package-lock.json .npmrc ./ +RUN npm ci + +FROM node:20-bookworm-slim AS builder +WORKDIR /app + +COPY --from=deps /app/node_modules ./node_modules +COPY . . + +ENV NODE_ENV=production +RUN npm run build + +FROM node:20-bookworm-slim AS runner +WORKDIR /app + +ENV NODE_ENV=production +ENV PORT=3000 +ENV HOSTNAME=0.0.0.0 + +RUN groupadd --system --gid 1001 nodejs \ + && useradd --system --uid 1001 --gid nodejs nextjs + +COPY --from=builder /app/public ./public +COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./ +COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static + +USER nextjs + +EXPOSE 3000 + +CMD ["node", "server.js"] diff --git a/apps/web/drizzle.config.ts b/apps/web/drizzle.config.ts deleted file mode 100644 index 71ff8c64..00000000 --- a/apps/web/drizzle.config.ts +++ /dev/null @@ -1,23 +0,0 @@ -import type { Config } from "drizzle-kit"; -import * as dotenv from "dotenv"; -import { webEnv } from "./src/env/web"; - -// Load the right env file based on environment -if (webEnv.NODE_ENV === "production") { - dotenv.config({ path: ".env.production" }); -} else { - dotenv.config({ path: ".env.local" }); -} - -export default { - schema: "./src/schema.ts", - dialect: "postgresql", - migrations: { - table: "drizzle_migrations", - }, - dbCredentials: { - url: webEnv.DATABASE_URL, - }, - out: "./migrations", - strict: webEnv.NODE_ENV === "production", -} satisfies Config; diff --git a/apps/web/next-env.d.ts b/apps/web/next-env.d.ts index c4b7818f..9edff1c7 100644 --- a/apps/web/next-env.d.ts +++ b/apps/web/next-env.d.ts @@ -1,6 +1,6 @@ /// /// -import "./.next/dev/types/routes.d.ts"; +import "./.next/types/routes.d.ts"; // NOTE: This file should not be edited // see https://nextjs.org/docs/app/api-reference/config/typescript for more information. diff --git a/apps/web/src/app/api/sounds/search/route.ts b/apps/web/src/app/api/sounds/search/route.ts index 853581f1..dbc64c26 100644 --- a/apps/web/src/app/api/sounds/search/route.ts +++ b/apps/web/src/app/api/sounds/search/route.ts @@ -1,7 +1,6 @@ -import { webEnv } from "@/env/web"; +import { checkRateLimit } from "@/lib/rate-limit"; import { type NextRequest, NextResponse } from "next/server"; import { z } from "zod"; -import { checkRateLimit } from "@/lib/rate-limit"; const searchParamsSchema = z.object({ q: z.string().max(500, "Query too long").optional(), @@ -202,7 +201,7 @@ export async function GET(request: NextRequest) { const params = new URLSearchParams({ query: query || "", - token: webEnv.FREESOUND_API_KEY, + token: '', page: page.toString(), page_size: pageSize.toString(), sort: sortParam, diff --git a/apps/web/src/env/web.ts b/apps/web/src/env/web.ts index bbd2c7e5..e3e5bcaf 100644 --- a/apps/web/src/env/web.ts +++ b/apps/web/src/env/web.ts @@ -2,14 +2,6 @@ import { z } from "zod"; const webEnvSchema = z.object({ NODE_ENV: z.enum(["development", "test", "production"]).default("development"), - DATABASE_URL: z.string().min(1), - UPSTASH_REDIS_REST_URL: z.string().min(1), - UPSTASH_REDIS_REST_TOKEN: z.string().min(1), - FREESOUND_API_KEY: z.string().min(1), - FREESOUND_CLIENT_ID: z.string().min(1).optional(), - MARBLE_WORKSPACE_KEY: z.string().min(1).optional(), - MODAL_TRANSCRIPTION_URL: z.string().min(1).optional(), - NEXT_PUBLIC_AUTH_API_BASE_URL: z.string().min(1).optional(), }); export const webEnv = webEnvSchema.parse({ diff --git a/apps/web/src/lib/db/index.ts b/apps/web/src/lib/db/index.ts deleted file mode 100644 index 29e3ffda..00000000 --- a/apps/web/src/lib/db/index.ts +++ /dev/null @@ -1,19 +0,0 @@ -import { drizzle } from "drizzle-orm/postgres-js"; -import postgres from "postgres"; -import * as schema from "./schema"; -import { webEnv } from "@/env/web"; - -let _db: ReturnType | null = null; - -function getDb() { - if (!_db) { - const client = postgres(webEnv.DATABASE_URL); - _db = drizzle(client, { schema }); - } - - return _db; -} - -export const db = getDb(); - -export * from "./schema"; diff --git a/apps/web/src/lib/db/schema.ts b/apps/web/src/lib/db/schema.ts deleted file mode 100644 index 88d71191..00000000 --- a/apps/web/src/lib/db/schema.ts +++ /dev/null @@ -1,62 +0,0 @@ -import { pgTable, text, timestamp, boolean } from "drizzle-orm/pg-core"; - -export const users = pgTable("users", { - id: text("id").primaryKey(), - - // todo: implement fully anonymous sign-in for privacy - // we don't have any auth flows currently so this is fine for now - name: text("name").notNull(), - email: text("email").notNull().unique(), - emailVerified: boolean("email_verified").default(false).notNull(), - image: text("image"), - createdAt: timestamp("created_at") - .$defaultFn(() => /* @__PURE__ */ new Date()) - .notNull(), - updatedAt: timestamp("updated_at") - .$defaultFn(() => /* @__PURE__ */ new Date()) - .notNull(), -}).enableRLS(); - -export const sessions = pgTable("sessions", { - id: text("id").primaryKey(), - expiresAt: timestamp("expires_at").notNull(), - token: text("token").notNull().unique(), - createdAt: timestamp("created_at").notNull(), - updatedAt: timestamp("updated_at").notNull(), - ipAddress: text("ip_address"), - userAgent: text("user_agent"), - userId: text("user_id") - .notNull() - .references(() => users.id, { onDelete: "cascade" }), -}).enableRLS(); - -export const accounts = pgTable("accounts", { - id: text("id").primaryKey(), - accountId: text("account_id").notNull(), - providerId: text("provider_id").notNull(), - userId: text("user_id") - .notNull() - .references(() => users.id, { onDelete: "cascade" }), - accessToken: text("access_token"), - refreshToken: text("refresh_token"), - idToken: text("id_token"), - accessTokenExpiresAt: timestamp("access_token_expires_at"), - refreshTokenExpiresAt: timestamp("refresh_token_expires_at"), - scope: text("scope"), - password: text("password"), - createdAt: timestamp("created_at").notNull(), - updatedAt: timestamp("updated_at").notNull(), -}).enableRLS(); - -export const verifications = pgTable("verifications", { - id: text("id").primaryKey(), - identifier: text("identifier").notNull(), - value: text("value").notNull(), - expiresAt: timestamp("expires_at").notNull(), - createdAt: timestamp("created_at").$defaultFn( - () => /* @__PURE__ */ new Date(), - ), - updatedAt: timestamp("updated_at").$defaultFn( - () => /* @__PURE__ */ new Date(), - ), -}).enableRLS(); diff --git a/apps/web/src/lib/rate-limit.ts b/apps/web/src/lib/rate-limit.ts index c10c3819..a00b8132 100644 --- a/apps/web/src/lib/rate-limit.ts +++ b/apps/web/src/lib/rate-limit.ts @@ -1,10 +1,10 @@ import { Ratelimit } from "@upstash/ratelimit"; import { Redis } from "@upstash/redis"; -import { webEnv } from "@/env/web"; +// import { webEnv } from "@/env/web"; const redis = new Redis({ - url: webEnv.UPSTASH_REDIS_REST_URL, - token: webEnv.UPSTASH_REDIS_REST_TOKEN, + url: '', + token: '', }); export const baseRateLimit = new Ratelimit({