# Install dependencies only when needed FROM node:18-alpine AS builder # 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 COPY . . RUN yarn install --frozen-lockfile # If using npm with a `package-lock.json` comment out above and use below instead # RUN npm ci ENV NEXT_TELEMETRY_DISABLED 1 ARG NEXT_PUBLIC_DOCSEARCH_APP_ID="DG5ZD77AMZ" ARG NEXT_PUBLIC_DOCSEARCH_API_KEY="b676a07ff7e3dbafc495dbe75a8a1c3c" ARG NEXT_PUBLIC_DOCSEARCH_INDEX_NAME="sentrypeer" RUN yarn build # If using npm comment out above and use below instead # RUN npm run build # Production image, copy all the files and run next FROM node:18-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 COPY --from=builder /app ./ USER nextjs CMD ["yarn", "start"] # If using npm comment out above and use below instead # CMD ["npm", "run", "start"]