3eeac0fe10
Multi-stage Alpine Dockerfile producing a standalone Next.js image with the better-sqlite3 native addon included. Gitea workflow builds on push to main and on v* tags, pushing to the Gitea registry using the REGISTRY_URL variable and REGISTRY_TOKEN secret. Compose file mounts ./data so alerts.db and settings.json persist across restarts. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
40 lines
1.1 KiB
Docker
40 lines
1.1 KiB
Docker
# syntax=docker/dockerfile:1.7
|
|
ARG NODE_VERSION=22-alpine
|
|
|
|
# ── deps: install node_modules (with native build tools for better-sqlite3) ──
|
|
FROM node:${NODE_VERSION} AS deps
|
|
RUN apk add --no-cache libc6-compat python3 make g++
|
|
WORKDIR /app
|
|
COPY package.json package-lock.json ./
|
|
RUN npm ci
|
|
|
|
# ── builder: produce the standalone Next.js bundle ──
|
|
FROM node:${NODE_VERSION} AS builder
|
|
WORKDIR /app
|
|
COPY --from=deps /app/node_modules ./node_modules
|
|
COPY . .
|
|
ENV NEXT_TELEMETRY_DISABLED=1
|
|
RUN npm run build
|
|
|
|
# ── runner: minimal runtime image ──
|
|
FROM node:${NODE_VERSION} AS runner
|
|
WORKDIR /app
|
|
ENV NODE_ENV=production
|
|
ENV NEXT_TELEMETRY_DISABLED=1
|
|
ENV PORT=3000
|
|
ENV HOSTNAME=0.0.0.0
|
|
|
|
RUN addgroup --system --gid 1001 nodejs \
|
|
&& adduser --system --uid 1001 nextjs
|
|
|
|
COPY --from=builder /app/public ./public
|
|
COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./
|
|
COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static
|
|
|
|
RUN mkdir -p /app/data && chown nextjs:nodejs /app/data
|
|
|
|
USER nextjs
|
|
EXPOSE 3000
|
|
VOLUME ["/app/data"]
|
|
CMD ["node", "server.js"]
|