Should be ready to host hopefully

This commit is contained in:
2025-09-04 21:22:17 -05:00
parent f716d7c8d6
commit 99bbe03b98
7 changed files with 140 additions and 43 deletions

View File

@@ -0,0 +1,57 @@
import './src/env.js';
import { withSentryConfig } from '@sentry/nextjs';
import { withPlausibleProxy } from 'next-plausible';
/** @type {import("next").NextConfig} */
const nextConfig = withPlausibleProxy({
customDomain: 'https://plausible.gbrown.org',
})({
output: 'standalone',
images: {
remotePatterns: [
{
protocol: 'https',
hostname: '*.gbrown.org',
},
],
},
serverExternalPackages: ['require-in-the-middle'],
experimental: {
serverActions: {
bodySizeLimit: '10mb',
},
},
typescript: {
ignoreBuildErrors: true,
},
eslint: {
ignoreDuringBuilds: true,
},
});
const sentryConfig = {
// For all available options, see:
// https://www.npmjs.com/package/@sentry/webpack-plugin#options
org: 'gib',
project: process.env.NEXT_PUBLIC_SENTRY_PROJECT_NAME,
sentryUrl: process.env.NEXT_PUBLIC_SENTRY_URL,
authToken: process.env.SENTRY_AUTH_TOKEN,
// Only print logs for uploading source maps in CI
silent: !process.env.CI,
// For all available options, see:
// https://docs.sentry.io/platforms/javascript/guides/nextjs/manual-setup/
// Upload a larger set of source maps for prettier stack traces (increases build time)
widenClientFileUpload: true,
// Route browser requests to Sentry through a Next.js rewrite to circumvent ad-blockers.
// This can increase your server load as well as your hosting bill.
// Note: Check that the configured route will not match with your Next.js middleware, otherwise reporting of client-
// side errors will fail.
tunnelRoute: '/monitoring',
// Automatically tree-shake Sentry logger statements to reduce bundle size
disableLogger: true,
// Capture React Component Names
reactComponentAnnotation: {
enabled: true,
},
};
export default withSentryConfig(nextConfig, sentryConfig);

View File

@@ -1,54 +1,48 @@
# syntax=docker/dockerfile:1
FROM oven/bun:latest AS base
# Install dependencies only when needed
# --- Bun on Alpine for build ---
FROM oven/bun:alpine AS base
# --- deps: install node_modules with Bun ---
FROM base AS deps
# Check https://github.com/nodejs/docker-node/tree/b4117f9333da4138b03a546ec926ef50a31506c3#nodealpine to understand why libc6-compat might be needed.
RUN apk add --no-cache libc6-compat
WORKDIR /app
# Install dependencies with Bun
COPY package.json bun.lockb* ./
RUN bun install --frozen-lockfile
RUN \
if [ -f bun.lockb ]; then bun install --frozen-lockfile; \
else echo "Lockfile not found." && exit 1; \
fi
# Rebuild the source code only when needed
# Copy package + whichever Bun lock file you have (optional)
COPY package.json bun.lockb* bun.lock* ./
# If bun.lockb exists, enforce frozen; otherwise install and generate it
RUN if [ -f bun.lockb ]; then \
bun install --frozen-lockfile; \
else \
bun install; \
fi
# --- builder: build Next.js with Bun ---
FROM base AS builder
WORKDIR /app
COPY --from=deps /app/node_modules ./node_modules
COPY . .
ENV NEXT_TELEMETRY_DISABLED=1
RUN bun run build
# Production image, copy all the files and run next
FROM base AS runner
# --- runner: Node on Alpine to run server.js ---
FROM node:20-alpine 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
# non-root user
RUN addgroup -S nodejs -g 1001 && adduser -S nextjs -u 1001
COPY --from=builder /app/public ./public
RUN mkdir .next && chown -R nextjs:nodejs .next
# Set the correct permission for prerender cache
RUN mkdir .next
RUN chown nextjs:nodejs .next
# 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
# Next standalone output
COPY --from=builder /app/.next/standalone ./
COPY --from=builder /app/.next/static ./.next/static
USER nextjs
EXPOSE 3000
ENV PORT=3000
# server.js is created by next build from the standalone output
# https://nextjs.org/docs/pages/api-reference/config/next-config-js/output
ENV HOSTNAME="0.0.0.0"
ENV HOSTNAME=0.0.0.0
CMD ["node", "server.js"]

View File

@@ -6,7 +6,7 @@ services:
build:
context: ../../..
dockerfile: host/next/docker/Dockerfile
image: nextjs
image: techtracker-next:alpine
container_name: techtracker-next
hostname: techtracker-next
domainname: techtracker.gbrown.org

6
host/next/update Normal file → Executable file
View File

@@ -1,9 +1,9 @@
#!/usr/bin/env bash
git pull
bun update
#mv ./next.config.js ./host/next/config/next.config.default.js
#cp ./host/next/config/next.config.build.js ./next.config.js
mv ./next.config.js ./host/next/config/next.config.default.js
cp ./host/next/config/next.config.build.js ./next.config.js
sudo docker compose -f ./host/next/docker/compose.yaml down
sudo docker compose -f ./host/next/docker/compose.yaml build
sudo docker compose -f ./host/next/docker/compose.yaml up -d
#cp ./host/next/config/next.config.default.js ./next.config.js
cp ./host/next/config/next.config.default.js ./next.config.js