diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..bcd31f1 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,5 @@ +node_modules +.next +.env +.env.local +.git diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..efb5edc --- /dev/null +++ b/Dockerfile @@ -0,0 +1,35 @@ +FROM node:22-alpine AS deps +WORKDIR /app +COPY package*.json ./ +RUN npm ci --legacy-peer-deps + +FROM node:22-alpine AS builder +WORKDIR /app +COPY --from=deps /app/node_modules ./node_modules +COPY . . + +# Build-time env placeholders (real values injected at runtime) +ENV DATABASE_URL=mongodb://placeholder:27017/llm_proxy +ENV REDIS_URL=redis://placeholder:6379 +ENV NEXTAUTH_SECRET=build-placeholder +ENV ENCRYPTION_KEY=0000000000000000000000000000000000000000000000000000000000000000 +ENV NEXT_PUBLIC_APP_NAME="LLM Proxy" +ENV NEXT_PUBLIC_APP_URL=http://localhost:3000 + +RUN npm run build + +FROM node:22-alpine AS runner +WORKDIR /app +ENV NODE_ENV=production +RUN addgroup --system --gid 1001 nodejs && 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 + +USER nextjs +EXPOSE 3000 +ENV PORT=3000 +ENV HOSTNAME="0.0.0.0" + +CMD ["node", "server.js"] diff --git a/next.config.ts b/next.config.ts index c819fd4..d822351 100644 --- a/next.config.ts +++ b/next.config.ts @@ -1,6 +1,7 @@ import type { NextConfig } from "next"; const nextConfig: NextConfig = { + output: "standalone", serverExternalPackages: ["pino", "pino-pretty"], }; diff --git a/package-lock.json b/package-lock.json index f0858ad..fcbf895 100644 --- a/package-lock.json +++ b/package-lock.json @@ -32,6 +32,7 @@ "pino-pretty": "^13.0.0", "react": "^19.1.0", "react-dom": "^19.1.0", + "react-is": "^19.2.4", "react-markdown": "^10.1.0", "recharts": "^3.7.0", "rehype-highlight": "^7.0.2", @@ -2969,6 +2970,7 @@ "version": "19.2.14", "resolved": "https://registry.npmjs.org/@types/react/-/react-19.2.14.tgz", "integrity": "sha512-ilcTH/UniCkMdtexkoCN0bI7pMcJDvmQFPvuPvmEaYA/NSfFTAgdUSLAoVjaRJm7+6PvcM+q1zYOwS4wTYMF9w==", + "dev": true, "license": "MIT", "dependencies": { "csstype": "^3.2.2" @@ -2978,7 +2980,7 @@ "version": "19.2.3", "resolved": "https://registry.npmjs.org/@types/react-dom/-/react-dom-19.2.3.tgz", "integrity": "sha512-jp2L/eY6fn+KgVVQAOqYItbF0VY/YApe5Mz2F0aykSO8gx31bYCZyvSeYxCHKvzHG5eZjc+zyaS5BrBWya2+kQ==", - "devOptional": true, + "dev": true, "license": "MIT", "peerDependencies": { "@types/react": "^19.2.0" @@ -4185,6 +4187,7 @@ "version": "3.2.3", "resolved": "https://registry.npmjs.org/csstype/-/csstype-3.2.3.tgz", "integrity": "sha512-z1HGKcYy2xA8AGQfwrn0PAy+PB7X/GSj3UVJW9qKyn43xWa+gl5nXmU4qqLMRzWVLFC8KusUX8T/0kCiOYpAIQ==", + "dev": true, "license": "MIT" }, "node_modules/d3-array": { @@ -8837,8 +8840,7 @@ "version": "19.2.4", "resolved": "https://registry.npmjs.org/react-is/-/react-is-19.2.4.tgz", "integrity": "sha512-W+EWGn2v0ApPKgKKCy/7s7WHXkboGcsrXE+2joLyVxkbyVQfO3MUEaUQDHoSmb8TFFrSKYa9mw64WZHNHSDzYA==", - "license": "MIT", - "peer": true + "license": "MIT" }, "node_modules/react-markdown": { "version": "10.1.0", diff --git a/package.json b/package.json index 79c056d..b29a9d8 100644 --- a/package.json +++ b/package.json @@ -39,6 +39,7 @@ "pino-pretty": "^13.0.0", "react": "^19.1.0", "react-dom": "^19.1.0", + "react-is": "^19.2.4", "react-markdown": "^10.1.0", "recharts": "^3.7.0", "rehype-highlight": "^7.0.2",