diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..d34e3b1 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,50 @@ +# Stage 1: Dependencies +FROM node:20-alpine AS deps + +RUN apk add --no-cache libc6-compat + +WORKDIR /app + +COPY package.json package-lock.json* ./ + +RUN npm ci + +# Stage 2: Build +FROM node:20-alpine AS builder + +WORKDIR /app + +COPY --from=deps /app/node_modules ./node_modules +COPY . . + +RUN npx prisma generate + +RUN npm run build + +# Stage 3: Production +FROM node:20-alpine AS runner + +WORKDIR /app + +ENV NODE_ENV=production + +RUN addgroup --system --gid 1001 nodejs +RUN adduser --system --uid 1001 nextjs + +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/node_modules/.prisma ./node_modules/.prisma + +COPY --from=builder /app/prisma/schema.prisma /app/schema.prisma + +USER nextjs + +EXPOSE 3000 + +ENV PORT=3000 +ENV HOSTNAME="0.0.0.0" +ENV DATABASE_URL="file:./dev.db" + +CMD ["node", "server.js"] diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..cf2b7cb --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,12 @@ +services: + app: + build: + context: . + dockerfile: Dockerfile + ports: + - "3000:3000" + volumes: + - ./prisma:/app/prisma + environment: + - DATABASE_URL=file:./dev.db + restart: unless-stopped diff --git a/next.config.ts b/next.config.ts index e9ffa30..225e495 100644 --- a/next.config.ts +++ b/next.config.ts @@ -1,7 +1,7 @@ import type { NextConfig } from "next"; const nextConfig: NextConfig = { - /* config options here */ + output: 'standalone', }; export default nextConfig;