38 lines
956 B
Docker
38 lines
956 B
Docker
FROM node:22-alpine AS builder
|
|
|
|
WORKDIR /app
|
|
|
|
ARG NPM_REGISTRY=https://package-mirror.liara.ir/repository/npm/
|
|
|
|
COPY package.json package-lock.json ./
|
|
RUN npm ci \
|
|
--registry="${NPM_REGISTRY}" \
|
|
--replace-registry-host=registry.npmjs.org \
|
|
--include=optional
|
|
|
|
COPY . .
|
|
RUN npm run build
|
|
|
|
FROM node:22-alpine AS runtime
|
|
|
|
WORKDIR /app
|
|
ENV NODE_ENV=production \
|
|
HOSTNAME=0.0.0.0 \
|
|
PORT=3000
|
|
|
|
RUN addgroup --system --gid 1001 nodejs \
|
|
&& adduser --system --uid 1001 nextjs
|
|
|
|
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/public ./public
|
|
RUN mkdir -p .next/cache && chown -R nextjs:nodejs .next/cache
|
|
|
|
USER nextjs
|
|
EXPOSE 3000
|
|
|
|
HEALTHCHECK --interval=30s --timeout=3s --start-period=10s --retries=3 \
|
|
CMD wget --no-verbose --tries=1 --spider http://127.0.0.1:3000/ || exit 1
|
|
|
|
CMD ["node", "server.js"]
|