diff --git a/.nvmrc b/.nvmrc new file mode 100644 index 0000000..2bd5a0a --- /dev/null +++ b/.nvmrc @@ -0,0 +1 @@ +22 diff --git a/AGENTS.md b/AGENTS.md index 777dd90..c800c47 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -23,8 +23,10 @@ Update `docs/links.md` to add or modify community resources. ## Build and Verification -- Always verify changes locally using `npm run docs:dev`. -- Run `npm run docs:build` to ensure the production build is successful. +- Use Docker for all development — do not run `npm install` directly. +- Dev server with live reload: `docker compose up dev` (available at `http://localhost:5173`). +- Production build: `docker compose up --build community` (available at `http://localhost:4174`). +- Update packages inside the container: `docker run --rm -v "$(pwd):/app" -w /app node:22 npm install `, then commit `package.json` and `package-lock.json`. - When modifying the UI, perform visual verification (e.g., using Playwright) to ensure style parity with `mume.org` is maintained. ## Deployment diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..b64a232 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,23 @@ +FROM node:22-alpine AS builder + +RUN apk upgrade --no-cache + +WORKDIR /app + +COPY package.json package-lock.json ./ +RUN npm ci + +COPY . . + +ARG VITE_BASE=/ +ENV VITE_BASE=${VITE_BASE} + +RUN npm run build + +FROM nginx:alpine + +RUN apk upgrade --no-cache + +COPY --from=builder /app/dist /usr/share/nginx/html + +EXPOSE 80 diff --git a/README.md b/README.md index 3e37cba..a880793 100644 --- a/README.md +++ b/README.md @@ -13,29 +13,39 @@ The site is built with **VitePress** and designed to match the style and layout ## Development -### Prerequisites +> **Use Docker.** All development should be done via Docker to keep the environment consistent with CI. -- [Node.js](https://nodejs.org/) (Latest LTS recommended) -- [npm](https://www.npmjs.com/) - -### Setup +### Dev server (live reload) ```bash -# Install dependencies -npm install +docker compose up dev +``` + +The site will be available at [http://localhost:5173](http://localhost:5173). -# Start development server -npm run docs:dev +### Production build + +```bash +docker compose up --build community ``` -### Build +The site will be available at [http://localhost:4174](http://localhost:4174). + +To pass a custom base path: ```bash -# Build for production -npm run docs:build +docker compose build --build-arg VITE_BASE=/community/ community +docker compose up community +``` + +### Updating dependencies -# Preview production build locally -npm run docs:preview +Always update packages inside the container so the lock file stays CI-compatible: + +```bash +docker run --rm -v "$(pwd):/app" -w /app node:22 npm install +git add package.json package-lock.json +git commit -m "chore: update dependencies" ``` ## Deployment diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..4c8fe9a --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,20 @@ +services: + # Development server with live reload + dev: + image: node:22-alpine + working_dir: /app + volumes: + - .:/app + - /app/node_modules + command: sh -c "npm ci && npm run dev -- --host" + ports: + - "5173:5173" + + # Production build served via nginx (mirrors deployment) + community: + build: + context: . + args: + VITE_BASE: / + ports: + - "4174:80" diff --git a/docs/.vitepress/theme/Layout.vue b/docs/.vitepress/theme/Layout.vue index 4740e16..3fea18b 100644 --- a/docs/.vitepress/theme/Layout.vue +++ b/docs/.vitepress/theme/Layout.vue @@ -1,7 +1,8 @@