12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182 |
- FROM node:18-alpine AS deps
- WORKDIR /app
- RUN npm install -g pnpm
- RUN apk add --no-cache libc6-compat bash
- COPY package.json pnpm-lock.yaml* ./
- RUN pnpm install --no-frozen-lockfile
- FROM node:18-alpine AS builder
- WORKDIR /app
- RUN npm install -g pnpm
- RUN apk add --no-cache bash
- COPY . .
- COPY --from=deps /app/node_modules ./node_modules
- RUN pnpm build
- FROM node:18-alpine AS runner
- WORKDIR /app
- ENV NODE_ENV production
- ENV JWT_SECRET=${JWT_SECRET}
- ENV MONGODB_URI=${MONGODB_URI}
- RUN apk add --no-cache bash
- RUN addgroup -S -g 1001 nodejs && adduser -S -u 1001 -G nodejs nextjs
- COPY --from=builder /app/public ./public
- COPY --from=builder --chown=nextjs:nodejs /app/.next ./.next
- COPY --from=builder /app/node_modules ./node_modules
- COPY --from=builder /app/package.json ./package.json
- RUN mkdir -p /app/public/uploads
- RUN chown -R nextjs:nodejs /app/public
- RUN chown -R nextjs:nodejs /app/public/uploads
- USER root
- RUN chmod 777 /app/public/uploads
- USER nextjs
- EXPOSE 3000
- ENV PORT 3000
- CMD ["/bin/bash", "-c", "node_modules/.bin/next start"]
|