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