diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..ce82c3f --- /dev/null +++ b/Dockerfile @@ -0,0 +1,48 @@ +FROM node:23-alpine AS base + +FROM base AS deps +RUN apk add --no-cache libc6-compat +WORKDIR /app + +COPY package.json pnpm-lock.yaml* ./ +COPY prisma ./prisma/ + +RUN corepack enable pnpm && pnpm i --frozen-lockfile + +# Rebuild the source code only when needed +FROM base AS builder +WORKDIR /app +COPY --from=deps /app/node_modules ./node_modules +COPY . . + +ENV NEXT_TELEMETRY_DISABLED=1 + +RUN corepack enable pnpm && pnpm prisma generate +RUN pnpm prisma migrate deploy +RUN pnpm run build + +# Production image, copy all the files and run next +FROM base AS runner +WORKDIR /app + +ENV NODE_ENV=production +ENV NEXT_TELEMETRY_DISABLED=1 + +RUN addgroup --system --gid 1001 nodejs +RUN adduser --system --uid 1001 nextjs + +COPY --from=builder /app/public ./public + +# Automatically leverage output traces to reduce image size +# https://nextjs.org/docs/advanced-features/output-file-tracing +COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./ +COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static +COPY --from=builder --chown=nextjs:nodejs /app/prisma ./prisma + +USER nextjs + +EXPOSE 3000 +ENV PORT=3000 + +ENV HOSTNAME="0.0.0.0" +CMD ["node", "server.js"] \ No newline at end of file diff --git a/next.config.ts b/next.config.ts index af06301..38604e7 100644 --- a/next.config.ts +++ b/next.config.ts @@ -1,6 +1,7 @@ import type { NextConfig } from "next"; const nextConfig: NextConfig = { + output: "standalone", images: { remotePatterns: [ { diff --git a/package.json b/package.json index 9de986c..150f42a 100644 --- a/package.json +++ b/package.json @@ -2,6 +2,7 @@ "name": "tomodachi-share", "version": "0.1.0", "private": true, + "packageManager": "pnpm@10.9.0", "scripts": { "dev": "next dev --turbopack", "build": "next build", diff --git a/pnpm-workspace.yaml b/pnpm-workspace.yaml index 66080a0..4f18af6 100644 --- a/pnpm-workspace.yaml +++ b/pnpm-workspace.yaml @@ -1,5 +1,6 @@ onlyBuiltDependencies: - '@prisma/client' - '@prisma/engines' + - esbuild - prisma - sharp diff --git a/prisma/migrations/20250407113906_images_to_image_count/migration.sql b/prisma/migrations/20250407113906_images_to_image_count/migration.sql deleted file mode 100644 index d2474de..0000000 --- a/prisma/migrations/20250407113906_images_to_image_count/migration.sql +++ /dev/null @@ -1,9 +0,0 @@ -/* - Warnings: - - - You are about to drop the column `images` on the `miis` table. All the data in the column will be lost. - -*/ --- AlterTable -ALTER TABLE "miis" DROP COLUMN "images", -ADD COLUMN "imageCount" INTEGER NOT NULL DEFAULT 0; diff --git a/prisma/migrations/20250418153435_username_updated_at/migration.sql b/prisma/migrations/20250418153435_username_updated_at/migration.sql deleted file mode 100644 index 4f84f6c..0000000 --- a/prisma/migrations/20250418153435_username_updated_at/migration.sql +++ /dev/null @@ -1,2 +0,0 @@ --- AlterTable -ALTER TABLE "users" ADD COLUMN "usernameUpdatedAt" TIMESTAMP(3); diff --git a/prisma/migrations/20250405161120_init/migration.sql b/prisma/migrations/20250423164356_init/migration.sql similarity index 97% rename from prisma/migrations/20250405161120_init/migration.sql rename to prisma/migrations/20250423164356_init/migration.sql index 70f3168..e3a263c 100644 --- a/prisma/migrations/20250405161120_init/migration.sql +++ b/prisma/migrations/20250423164356_init/migration.sql @@ -8,6 +8,7 @@ CREATE TABLE "users" ( "image" TEXT, "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, "updatedAt" TIMESTAMP(3) NOT NULL, + "usernameUpdatedAt" TIMESTAMP(3), CONSTRAINT "users_pkey" PRIMARY KEY ("id") ); @@ -45,7 +46,7 @@ CREATE TABLE "miis" ( "id" SERIAL NOT NULL, "userId" INTEGER NOT NULL, "name" VARCHAR(64) NOT NULL, - "images" TEXT[], + "imageCount" INTEGER NOT NULL DEFAULT 0, "tags" TEXT[], "firstName" TEXT NOT NULL, "lastName" TEXT NOT NULL,