d8efa71992
Build and Push Docker Image / build (push) Successful in 1m43s
The classic Docker builder (used by docker-build.yml on the host runner) does not support heredoc COPY syntax, which caused 'COPY failed: no source files were specified'. Replace the heredoc with a checked-in entrypoint.sh copied normally. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
65 lines
1.7 KiB
Docker
65 lines
1.7 KiB
Docker
FROM node:20-alpine AS base
|
|
|
|
# Install dependencies only when needed
|
|
FROM base AS deps
|
|
RUN apk add --no-cache libc6-compat openssl
|
|
WORKDIR /app
|
|
|
|
COPY package.json package-lock.json* ./
|
|
RUN npm install
|
|
|
|
# Rebuild the source code only when needed
|
|
FROM base AS builder
|
|
WORKDIR /app
|
|
COPY --from=deps /app/node_modules ./node_modules
|
|
COPY . .
|
|
|
|
# Generate Prisma Client (with SQLite)
|
|
ENV DATABASE_URL="file:/app/data/dev.db"
|
|
RUN npx prisma generate
|
|
|
|
# Disable telemetry during build
|
|
ENV NEXT_TELEMETRY_DISABLED=1
|
|
|
|
RUN npm run build
|
|
|
|
# Production image, copy all the files and run next
|
|
FROM base AS runner
|
|
WORKDIR /app
|
|
|
|
ENV NODE_ENV=production
|
|
ENV NEXT_TELEMETRY_DISABLED=1
|
|
ENV DATABASE_URL="file:/app/data/dev.db"
|
|
|
|
RUN addgroup --system --gid 1001 nodejs
|
|
RUN adduser --system --uid 1001 nextjs
|
|
|
|
COPY --from=builder /app/public ./public
|
|
|
|
# Set the correct permission for prerender cache
|
|
RUN mkdir .next
|
|
RUN chown nextjs:nodejs .next
|
|
|
|
# Automatically leverage output traces to reduce image size
|
|
COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./
|
|
COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static
|
|
COPY --from=builder --chown=nextjs:nodejs /app/prisma ./prisma
|
|
COPY --from=builder --chown=nextjs:nodejs /app/prisma.config.ts ./prisma.config.ts
|
|
COPY --from=deps --chown=nextjs:nodejs /app/node_modules ./node_modules
|
|
|
|
# Create data directory AFTER all copies so permissions are never clobbered
|
|
RUN mkdir -p /app/data && chown nextjs:nodejs /app/data && chmod 700 /app/data
|
|
|
|
USER nextjs
|
|
|
|
EXPOSE 3000
|
|
|
|
ENV PORT=3000
|
|
|
|
# script to run migrations before starting
|
|
COPY --chown=nextjs:nodejs entrypoint.sh /app/entrypoint.sh
|
|
|
|
RUN chmod +x /app/entrypoint.sh
|
|
|
|
CMD ["/app/entrypoint.sh"]
|