diff --git a/.env.example b/.env.example index 05f9b28..af1dee4 100644 --- a/.env.example +++ b/.env.example @@ -2,7 +2,7 @@ NEXT_PUBLIC_BASE_URL=https://reducelink.arthurp.fr # Base de données SQLite -DATABASE_URL="file:./dev.db" +DATABASE_URL="file:/app/data/db.db" # Port exposé côté machine APP_PORT=3000 diff --git a/Dockerfile b/Dockerfile index 6f683e1..1f97ea7 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,30 +1,54 @@ -# ===== BUILD ===== +# ========================= +# BUILD STAGE +# ========================= FROM node:20-alpine AS builder WORKDIR /app +# dépendances COPY package*.json ./ RUN npm ci +# code source COPY . . +# Prisma generate (OBLIGATOIRE avant build Next) +RUN npx prisma generate + +# build Next.js (standalone) RUN npm run build -# ===== RUN ===== +# ========================= +# RUN STAGE +# ========================= FROM node:20-alpine AS runner WORKDIR /app ENV NODE_ENV=production +ENV PORT=3000 -# Standalone output -COPY --from=builder /app/public ./public +# Installer uniquement les deps prod (nécessaire pour Prisma runtime) +COPY package*.json ./ +RUN npm ci --omit=dev + +# Next standalone output COPY --from=builder /app/.next/standalone ./ COPY --from=builder /app/.next/static ./.next/static +COPY --from=builder /app/public ./public + +# Prisma (schema + migrations + seed si existant) COPY --from=builder /app/prisma ./prisma -RUN prism generate +# Prisma client généré +COPY --from=builder /app/node_modules/.prisma ./node_modules/.prisma +COPY --from=builder /app/node_modules/@prisma ./node_modules/@prisma + +# SQLite data folder (IMPORTANT) +RUN mkdir -p /app/data + +VOLUME ["/app/data"] EXPOSE 3000