Next.js Discord

Discord Forum

npm run build is stuck

Unanswered
Seppala Siberian Sleddog posted this in #help-forum
Open in Discord
Seppala Siberian SleddogOP
I'm stuck when trying to run the command npm run build inside a docker image, it's only showing creating optimized build for production for 18 minutes this is just happened as I migrated to NextJs 16 and started facing this issue here is the docker file
# ─────────────── Stage 1: Build ───────────────
FROM node:22-alpine AS builder

WORKDIR /app

# Install system dependencies
RUN apk add --no-cache libc6-compat

# Copy package metadata and install dependencies
COPY package*.json .npmrc source.config.ts next.config.mjs  ./
RUN npm ci

## Copy application code and build
COPY . .
RUN npm run build

# ─────────────── Stage 2: Production ───────────────
FROM node:22-alpine AS runner

WORKDIR /app

# Install system dependencies
RUN apk add --no-cache libc6-compat

# Create non-root user
RUN addgroup -g 1001 -S nodejs && adduser -S appuser -u 1001
USER appuser

# Copy only necessary runtime files
COPY --from=builder /app/public ./public
COPY --from=builder /app/.env.local ./.env.local
COPY --from=builder /app/.next ./.next
COPY --from=builder /app/.source ./.source
COPY --from=builder /app/node_modules ./node_modules
COPY --from=builder /app/package.json ./package.json

# Expose Next.js default port
EXPOSE 3000

CMD ["npm", "start"]

0 Replies