mirror of
https://github.com/xCyanGrizzly/DragonsStash.git
synced 2026-05-11 06:11:15 +00:00
61 lines
1.5 KiB
Docker
61 lines
1.5 KiB
Docker
# ---- Base ----
|
|
FROM node:20-alpine AS base
|
|
RUN apk add --no-cache libc6-compat openssl
|
|
WORKDIR /app
|
|
|
|
# ---- Dependencies ----
|
|
FROM base AS deps
|
|
COPY package.json package-lock.json ./
|
|
RUN npm ci --ignore-scripts
|
|
COPY prisma ./prisma/
|
|
COPY prisma.config.ts ./
|
|
RUN npx prisma generate
|
|
|
|
# ---- Build ----
|
|
FROM base AS builder
|
|
WORKDIR /app
|
|
COPY --from=deps /app/node_modules ./node_modules
|
|
COPY . .
|
|
|
|
ENV NEXT_TELEMETRY_DISABLED=1
|
|
ENV NODE_ENV=production
|
|
|
|
RUN npm run build
|
|
|
|
# ---- Production ----
|
|
FROM base AS runner
|
|
WORKDIR /app
|
|
|
|
ENV NEXT_TELEMETRY_DISABLED=1
|
|
ENV NODE_ENV=production
|
|
|
|
RUN addgroup --system --gid 1001 nodejs
|
|
RUN 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 Prisma files for migrations
|
|
COPY --from=builder /app/prisma ./prisma
|
|
COPY --from=builder /app/prisma.config.ts ./prisma.config.ts
|
|
COPY --from=deps /app/node_modules/.prisma ./node_modules/.prisma
|
|
COPY --from=deps /app/node_modules/@prisma ./node_modules/@prisma
|
|
|
|
# Copy entrypoint
|
|
COPY docker-entrypoint.sh ./
|
|
RUN chmod +x docker-entrypoint.sh
|
|
|
|
USER nextjs
|
|
|
|
EXPOSE 3000
|
|
ENV PORT=3000
|
|
ENV HOSTNAME="0.0.0.0"
|
|
|
|
HEALTHCHECK --interval=30s --timeout=10s --start-period=30s --retries=3 \
|
|
CMD wget --no-verbose --tries=1 --spider http://localhost:3000/api/health || exit 1
|
|
|
|
ENTRYPOINT ["./docker-entrypoint.sh"]
|
|
CMD ["node", "server.js"]
|