mirror of
https://github.com/xCyanGrizzly/DragonsStash.git
synced 2026-05-10 22:01:16 +00:00
66 lines
1.9 KiB
Docker
66 lines
1.9 KiB
Docker
FROM node:20-alpine AS base
|
|
|
|
# --- Install dependencies ---
|
|
FROM base AS deps
|
|
RUN apk add --no-cache libc6-compat
|
|
WORKDIR /app
|
|
|
|
COPY package.json package-lock.json ./
|
|
COPY prisma ./prisma/
|
|
RUN npm ci
|
|
|
|
# --- Build the application ---
|
|
FROM base AS builder
|
|
WORKDIR /app
|
|
|
|
COPY --from=deps /app/node_modules ./node_modules
|
|
COPY . .
|
|
|
|
ENV NEXT_TELEMETRY_DISABLED=1
|
|
RUN npm run build
|
|
|
|
# --- Production image ---
|
|
FROM base AS runner
|
|
WORKDIR /app
|
|
|
|
ENV NODE_ENV=production
|
|
ENV NEXT_TELEMETRY_DISABLED=1
|
|
|
|
RUN addgroup --system --gid 1001 nodejs && \
|
|
adduser --system --uid 1001 nextjs
|
|
|
|
# Copy public assets
|
|
COPY --from=builder /app/public ./public
|
|
|
|
# Copy prisma schema + migrations for runtime migrate deploy
|
|
COPY --from=builder /app/prisma ./prisma
|
|
COPY --from=builder /app/prisma.config.ts ./prisma.config.ts
|
|
|
|
# Copy standalone build output
|
|
COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./
|
|
COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static
|
|
|
|
# Copy node_modules for prisma CLI (needed for migrate deploy at startup)
|
|
COPY --from=builder /app/node_modules/.prisma ./node_modules/.prisma
|
|
COPY --from=builder /app/node_modules/@prisma ./node_modules/@prisma
|
|
COPY --from=builder /app/node_modules/prisma ./node_modules/prisma
|
|
COPY --from=builder /app/node_modules/dotenv ./node_modules/dotenv
|
|
COPY --from=builder /app/node_modules/valibot ./node_modules/valibot
|
|
# Create the .bin/prisma symlink so Node resolves __dirname to prisma/build/,
|
|
# where the WASM files live (COPY dereferences symlinks, breaking WASM resolution)
|
|
RUN mkdir -p ./node_modules/.bin && \
|
|
ln -sf ../prisma/build/index.js ./node_modules/.bin/prisma
|
|
|
|
# Copy entrypoint script
|
|
COPY --chown=nextjs:nodejs docker-entrypoint.sh ./
|
|
RUN chmod +x docker-entrypoint.sh
|
|
|
|
USER nextjs
|
|
|
|
EXPOSE 3000
|
|
ENV PORT=3000
|
|
ENV HOSTNAME="0.0.0.0"
|
|
|
|
ENTRYPOINT ["./docker-entrypoint.sh"]
|
|
CMD ["node", "server.js"]
|