Barazo default frontend barazo.forum
2
fork

Configure Feed

Select the types of activity you want to include in your feed.

fix(docker): rewrite Dockerfile for Next.js standalone output

Replaces broken static-server Dockerfile with proper multi-stage build for
Next.js standalone mode. Handles pnpm workspace directory structure in
standalone output, binds to 0.0.0.0, serves on port 3001.

+68 -30
+19
.dockerignore
··· 1 + node_modules 2 + .next 3 + dist 4 + .git 5 + .gitignore 6 + tests 7 + coverage 8 + .env 9 + .env.* 10 + *.md 11 + LICENSE 12 + vitest.config.ts 13 + eslint.config.mjs 14 + prettier.config.mjs 15 + postcss.config.mjs 16 + commitlint.config.mjs 17 + lint-staged.config.mjs 18 + pnpm-lock.yaml 19 + pnpm-workspace.yaml
+49 -30
Dockerfile
··· 1 - # Multi-stage build for production 2 - # Stage 1: Dependencies 1 + # Multi-stage build for barazo-web (Next.js standalone) 2 + # Build context: monorepo root (docker build -f barazo-web/Dockerfile .) 3 + 4 + # --------------------------------------------------------------------------- 5 + # Stage 1: Install dependencies 6 + # --------------------------------------------------------------------------- 3 7 FROM node:24-alpine AS deps 4 8 RUN apk add --no-cache libc6-compat 5 - WORKDIR /app 9 + WORKDIR /workspace 6 10 7 - # Install pnpm 8 - RUN corepack enable && corepack prepare pnpm@9.0.0 --activate 11 + # Enable pnpm via corepack 12 + RUN corepack enable && corepack prepare pnpm@10.29.2 --activate 9 13 10 - # Copy package files 11 - COPY package.json pnpm-lock.yaml ./ 14 + # Copy workspace root config 15 + COPY package.json pnpm-lock.yaml pnpm-workspace.yaml ./ 16 + 17 + # Copy all workspace package.json files (needed for pnpm install) 18 + COPY barazo-lexicons/package.json ./barazo-lexicons/ 19 + COPY barazo-api/package.json ./barazo-api/ 20 + COPY barazo-web/package.json ./barazo-web/ 21 + 22 + # Install all dependencies 12 23 RUN pnpm install --frozen-lockfile 13 24 14 - # Stage 2: Builder 25 + # --------------------------------------------------------------------------- 26 + # Stage 2: Build 27 + # --------------------------------------------------------------------------- 15 28 FROM node:24-alpine AS builder 16 - WORKDIR /app 29 + WORKDIR /workspace 17 30 18 - # Install pnpm 19 - RUN corepack enable && corepack prepare pnpm@9.0.0 --activate 31 + RUN corepack enable && corepack prepare pnpm@10.29.2 --activate 20 32 21 - # Copy dependencies from deps stage 22 - COPY --from=deps /app/node_modules ./node_modules 23 - COPY . . 33 + # Copy installed dependencies 34 + COPY --from=deps /workspace/ ./ 35 + 36 + # Copy web source 37 + COPY barazo-web/ ./barazo-web/ 24 38 25 - # Build application 39 + # Build Next.js (produces .next/standalone via output: 'standalone') 26 40 ENV NEXT_TELEMETRY_DISABLED=1 27 - RUN pnpm build 41 + RUN pnpm --filter @barazo-forum/web build 28 42 29 - # Stage 3: Production 43 + # --------------------------------------------------------------------------- 44 + # Stage 3: Production runner 45 + # --------------------------------------------------------------------------- 30 46 FROM node:24-alpine AS runner 31 47 WORKDIR /app 32 48 33 49 ENV NODE_ENV=production 34 50 ENV NEXT_TELEMETRY_DISABLED=1 51 + # docker-compose healthcheck expects port 3001 52 + ENV PORT=3001 53 + # Bind to all interfaces (default binds to container hostname only) 54 + ENV HOSTNAME=0.0.0.0 35 55 36 56 # Create non-root user 37 - RUN addgroup --system --gid 1001 nodejs 38 - RUN adduser --system --uid 1001 nextjs 57 + RUN addgroup --system --gid 1001 nodejs && \ 58 + adduser --system --uid 1001 nextjs 59 + 60 + # Copy standalone server (includes node_modules and server.js) 61 + COPY --from=builder --chown=nextjs:nodejs /workspace/barazo-web/.next/standalone/ ./ 39 62 40 - # Copy static files from builder 41 - COPY --from=builder /app/dist ./dist 42 - COPY --from=builder /app/package.json ./package.json 63 + # Copy static assets into the standalone output (must be relative to server.js) 64 + COPY --from=builder --chown=nextjs:nodejs /workspace/barazo-web/.next/static/ ./barazo-web/.next/static/ 65 + COPY --from=builder --chown=nextjs:nodejs /workspace/barazo-web/public/ ./barazo-web/public/ 43 66 44 - # Change ownership 45 67 USER nextjs 46 68 47 - # Expose port 48 - EXPOSE 3000 69 + EXPOSE 3001 49 70 50 - # Health check 51 - HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \ 52 - CMD node -e "require('http').get('http://localhost:3000/api/health', (r) => r.statusCode === 200 ? process.exit(0) : process.exit(1))" 71 + HEALTHCHECK --interval=30s --timeout=10s --start-period=20s --retries=3 \ 72 + CMD wget -qO- http://127.0.0.1:3001/api/health || exit 1 53 73 54 - # Start static server 55 - CMD ["npx", "serve", "dist", "-l", "3000"] 74 + CMD ["node", "barazo-web/server.js"]