Files
OverSnitch/Dockerfile
T
josh 3eeac0fe10 Add Docker build and Gitea Actions CI for deployment
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>
2026-04-19 10:04:22 -04:00

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"]