From 53ea42db944601a5556e5c47f6e74e36399080e6 Mon Sep 17 00:00:00 2001 From: Avisek Date: Mon, 30 Mar 2026 08:58:37 +0530 Subject: [PATCH 1/2] feat: add Docker support with multi-stage production builds and development configuration --- .dockerignore | 60 ++++++++++++++++++++++++ Dockerfile | 114 +++++++++++++++++++++++++++++++++++++++++++++ Dockerfile.dev | 15 ++++++ README.md | 44 +++++++++-------- docker-compose.yml | 53 +++++++++++++++++++++ next.config.ts | 1 + 6 files changed, 268 insertions(+), 19 deletions(-) create mode 100644 .dockerignore create mode 100644 Dockerfile create mode 100644 Dockerfile.dev create mode 100644 docker-compose.yml diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 00000000..6f4507bd --- /dev/null +++ b/.dockerignore @@ -0,0 +1,60 @@ +# Dependencies (reinstalled inside Docker) +node_modules +pnpm-debug.log* +npm-debug.log* +yarn-debug.log* + +# Build output +.next +out +build +dist + +# Git +.git +.gitignore + +# Environment files (pass via docker-compose env_file or runtime env vars) +.env +.env.local +.env.*.local + +# Editor / OS +.vscode +.idea +.DS_Store +Thumbs.db +*.swp +*.swo + +# Agent / AI tool configs (not needed at runtime) +.claude +.codex +.cursor +.windsurf +.gemini +.continue +.amazonq +.augment +.opencode +.aider.conf.yml +.clinerules +.windsurfrules +AGENTS.md +CLAUDE.md +GEMINI.md + +# Docs / research (large, not needed at runtime) +docs +scripts + +# Docker files themselves (no need to copy into image) +Dockerfile +docker-compose.yml +.dockerignore + +# Misc +*.tsbuildinfo +README.md +CHANGELOG.md +LICENSE diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..2e5a33a0 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,114 @@ +# SRC https://github.com/vercel/next.js/blob/canary/examples/with-docker/Dockerfile + +# ============================================ +# Stage 1: Dependencies Installation Stage +# ============================================ + +# IMPORTANT: Node.js Version Maintenance +# This Dockerfile uses Node.js 24.13.0-slim, which was the latest LTS version at the time of writing. +# To ensure security and compatibility, regularly update the NODE_VERSION ARG to the latest LTS version. +ARG NODE_VERSION=24.13.0-slim + +FROM node:${NODE_VERSION} AS dependencies + +# Set working directory +WORKDIR /app + +# Copy package-related files first to leverage Docker's caching mechanism +COPY package.json yarn.lock* package-lock.json* pnpm-lock.yaml* .npmrc* ./ + +# Install project dependencies with frozen lockfile for reproducible builds +RUN --mount=type=cache,target=/root/.npm \ + --mount=type=cache,target=/usr/local/share/.cache/yarn \ + --mount=type=cache,target=/root/.local/share/pnpm/store \ + if [ -f package-lock.json ]; then \ + npm ci --no-audit --no-fund; \ + elif [ -f yarn.lock ]; then \ + corepack enable yarn && yarn install --frozen-lockfile --production=false; \ + elif [ -f pnpm-lock.yaml ]; then \ + corepack enable pnpm && pnpm install --frozen-lockfile; \ + else \ + echo "No lockfile found." && exit 1; \ + fi + +# ============================================ +# Stage 2: Build Next.js application in standalone mode +# ============================================ + +FROM node:${NODE_VERSION} AS builder + +# Set working directory +WORKDIR /app + +# Copy project dependencies from dependencies stage +COPY --from=dependencies /app/node_modules ./node_modules + +# Copy application source code +COPY . . + +ENV NODE_ENV=production + +# Next.js collects completely anonymous telemetry data about general usage. +# Learn more here: https://nextjs.org/telemetry +# Uncomment the following line in case you want to disable telemetry during the build. +# ENV NEXT_TELEMETRY_DISABLED=1 + +# Build Next.js application +# If you want to speed up Docker rebuilds, you can cache the build artifacts +# by adding: --mount=type=cache,target=/app/.next/cache +# This caches the .next/cache directory across builds, but it also prevents +# .next/cache/fetch-cache from being included in the final image, meaning +# cached fetch responses from the build won't be available at runtime. +RUN if [ -f package-lock.json ]; then \ + npm run build; \ + elif [ -f yarn.lock ]; then \ + corepack enable yarn && yarn build; \ + elif [ -f pnpm-lock.yaml ]; then \ + corepack enable pnpm && pnpm build; \ + else \ + echo "No lockfile found." && exit 1; \ + fi + +# ============================================ +# Stage 3: Run Next.js application +# ============================================ + +FROM node:${NODE_VERSION} AS runner + +# Set working directory +WORKDIR /app + +# Set production environment variables +ENV NODE_ENV=production +ENV PORT=3000 +ENV HOSTNAME="0.0.0.0" + +# Next.js collects completely anonymous telemetry data about general usage. +# Learn more here: https://nextjs.org/telemetry +# Uncomment the following line in case you want to disable telemetry during the run time. +# ENV NEXT_TELEMETRY_DISABLED=1 + +# Copy production assets +COPY --from=builder --chown=node:node /app/public ./public + +# Set the correct permission for prerender cache +RUN mkdir .next +RUN chown node:node .next + +# Automatically leverage output traces to reduce image size +# https://nextjs.org/docs/advanced-features/output-file-tracing +COPY --from=builder --chown=node:node /app/.next/standalone ./ +COPY --from=builder --chown=node:node /app/.next/static ./.next/static + +# If you want to persist the fetch cache generated during the build so that +# cached responses are available immediately on startup, uncomment this line: +# COPY --from=builder --chown=node:node /app/.next/cache ./.next/cache + +# Switch to non-root user for security best practices +USER node + +# Expose port 3000 to allow HTTP traffic +EXPOSE 3000 + +# Start Next.js standalone server +CMD ["node", "server.js"] \ No newline at end of file diff --git a/Dockerfile.dev b/Dockerfile.dev new file mode 100644 index 00000000..415c4ec8 --- /dev/null +++ b/Dockerfile.dev @@ -0,0 +1,15 @@ +FROM node:20-alpine + +WORKDIR /app + +COPY package.json package-lock.json ./ +RUN npm install + +# Source files are mounted as a volume at runtime for hot reload + +EXPOSE 3000 + +ENV NODE_ENV=development +ENV NEXT_TELEMETRY_DISABLED=1 + +CMD ["npm", "run", "dev"] diff --git a/README.md b/README.md index 758feb20..3066aacd 100644 --- a/README.md +++ b/README.md @@ -35,24 +35,23 @@ Point it at a URL, run `/clone-website`, and your AI agent will inspect the site > Using a different agent? Open `AGENTS.md` for project instructions — most agents pick it up automatically. - ## Supported Platforms -| Agent | Status | -|-------|--------| +| Agent | Status | +| ------------------------------------------------------------- | -------------------------- | | [Claude Code](https://docs.anthropic.com/en/docs/claude-code) | **Recommended** — Opus 4.6 | -| [Codex CLI](https://github.com/openai/codex) | Supported | -| [OpenCode](https://opencode.ai/) | Supported | -| [GitHub Copilot](https://github.com/features/copilot) | Supported | -| [Cursor](https://cursor.com/) | Supported | -| [Windsurf](https://codeium.com/windsurf) | Supported | -| [Gemini CLI](https://github.com/google-gemini/gemini-cli) | Supported | -| [Cline](https://github.com/cline/cline) | Supported | -| [Roo Code](https://github.com/RooCodeInc/Roo-Code) | Supported | -| [Continue](https://continue.dev/) | Supported | -| [Amazon Q](https://aws.amazon.com/q/developer/) | Supported | -| [Augment Code](https://www.augmentcode.com/) | Supported | -| [Aider](https://aider.chat/) | Supported | +| [Codex CLI](https://github.com/openai/codex) | Supported | +| [OpenCode](https://opencode.ai/) | Supported | +| [GitHub Copilot](https://github.com/features/copilot) | Supported | +| [Cursor](https://cursor.com/) | Supported | +| [Windsurf](https://codeium.com/windsurf) | Supported | +| [Gemini CLI](https://github.com/google-gemini/gemini-cli) | Supported | +| [Cline](https://github.com/cline/cline) | Supported | +| [Roo Code](https://github.com/RooCodeInc/Roo-Code) | Supported | +| [Continue](https://continue.dev/) | Supported | +| [Amazon Q](https://aws.amazon.com/q/developer/) | Supported | +| [Augment Code](https://www.augmentcode.com/) | Supported | +| [Aider](https://aider.chat/) | Supported | ## Prerequisites @@ -114,14 +113,21 @@ npm run typecheck # TypeScript check npm run check # Run lint + typecheck + build ``` +### If using docker + +```bash +docker compose up add --build # build and run the app +docker compose up dev # run the app in dev mode +``` + ## Updating for Other Platforms Two source-of-truth files power all platform support. Edit the source, then run the sync script: -| What | Source of truth | Sync command | -|------|----------------|--------------| -| Project instructions | `AGENTS.md` | `bash scripts/sync-agent-rules.sh` | -| `/clone-website` skill | `.claude/skills/clone-website/SKILL.md` | `node scripts/sync-skills.mjs` | +| What | Source of truth | Sync command | +| ---------------------- | --------------------------------------- | ---------------------------------- | +| Project instructions | `AGENTS.md` | `bash scripts/sync-agent-rules.sh` | +| `/clone-website` skill | `.claude/skills/clone-website/SKILL.md` | `node scripts/sync-skills.mjs` | Each script regenerates the platform-specific copies automatically. Agents that read the source files natively need no regeneration. diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 00000000..dc00fef7 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,53 @@ +services: + app: + build: + context: . + dockerfile: Dockerfile + target: runner + image: ai-website-cloner:latest + container_name: ai-website-cloner + restart: unless-stopped + ports: + - "${PORT:-3000}:3000" + environment: + - NODE_ENV=production + - NEXT_TELEMETRY_DISABLED=1 + env_file: + - path: .env.local + required: false + - path: .env + required: false + healthcheck: + test: ["CMD-SHELL", "wget -qO- http://localhost:3000/ || exit 1"] + interval: 30s + timeout: 10s + retries: 3 + start_period: 10s + + dev: + build: + context: . + dockerfile: Dockerfile.dev + image: ai-website-cloner:dev + container_name: ai-website-cloner-dev + restart: unless-stopped + ports: + - "${DEV_PORT:-3000}:3000" + environment: + - NODE_ENV=development + - NEXT_TELEMETRY_DISABLED=1 + env_file: + - path: .env.local + required: false + - path: .env + required: false + volumes: + - .:/app + - /app/node_modules + - /app/.next + healthcheck: + test: ["CMD-SHELL", "wget -qO- http://localhost:3000/ || exit 1"] + interval: 30s + timeout: 10s + retries: 3 + start_period: 15s diff --git a/next.config.ts b/next.config.ts index e9ffa308..ed235781 100644 --- a/next.config.ts +++ b/next.config.ts @@ -2,6 +2,7 @@ import type { NextConfig } from "next"; const nextConfig: NextConfig = { /* config options here */ + output: "standalone", }; export default nextConfig; From f11f9315cbddd95d1ef0773930d77b6227f7dc22 Mon Sep 17 00:00:00 2001 From: JCodesMore Date: Sun, 29 Mar 2026 23:59:46 -0500 Subject: [PATCH 2/2] fix: align Docker follow-up with repo defaults Co-Authored-By: Oz --- Dockerfile | 6 +++--- README.md | 4 ++-- docker-compose.yml | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Dockerfile b/Dockerfile index 2e5a33a0..08be1729 100644 --- a/Dockerfile +++ b/Dockerfile @@ -5,9 +5,9 @@ # ============================================ # IMPORTANT: Node.js Version Maintenance -# This Dockerfile uses Node.js 24.13.0-slim, which was the latest LTS version at the time of writing. -# To ensure security and compatibility, regularly update the NODE_VERSION ARG to the latest LTS version. -ARG NODE_VERSION=24.13.0-slim +# This Dockerfile defaults to Node.js 20.20.2-slim to match the repo's Node 20 baseline used in CI and local development. +# To ensure security and compatibility, update the NODE_VERSION ARG when the project's Node baseline changes. +ARG NODE_VERSION=20.20.2-slim FROM node:${NODE_VERSION} AS dependencies diff --git a/README.md b/README.md index 3066aacd..451b1874 100644 --- a/README.md +++ b/README.md @@ -116,8 +116,8 @@ npm run check # Run lint + typecheck + build ### If using docker ```bash -docker compose up add --build # build and run the app -docker compose up dev # run the app in dev mode +docker compose up app --build # build and run the app +docker compose up dev --build # run the app in dev mode on port 3001 ``` ## Updating for Other Platforms diff --git a/docker-compose.yml b/docker-compose.yml index dc00fef7..39fc6f9c 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -32,7 +32,7 @@ services: container_name: ai-website-cloner-dev restart: unless-stopped ports: - - "${DEV_PORT:-3000}:3000" + - "${DEV_PORT:-3001}:3000" environment: - NODE_ENV=development - NEXT_TELEMETRY_DISABLED=1