2026-05-03 20:15:39 +03:30
|
|
|
# Build stage — produces `.next/standalone` (see next.config.ts output: standalone)
|
2026-05-05 00:01:06 +03:30
|
|
|
FROM node:20-alpine AS builder
|
2026-04-23 15:33:11 +03:30
|
|
|
|
|
|
|
|
WORKDIR /app
|
|
|
|
|
|
|
|
|
|
COPY package*.json ./
|
2026-07-20 21:11:08 +03:30
|
|
|
# Same safeguard as backend: incomplete npm ci can leave node_modules/.bin empty.
|
|
|
|
|
RUN npm ci --no-audit --no-fund || true; \
|
|
|
|
|
if [ ! -e node_modules/.bin/next ]; then \
|
|
|
|
|
echo "Incomplete npm ci (missing .bin links) — falling back to npm install"; \
|
|
|
|
|
rm -rf node_modules; \
|
|
|
|
|
npm install --no-audit --no-fund; \
|
|
|
|
|
fi; \
|
|
|
|
|
test -e node_modules/.bin/next
|
2026-04-23 15:33:11 +03:30
|
|
|
|
|
|
|
|
COPY . .
|
|
|
|
|
|
2026-05-03 20:15:39 +03:30
|
|
|
ARG NEXT_PUBLIC_API_URL
|
|
|
|
|
ARG NEXT_PUBLIC_APP_URL
|
|
|
|
|
ARG NEXT_PUBLIC_APP_NAME
|
|
|
|
|
|
2026-04-23 15:33:11 +03:30
|
|
|
ENV NEXT_TELEMETRY_DISABLED=1
|
|
|
|
|
ENV NODE_ENV=production
|
2026-05-03 20:15:39 +03:30
|
|
|
ENV NEXT_PUBLIC_API_URL=${NEXT_PUBLIC_API_URL}
|
|
|
|
|
ENV NEXT_PUBLIC_APP_URL=${NEXT_PUBLIC_APP_URL}
|
|
|
|
|
ENV NEXT_PUBLIC_APP_NAME=${NEXT_PUBLIC_APP_NAME}
|
2026-04-23 15:33:11 +03:30
|
|
|
|
|
|
|
|
RUN npm run build
|
|
|
|
|
|
2026-05-03 20:15:39 +03:30
|
|
|
# Production — minimal runtime using Next.js standalone bundle
|
2026-05-05 00:01:06 +03:30
|
|
|
FROM node:20-alpine AS runner
|
2026-05-03 20:15:39 +03:30
|
|
|
|
|
|
|
|
RUN apk add --no-cache dumb-init
|
2026-04-23 15:33:11 +03:30
|
|
|
|
|
|
|
|
WORKDIR /app
|
|
|
|
|
|
|
|
|
|
RUN addgroup -g 1001 -S nodejs && \
|
|
|
|
|
adduser -S dyolink -u 1001
|
|
|
|
|
|
2026-05-03 20:15:39 +03:30
|
|
|
ENV NODE_ENV=production
|
|
|
|
|
ENV PORT=3000
|
|
|
|
|
ENV HOSTNAME=0.0.0.0
|
2026-04-23 15:33:11 +03:30
|
|
|
|
|
|
|
|
COPY --from=builder /app/public ./public
|
2026-05-03 20:15:39 +03:30
|
|
|
COPY --from=builder --chown=dyolink:nodejs /app/.next/standalone ./
|
|
|
|
|
COPY --from=builder --chown=dyolink:nodejs /app/.next/static ./.next/static
|
2026-04-23 15:33:11 +03:30
|
|
|
|
2026-05-03 20:15:39 +03:30
|
|
|
COPY docker-entrypoint.sh /usr/local/bin/docker-entrypoint.sh
|
|
|
|
|
RUN chmod +x /usr/local/bin/docker-entrypoint.sh
|
2026-04-23 15:33:11 +03:30
|
|
|
|
|
|
|
|
USER dyolink
|
|
|
|
|
|
|
|
|
|
EXPOSE 3000
|
|
|
|
|
|
2026-05-03 20:15:39 +03:30
|
|
|
HEALTHCHECK --interval=30s --timeout=5s --start-period=40s --retries=3 \
|
|
|
|
|
CMD node -e "require('http').get('http://127.0.0.1:3000/', (r) => {if(r.statusCode!==200)process.exit(1)})"
|
2026-04-23 15:33:11 +03:30
|
|
|
|
|
|
|
|
ENTRYPOINT ["dumb-init", "--", "docker-entrypoint.sh"]
|
|
|
|
|
|
2026-05-03 20:15:39 +03:30
|
|
|
CMD ["node", "server.js"]
|