diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..5d16fd5 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,10 @@ +node_modules +.git +.next +.env* +README.md +.docker +docker-compose.dev.yml +docker/ +drizzle/ +*.log \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..fb5fa4c --- /dev/null +++ b/Dockerfile @@ -0,0 +1,29 @@ +# Stage 1: Install dependencies +FROM node:20-alpine AS deps +RUN corepack enable && apk add --no-cache libc6-compat +WORKDIR /app +COPY package.json pnpm-lock.yaml ./ +RUN pnpm install --frozen-lockfile + +# Stage 2: Build the app +FROM node:20-alpine AS builder +RUN corepack enable && apk add --no-cache libc6-compat openssl +WORKDIR /app +COPY --from=deps /app/node_modules ./node_modules +COPY . . +RUN pnpm build + +# Stage 3: Production runner +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 --chown=nextjs:nodejs /app/.next/standalone ./ +COPY --from=builder /app/.next/static .next/static +USER nextjs +EXPOSE 3000 +ENV PORT=3000 +ENV HOSTNAME="0.0.0.0" +CMD ["node", "server.js"] \ No newline at end of file diff --git a/next.config.ts b/next.config.ts index e9ffa30..de2d453 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; +export default nextConfig; \ No newline at end of file