mirror of
https://github.com/R0m1k3/Menu.git
synced 2026-10-11 17:28:28 +02:00
69 lines
1.8 KiB
Docker
69 lines
1.8 KiB
Docker
# Stage 1: Build
|
|
FROM node:22-bookworm-slim AS builder
|
|
|
|
WORKDIR /app
|
|
|
|
# Install build dependencies
|
|
RUN apt-get update && apt-get install -y \
|
|
python3 \
|
|
make \
|
|
g++ \
|
|
build-essential \
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
COPY package*.json ./
|
|
COPY prisma ./prisma/
|
|
|
|
RUN npm install
|
|
|
|
COPY . .
|
|
|
|
# Generate Prisma Client (crucial for standalone)
|
|
RUN npx prisma generate
|
|
|
|
# Build Next.js app
|
|
ENV DATABASE_URL="file:./build.db"
|
|
RUN npm run build
|
|
|
|
# Stage 2: Runner
|
|
FROM node:22-bookworm-slim AS runner
|
|
|
|
WORKDIR /app
|
|
|
|
ENV NODE_ENV=production
|
|
ENV NEXT_TELEMETRY_DISABLED=1
|
|
|
|
# Install runtime dependencies
|
|
RUN apt-get update && apt-get install -y \
|
|
openssl \
|
|
curl \
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
# Copy standalone build and static 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/prisma ./prisma
|
|
COPY --from=builder /app/prisma.config.ts ./prisma.config.ts
|
|
|
|
# Explicitly copy all native/prisma node_modules (required for standalone mode)
|
|
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/better-sqlite3 ./node_modules/better-sqlite3
|
|
COPY --from=builder /app/node_modules/bcrypt ./node_modules/bcrypt
|
|
COPY --from=builder /app/node_modules/bindings ./node_modules/bindings
|
|
COPY --from=builder /app/node_modules/file-uri-to-path ./node_modules/file-uri-to-path
|
|
COPY --from=builder /app/node_modules/node-addon-api ./node_modules/node-addon-api
|
|
|
|
# Ensure prisma directory is accessible and writable for SQLite
|
|
RUN mkdir -p /app/prisma && chmod -R 777 /app/prisma
|
|
|
|
# Expose port
|
|
EXPOSE 3214
|
|
|
|
# Set up entrypoint script
|
|
COPY entrypoint.sh ./
|
|
RUN chmod +x entrypoint.sh
|
|
|
|
ENTRYPOINT ["./entrypoint.sh"]
|