chore(docker): compose, entrypoint guard, LF shell script; format with Prettier

- Add docker-compose.yml (build context .) and .gitattributes for entrypoint LF
- README: document docker compose and gregWiki root requirement
- package.json: include docker-compose.yml in npm run format

Made-with: Cursor
This commit is contained in:
Marvin
2026-04-10 00:05:51 +02:00
parent 1d4676f52b
commit 31cd24b462
6 changed files with 31 additions and 14 deletions

1
.gitattributes vendored Normal file
View File

@@ -0,0 +1 @@
docker-entrypoint.sh text eol=lf

View File

@@ -1,10 +1,15 @@
# Build context: this repository root (gregWiki).
# Runs the Docusaurus dev server with hot reload.
# Build context MUST be this repository root (directory containing package.json).
# Correct: docker build -t gregwiki .
# Wrong: docker build -f gregWiki/Dockerfile .. → COPY fails or image has no package.json
# Dev server with hot reload. For production static files use: npm run build + any static host.
FROM node:20-alpine
WORKDIR /app
ENV NODE_OPTIONS="--max-old-space-size=4096"
COPY docker-entrypoint.sh /usr/local/bin/docker-entrypoint.sh
RUN chmod +x /usr/local/bin/docker-entrypoint.sh
COPY package.json package-lock.json ./
RUN npm ci --ignore-scripts
COPY . .
EXPOSE 3000
ENTRYPOINT ["docker-entrypoint.sh"]
CMD ["npm", "run", "start", "--", "--host", "0.0.0.0", "--port", "3000"]

View File

@@ -24,9 +24,11 @@ Optional: refresh the legacy GitHub Wiki mirror from a sibling `../.wiki/` clone
## Docker
Build context is this repository root:
Build context **must** be this repository root (the folder that contains `package.json`):
```bash
docker compose up --build
# or
docker build -t gregwiki-docs .
docker run --rm -p 3000:3000 gregwiki-docs
```

11
docker-compose.yml Normal file
View File

@@ -0,0 +1,11 @@
# Run from this directory (gregWiki repo root): docker compose up --build
# Wrong context (e.g. monorepo parent) causes: ENOENT /app/package.json
services:
wiki:
build:
context: .
dockerfile: Dockerfile
ports:
- '3000:3000'
environment:
CHOKIDAR_USEPOLLING: 'true'

View File

@@ -1,14 +1,12 @@
#!/bin/sh
set -e
# Prefer wiki subfolder when the repo root is mounted at /app (root also has package.json).
# Otherwise use /app when only ./wiki is bound there (compose: ./wiki:/app).
if [ -f /app/wiki/package.json ]; then
cd /app/wiki
elif [ -f /app/package.json ]; then
cd /app
else
echo "docker-entrypoint: no package.json under /app or /app/wiki." >&2
echo "Run docker compose from the repository root so ./wiki is mounted, then: docker compose build --no-cache docs" >&2
if [ ! -f /app/package.json ]; then
echo "docker-entrypoint: ERROR: /app/package.json not found." >&2
echo " Build context must be the gregWiki repo root (the folder that contains package.json)." >&2
echo " Example: cd path/to/gregWiki && docker build -t gregwiki ." >&2
echo " Not: docker build -f gregWiki/Dockerfile .. (wrong context)" >&2
echo " Compose: run from gregWiki so build.context is '.' — see docker-compose.yml." >&2
echo " If you use a volume on /app, it must map to that repo root, not an empty dir." >&2
exit 1
fi
exec "$@"

View File

@@ -11,8 +11,8 @@
"wiki:sync": "node ./scripts/sync-wiki-to-docs.mjs",
"wiki:normalize-i18n": "node ./scripts/normalize-wiki-import-i18n.mjs",
"wiki:refresh": "node ./scripts/sync-wiki-to-docs.mjs && node ./scripts/normalize-wiki-import-i18n.mjs",
"format": "prettier --write src scripts docusaurus.config.js sidebars.js README.md docs/README.md package.json .prettierrc.json",
"format:check": "prettier --check src scripts docusaurus.config.js sidebars.js README.md docs/README.md package.json .prettierrc.json"
"format": "prettier --write src scripts docusaurus.config.js sidebars.js README.md docs/README.md package.json .prettierrc.json docker-compose.yml",
"format:check": "prettier --check src scripts docusaurus.config.js sidebars.js README.md docs/README.md package.json .prettierrc.json docker-compose.yml"
},
"dependencies": {
"@docusaurus/core": "3.9.2",