- Add openssl package to all Docker build stages - Ensures Prisma engine works on Alpine Linux ARM64 - Fixes libssl.so.1.1 missing library error
53 lines
1.1 KiB
Docker
53 lines
1.1 KiB
Docker
# Use Node.js LTS version
|
|
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 files
|
|
COPY package.json package-lock.json* ./
|
|
RUN npm ci
|
|
|
|
# Rebuild the source code only when needed
|
|
FROM base AS builder
|
|
RUN apk add --no-cache openssl
|
|
WORKDIR /app
|
|
COPY --from=deps /app/node_modules ./node_modules
|
|
COPY . .
|
|
|
|
# Generate Prisma Client for Alpine Linux
|
|
RUN npx prisma generate
|
|
|
|
# Build Next.js application
|
|
ENV NEXT_TELEMETRY_DISABLED 1
|
|
RUN npm run build
|
|
|
|
# Production image, copy all the files and run next
|
|
FROM base AS runner
|
|
RUN apk add --no-cache openssl
|
|
WORKDIR /app
|
|
|
|
ENV NODE_ENV production
|
|
ENV NEXT_TELEMETRY_DISABLED 1
|
|
|
|
RUN addgroup --system --gid 1001 nodejs
|
|
RUN adduser --system --uid 1001 nextjs
|
|
|
|
# Copy necessary files
|
|
COPY --from=builder /app/public ./public
|
|
COPY --from=builder /app/.next/standalone ./
|
|
COPY --from=builder /app/.next/static ./.next/static
|
|
COPY --from=builder /app/node_modules/.prisma ./node_modules/.prisma
|
|
COPY --from=builder /app/prisma ./prisma
|
|
|
|
USER nextjs
|
|
|
|
EXPOSE 3500
|
|
|
|
ENV PORT 3500
|
|
ENV HOSTNAME "0.0.0.0"
|
|
|
|
CMD ["node", "server.js"]
|