spomeni/Dockerfile
2026-08-03 19:43:28 +02:00

71 lines
2.1 KiB
Docker

FROM node:20-alpine AS base
FROM base AS deps
RUN apk add --no-cache libc6-compat
WORKDIR /app
COPY package.json package-lock.json ./
RUN npm ci
FROM base AS builder
WORKDIR /app
RUN apk add --no-cache openssl
# NEXT_PUBLIC_* vars are inlined into the client bundle at build time. Pass
# them via build args (Coolify: mark them as build variables) or the browser
# ClerkProvider / public URLs will be missing.
ARG NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY
ARG NEXT_PUBLIC_CLERK_FAPI_HOST
ARG NEXT_PUBLIC_CLERK_SIGN_IN_URL
ARG NEXT_PUBLIC_CLERK_SIGN_UP_URL
ARG NEXT_PUBLIC_CLERK_SIGN_IN_FALLBACK_REDIRECT_URL
ARG NEXT_PUBLIC_CLERK_SIGN_UP_FALLBACK_REDIRECT_URL
ARG NEXT_PUBLIC_APP_URL
ARG NEXT_PUBLIC_APP_DOMAIN
COPY --from=deps /app/node_modules ./node_modules
COPY package.json package-lock.json ./
COPY next.config.ts ./
COPY tsconfig.json ./
COPY postcss.config.mjs ./
COPY eslint.config.mjs ./
COPY prisma ./prisma
COPY src ./src
COPY public ./public
RUN npx prisma generate
RUN npm run build
FROM base AS runner
WORKDIR /app
ENV NODE_ENV=production
RUN apk add --no-cache openssl wget
RUN addgroup --system --gid 1001 nodejs
RUN adduser --system --uid 1001 nextjs
COPY --from=builder /app/public ./public
COPY --from=builder /app/.next/standalone ./
COPY --from=builder /app/.next/static ./.next/static
COPY --from=builder /app/prisma ./prisma
COPY --from=builder /app/node_modules/.prisma ./node_modules/.prisma
COPY --from=builder /app/node_modules/@prisma ./node_modules/@prisma
# The `prisma` CLI is not part of the standalone trace, and `npx prisma`
# fails non-interactively in the runner. Install it (pinned to the project's
# Prisma version) so `scripts/start.sh` can run `prisma migrate deploy`.
RUN npm install --no-save --no-audit --no-fund prisma@5.22.0
COPY scripts/start.sh /app/start.sh
RUN chmod +x /app/start.sh
RUN chown -R nextjs:nodejs /app
USER nextjs
EXPOSE 3000
ENV PORT=3000
ENV HOSTNAME="0.0.0.0"
HEALTHCHECK --interval=30s --timeout=5s --start-period=15s --retries=3 \
CMD wget --quiet --spider http://localhost:3000/api/check-subdomain?slug=__health || exit 1
CMD ["/bin/sh", "/app/start.sh"]