chore(docker): update Docker and Next.js config
This commit is contained in:
parent
bee5234944
commit
b85841248d
@ -15,12 +15,7 @@ dist
|
||||
.env.test.local
|
||||
.env.production.local
|
||||
|
||||
# Debug
|
||||
npm-debug.log*
|
||||
yarn-debug.log*
|
||||
yarn-error.log*
|
||||
|
||||
# Local files
|
||||
# Development files
|
||||
.git
|
||||
.gitignore
|
||||
README.md
|
||||
@ -47,3 +42,12 @@ test-results
|
||||
# Misc
|
||||
.turbo
|
||||
*.log
|
||||
|
||||
# BMAD output (not needed in container)
|
||||
_bmad-output
|
||||
|
||||
# Docker files
|
||||
Dockerfile
|
||||
.dockerignore
|
||||
docker-compose.yml
|
||||
deploy.sh
|
||||
|
||||
@ -1,9 +1,10 @@
|
||||
FROM node:22-alpine AS base
|
||||
# Multi-stage build for Next.js 16 with Webpack (not Turbopack)
|
||||
# Turbopack has issues with Tailwind CSS 4 in Docker containers
|
||||
|
||||
FROM node:22-alpine AS base
|
||||
# Install dependencies only when needed
|
||||
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
|
||||
RUN apk add --no-cache libc6-compat openssl
|
||||
WORKDIR /app
|
||||
|
||||
# Install dependencies based on the preferred package manager
|
||||
@ -16,19 +17,19 @@ WORKDIR /app
|
||||
COPY --from=deps /app/node_modules ./node_modules
|
||||
COPY . .
|
||||
|
||||
# Generate Prisma Client
|
||||
# Generate Prisma Client before build
|
||||
RUN npx prisma generate
|
||||
|
||||
# Build Next.js
|
||||
# Build Next.js with Webpack (not Turbopack) to avoid Tailwind CSS issues
|
||||
ENV NEXT_TELEMETRY_DISABLED=1
|
||||
RUN npm run build
|
||||
|
||||
# Production image, copy all the files and run next
|
||||
FROM base AS runner
|
||||
WORKDIR /app
|
||||
|
||||
ENV NODE_ENV production
|
||||
# Uncomment the following line in case you want to disable telemetry during runtime.
|
||||
# ENV NEXT_TELEMETRY_DISABLED 1
|
||||
ENV NODE_ENV=production
|
||||
ENV NEXT_TELEMETRY_DISABLED=1
|
||||
|
||||
RUN addgroup --system --gid 1001 nodejs
|
||||
RUN adduser --system --uid 1001 nextjs
|
||||
@ -40,21 +41,19 @@ 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
|
||||
|
||||
# Copy Prisma schema and migrations for runtime usage if needed
|
||||
# Copy Prisma for runtime
|
||||
COPY --from=builder /app/prisma ./prisma
|
||||
COPY --from=builder /app/node_modules/.prisma ./node_modules/.prisma
|
||||
|
||||
USER nextjs
|
||||
|
||||
EXPOSE 3000
|
||||
|
||||
ENV PORT 3000
|
||||
# set hostname to localhost
|
||||
ENV HOSTNAME "0.0.0.0"
|
||||
ENV PORT=3000
|
||||
ENV HOSTNAME="0.0.0.0"
|
||||
|
||||
# server.js is created by next build from the standalone output
|
||||
# https://nextjs.org/docs/pages/api-reference/next-config-js/output
|
||||
CMD ["node", "server.js"]
|
||||
|
||||
@ -15,10 +15,13 @@ services:
|
||||
- DATABASE_URL=file:/app/prisma/dev.db
|
||||
- NODE_ENV=production
|
||||
|
||||
# Application (Change these!)
|
||||
# Application (IMPORTANT: Change these!)
|
||||
- NEXTAUTH_URL=http://your-domain.com:3000
|
||||
- NEXTAUTH_SECRET=change-this-to-a-random-secret-string
|
||||
|
||||
# Disable Next.js telemetry
|
||||
- NEXT_TELEMETRY_DISABLED=1
|
||||
|
||||
# AI Provider (Optional - for OpenAI)
|
||||
# - OPENAI_API_KEY=your-openai-api-key-here
|
||||
|
||||
@ -45,7 +48,7 @@ services:
|
||||
reservations:
|
||||
cpus: '0.5'
|
||||
memory: 512M
|
||||
# Optional: Health check
|
||||
# Health check for automatic restart
|
||||
healthcheck:
|
||||
test: ["CMD", "wget", "--spider", "-q", "http://localhost:3000"]
|
||||
interval: 30s
|
||||
@ -73,14 +76,6 @@ services:
|
||||
# reservations:
|
||||
# cpus: '2'
|
||||
# memory: 4G
|
||||
# # GPU support for Proxmox with GPU passthrough
|
||||
# # deploy:
|
||||
# # resources:
|
||||
# # reservations:
|
||||
# # devices:
|
||||
# # - driver: nvidia
|
||||
# # count: 1
|
||||
# # capabilities: [gpu]
|
||||
|
||||
networks:
|
||||
keep-network:
|
||||
|
||||
@ -1,5 +1,4 @@
|
||||
import type { NextConfig } from "next";
|
||||
import path from "path";
|
||||
|
||||
const withPWA = require("@ducanh2912/next-pwa").default({
|
||||
dest: "public",
|
||||
@ -12,10 +11,8 @@ const nextConfig: NextConfig = {
|
||||
// Enable standalone output for Docker
|
||||
output: 'standalone',
|
||||
|
||||
turbopack: {
|
||||
// Set root to parent directory to support monorepo workspace structure
|
||||
root: path.resolve(__dirname, ".."),
|
||||
},
|
||||
// Disable Turbopack for Docker builds - use Webpack instead
|
||||
// Turbopack has issues with Tailwind CSS 4 in Docker containers
|
||||
|
||||
// Optimize for production
|
||||
reactStrictMode: true,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user