| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859 |
- # ---- 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-lock.yaml pnpm-workspace.yaml .pnpm-approve-builds.json ./
- RUN pnpm install --frozen-lockfile
- # ---- 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 for dropping privileges in entrypoint
- RUN apk add --no-cache su-exec
- # 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
- COPY --from=builder /app/node_modules/bindings ./node_modules/bindings
- COPY --from=builder /app/node_modules/file-uri-to-path ./node_modules/file-uri-to-path
- # 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
- ENTRYPOINT ["docker-entrypoint.sh"]
|