| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960 |
- # ---- Base ----
- FROM node:22-alpine AS base
- RUN corepack enable && corepack prepare pnpm@latest --activate
- WORKDIR /app
- # ---- Dependencies ----
- FROM base AS deps
- COPY package.json pnpm-workspace.yaml .pnpm-approve-builds.json ./
- RUN pnpm install
- # ---- Build ----
- FROM base AS builder
- COPY --from=deps /app/node_modules ./node_modules
- COPY . .
- ENV NEXT_TELEMETRY_DISABLED=1
- RUN pnpm build
- # ---- Production ----
- FROM node:22-alpine AS runner
- WORKDIR /app
- ENV NODE_ENV=production
- ENV NEXT_TELEMETRY_DISABLED=1
- # Install su-exec and curl (for healthcheck)
- RUN apk add --no-cache su-exec curl
- # Create non-root user
- RUN addgroup --system --gid 1001 nodejs && \
- adduser --system --uid 1001 nextjs
- # Copy standalone output
- 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
- # Copy CLMM SDK dist (native requires)
- COPY --from=builder /app/src/lib/clmm-sdk/dist ./src/lib/clmm-sdk/dist
- # Copy better-sqlite3 native addon (standalone may miss it)
- COPY --from=builder /app/node_modules/better-sqlite3 ./node_modules/better-sqlite3
- # Data directory for SQLite
- RUN mkdir -p /app/data && chown nextjs:nodejs /app/data
- VOLUME /app/data
- # Entrypoint to fix volume permissions then drop to nextjs user
- COPY docker-entrypoint.sh /usr/local/bin/
- RUN chmod +x /usr/local/bin/docker-entrypoint.sh
- EXPOSE 3000
- ENV HOSTNAME=0.0.0.0
- ENV PORT=3000
- HEALTHCHECK --interval=30s --timeout=5s --start-period=10s --retries=3 \
- CMD curl -f http://localhost:3000/ || exit 1
- ENTRYPOINT ["docker-entrypoint.sh"]
|