Dockerfile 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. # ---- Base ----
  2. FROM node:22-alpine AS base
  3. RUN corepack enable && corepack prepare pnpm@latest --activate
  4. WORKDIR /app
  5. # ---- Dependencies ----
  6. FROM base AS deps
  7. COPY package.json pnpm-workspace.yaml .pnpm-approve-builds.json ./
  8. RUN pnpm install
  9. # ---- Build ----
  10. FROM base AS builder
  11. COPY --from=deps /app/node_modules ./node_modules
  12. COPY . .
  13. ENV NEXT_TELEMETRY_DISABLED=1
  14. RUN pnpm build
  15. # ---- Production ----
  16. FROM node:22-alpine AS runner
  17. WORKDIR /app
  18. ENV NODE_ENV=production
  19. ENV NEXT_TELEMETRY_DISABLED=1
  20. # Install su-exec and curl (for healthcheck)
  21. RUN apk add --no-cache su-exec curl
  22. # Create non-root user
  23. RUN addgroup --system --gid 1001 nodejs && \
  24. adduser --system --uid 1001 nextjs
  25. # Copy standalone output
  26. COPY --from=builder /app/public ./public
  27. COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./
  28. COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static
  29. # Copy CLMM SDK dist (native requires)
  30. COPY --from=builder /app/src/lib/clmm-sdk/dist ./src/lib/clmm-sdk/dist
  31. # Copy better-sqlite3 native addon (standalone may miss it)
  32. COPY --from=builder /app/node_modules/better-sqlite3 ./node_modules/better-sqlite3
  33. # Data directory for SQLite
  34. RUN mkdir -p /app/data && chown nextjs:nodejs /app/data
  35. VOLUME /app/data
  36. # Entrypoint to fix volume permissions then drop to nextjs user
  37. COPY docker-entrypoint.sh /usr/local/bin/
  38. RUN chmod +x /usr/local/bin/docker-entrypoint.sh
  39. EXPOSE 3000
  40. ENV HOSTNAME=0.0.0.0
  41. ENV PORT=3000
  42. HEALTHCHECK --interval=30s --timeout=5s --start-period=10s --retries=3 \
  43. CMD curl -f http://localhost:3000/ || exit 1
  44. ENTRYPOINT ["docker-entrypoint.sh"]