From e6f3ebae896cd767f8f6ba0ae0aac53c37034ac4 Mon Sep 17 00:00:00 2001 From: shabebe11 Date: Thu, 14 May 2026 09:42:09 +1200 Subject: [PATCH 1/2] fix: docker file and deployment --- .dockerignore | 13 ++++++++++++- Dockerfile | 54 ++++++++++++++++++++++++++++++++++++++++++++++++--- fly.toml | 2 +- next-env.d.ts | 2 +- package.json | 4 ++-- 5 files changed, 67 insertions(+), 8 deletions(-) diff --git a/.dockerignore b/.dockerignore index 0501d09..883b43c 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1 +1,12 @@ -fly.toml +.git +.github +.next +node_modules +npm-debug.log* +bun-debug.log* +.env +.env.* +!.env.example +Dockerfile +README.md +tsconfig.tsbuildinfo diff --git a/Dockerfile b/Dockerfile index 46a5e4c..8c1a7f1 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,3 +1,51 @@ -FROM pierrezemb/gostatic -COPY . /srv/http/ -CMD ["-port","8080","-https-promote", "-enable-logging"] +# syntax = docker/dockerfile:1 + +# Adjust BUN_VERSION as desired +ARG BUN_VERSION=1.3.14 +FROM oven/bun:${BUN_VERSION}-slim AS base + +LABEL fly_launch_runtime="Next.js" + +# Next.js app lives here +WORKDIR /app + +# Set production environment +ENV NODE_ENV="production" +ENV NEXT_TELEMETRY_DISABLED="1" + + +# Throw-away build stage to reduce size of final image +FROM base AS build + +# Install packages needed to build node modules +RUN apt-get update -qq && \ + apt-get install --no-install-recommends -y build-essential ca-certificates node-gyp pkg-config python-is-python3 && \ + rm -rf /var/lib/apt/lists/* + +# Install node modules +COPY package.json bun.lock prisma.config.ts ./ +COPY prisma ./prisma +RUN bun install --frozen-lockfile + +# Copy application code +COPY . . + +# Build application (runs prisma generate + prisma:sync + next build via package.json) +RUN bun run build + +# Remove development dependencies +RUN bun install --frozen-lockfile --production + + +# Final stage for app image +FROM base + +# Copy built application +COPY --from=build /app /app + +ENV HOSTNAME="0.0.0.0" +ENV PORT="3000" + +# Start the server by default, this can be overwritten at runtime +EXPOSE 3000 +CMD ["bun", "run", "start"] diff --git a/fly.toml b/fly.toml index d4d671e..f89c87e 100644 --- a/fly.toml +++ b/fly.toml @@ -9,7 +9,7 @@ primary_region = 'syd' [build] [http_service] - internal_port = 8080 + internal_port = 3000 force_https = true auto_stop_machines = 'stop' auto_start_machines = true diff --git a/next-env.d.ts b/next-env.d.ts index c4b7818..9edff1c 100644 --- a/next-env.d.ts +++ b/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/package.json b/package.json index 55cb6c4..6c51124 100644 --- a/package.json +++ b/package.json @@ -5,8 +5,8 @@ "type": "module", "scripts": { "dev": "next dev", - "build": "prisma generate && npm run prisma:sync && next build", - "prisma:sync": "node scripts/prisma-sync.mjs", + "build": "prisma generate && bun run prisma:sync && next build", + "prisma:sync": "bun scripts/prisma-sync.mjs", "postinstall": "prisma generate", "lint": "eslint .", "preview": "vite preview", From 5d73f9dec42133df7e0c3a74b68b7b8f7b3b6e81 Mon Sep 17 00:00:00 2001 From: shabebe11 Date: Thu, 14 May 2026 09:53:22 +1200 Subject: [PATCH 2/2] fix: fixed issues with previous changes --- Dockerfile | 11 +++++++++-- package.json | 4 ++-- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/Dockerfile b/Dockerfile index 8c1a7f1..ba80422 100644 --- a/Dockerfile +++ b/Dockerfile @@ -9,8 +9,6 @@ LABEL fly_launch_runtime="Next.js" # Next.js app lives here WORKDIR /app -# Set production environment -ENV NODE_ENV="production" ENV NEXT_TELEMETRY_DISABLED="1" @@ -30,6 +28,13 @@ RUN bun install --frozen-lockfile # Copy application code COPY . . +# Public admin configuration must be present at build time because Next.js +# inlines NEXT_PUBLIC_* values into the client bundle during next build. +ARG NEXT_PUBLIC_ADMIN_ADDRESS +ARG NEXT_PUBLIC_ADMIN_ADDRESSES +ENV NEXT_PUBLIC_ADMIN_ADDRESS="${NEXT_PUBLIC_ADMIN_ADDRESS}" +ENV NEXT_PUBLIC_ADMIN_ADDRESSES="${NEXT_PUBLIC_ADMIN_ADDRESSES}" + # Build application (runs prisma generate + prisma:sync + next build via package.json) RUN bun run build @@ -40,6 +45,8 @@ RUN bun install --frozen-lockfile --production # Final stage for app image FROM base +ENV NODE_ENV="production" + # Copy built application COPY --from=build /app /app diff --git a/package.json b/package.json index 6c51124..2e015bf 100644 --- a/package.json +++ b/package.json @@ -5,8 +5,8 @@ "type": "module", "scripts": { "dev": "next dev", - "build": "prisma generate && bun run prisma:sync && next build", - "prisma:sync": "bun scripts/prisma-sync.mjs", + "build": "prisma generate && node scripts/prisma-sync.mjs && next build", + "prisma:sync": "node scripts/prisma-sync.mjs", "postinstall": "prisma generate", "lint": "eslint .", "preview": "vite preview",