From bbf76e3a87d240530ff452c718e44a5bee0f87a3 Mon Sep 17 00:00:00 2001 From: Michael Brusegard <56915010+michaelbrusegard@users.noreply.github.com> Date: Sun, 22 Sep 2024 15:22:16 +0200 Subject: [PATCH] fix: build run by copying static files correctly --- .env.example | 4 +++- Dockerfile | 4 ++-- package.json | 8 ++++---- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/.env.example b/.env.example index 1ec2c58..f407f4e 100644 --- a/.env.example +++ b/.env.example @@ -8,10 +8,12 @@ # When adding additional environment variables, the schema in "/src/env.js" # should be updated accordingly. +# The ARGS in docker-compose.yml and the Dockerfile must also be updated. +# Also update any GitHub Actions that use these variables. # General -NEXT_TELEMETRY_DISABLED="true" NODE_ENV="development" +NEXT_TELEMETRY_DISABLED="true" NEXT_PUBLIC_SITE_URL="http://localhost:3000" # Database diff --git a/Dockerfile b/Dockerfile index bcd4f37..b2f34bd 100644 --- a/Dockerfile +++ b/Dockerfile @@ -18,7 +18,7 @@ COPY --from=deps /app/node_modules ./node_modules COPY . . ENV NODE_ENV=production -ENV NEXT_TELEMETRY_DISABLED=1 +ENV NEXT_TELEMETRY_DISABLED=true ENV SKIP_ENV_VALIDATION=true # Set environment variables during the build @@ -65,7 +65,7 @@ FROM base AS runner WORKDIR /app ENV NODE_ENV=production -ENV NEXT_TELEMETRY_DISABLED=1 +ENV NEXT_TELEMETRY_DISABLED=true ENV SKIP_ENV_VALIDATION=true RUN addgroup --system --gid 1002 nodejs && \ diff --git a/package.json b/package.json index b15b270..8f71801 100644 --- a/package.json +++ b/package.json @@ -5,12 +5,12 @@ "type": "module", "scripts": { "prepare": "if [ \"$NODE_ENV\" != \"production\" ]; then lefthook install; fi", - "postbuild": "next-sitemap", - "prebuild": "next telemetry disable", - "build": "next build", "dev": "next dev --turbo", "lint": "biome check --write", - "start": "next start", + "prebuild": "next telemetry disable", + "build": "next build", + "postbuild": "next-sitemap && mkdir -p .next/standalone/public && mkdir -p .next/standalone/.next/static && cp -R public/* .next/standalone/public/ && cp -R .next/static/* .next/standalone/.next/static/", + "start": "bun run .next/standalone/server.js", "db:start": "docker-compose up db", "db:generate": "drizzle-kit generate", "db:migrate": "drizzle-kit migrate",