This folder lets you develop cnpmcore in a fully provisioned container, either in GitHub Codespaces (in the browser or VS Code) or locally with the Dev Containers extension. It bundles the external services cnpmcore needs (MySQL + Redis) and initializes the development database automatically.
- On GitHub, click Code -> Codespaces -> Create codespace on master.
- Wait for the container to build and
post-create.shto finish (installs deps and creates thecnpmcoredatabase). - Start the registry:
CNPMCORE_DATABASE_NAME=cnpmcore npm run dev
- Open the forwarded port 7001 to reach the registry.
- Install Docker and the Dev Containers extension.
- Open the repo and run Dev Containers: Reopen in Container.
- Same as steps 3-4 above.
| Service | Image | Purpose |
|---|---|---|
app |
Dockerfile |
Node.js 22 workspace + db client CLIs |
mysql |
mysql:9 |
Default development/test database |
redis |
redis:6-alpine |
Cache + distributed lock (dev only) |
The app container is preconfigured (via docker-compose.yml environment:) to reach
MySQL at host mysql and Redis at host redis, so the connection settings already point
at the right places.
The test suite uses
ioredis-mockand an Elasticsearch mock, so Redis/ES are only needed fornpm run dev, not fornpm run test.
# Start the dev registry (MySQL)
CNPMCORE_DATABASE_NAME=cnpmcore npm run dev
# Run the full test suite (creates its own cnpmcore_unittest_* databases)
npm run test
# Run a single test file (fast)
npm run test:local test/path/to/file.test.ts
# Lint / format / type-check in one pass
npx vp check
npm run devneedsCNPMCORE_DATABASE_NAME=cnpmcorebecause the dev database name is intentionally not set globally (that keeps the test suite'scnpmcore_unittest_*databases separate from your dev data).
- In
docker-compose.yml, uncomment thepostgresservice and thecnpm-postgresvolume. - On the
appservice, set:and changeCNPMCORE_DATABASE_TYPE: PostgreSQL CNPMCORE_DATABASE_HOST: postgres CNPMCORE_DATABASE_PORT: '5432' CNPMCORE_DATABASE_USER: postgres CNPMCORE_DATABASE_PASSWORD: postgres
depends_onfrommysqltopostgres. - Rebuild the container (Dev Containers: Rebuild Container).
- Run with
npm run dev:postgresql/npm run test:postgresql.
The app image already includes the postgresql-client, so post-create.sh will pick
up CNPMCORE_DATABASE_TYPE=PostgreSQL and initialize the PostgreSQL database instead.