@emseepea/create-multi-instance-postgres-server 0.0.10 → 0.0.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -75,9 +75,13 @@ with Control-C. Remove the database container and local volume when you no
75
75
  longer need them:
76
76
 
77
77
  ```sh
78
- docker compose down --volumes
78
+ npm run db:reset
79
79
  ```
80
80
 
81
+ `npm run db:reset` deletes the local PostgreSQL volume and its data. You cannot
82
+ undo this action. Docker Compose starts PostgreSQL for local development only.
83
+ It is not a production deployment recipe.
84
+
81
85
  ## Use Managed PostgreSQL
82
86
 
83
87
  Set `DATABASE_URL` to a PostgreSQL connection string that every deployed
@@ -94,6 +98,26 @@ Use a different port or deployment endpoint for each process. You may set
94
98
  enters the MCP tool contract. Protect `DATABASE_URL` as a secret. Do not put it
95
99
  in source control or send it to an MCP client.
96
100
 
101
+ ## Build a production container
102
+
103
+ Run `npm install` first so the project has a lockfile. Then run:
104
+
105
+ ```sh
106
+ npm run container:build
107
+ ```
108
+
109
+ The image runs one `dist/server.js` process. Run separate containers for
110
+ separate production instances and point them at the same managed PostgreSQL
111
+ database.
112
+
113
+ The image is for a production deployment behind a trusted proxy. It starts with
114
+ the fail-closed production profile and needs a runtime-mounted deployment
115
+ configuration file. Keep secrets in your platform's runtime secret store, not in
116
+ the Dockerfile, build arguments, or deployment configuration file.
117
+
118
+ For the production proxy, runtime configuration, and hardening requirements, see
119
+ the [container guide](https://emseepea.github.io/emseepea/examples/#build-a-production-container).
120
+
97
121
  ## Tools
98
122
 
99
123
  - `save-harvest-report` saves the complete report for one garden bed and
@@ -0,0 +1,17 @@
1
+ .env
2
+ .env.*
3
+ .git
4
+ .github
5
+ .npmrc
6
+ artifacts
7
+ coverage
8
+ dist
9
+ docs
10
+ eval
11
+ initializer-dist
12
+ node_modules
13
+ release-artifacts
14
+ test
15
+ test-support
16
+ *.log
17
+ *.tsbuildinfo
@@ -0,0 +1,19 @@
1
+ FROM docker.io/library/node:24.21.0-trixie-slim@sha256:db3ae80f5d8df06e04dabdf7b44cbf008d32de168205fa0294444aabbc08c590 AS build
2
+ WORKDIR /app
3
+ COPY . .
4
+ RUN test "$(node --version)" = "v24.21.0" \
5
+ && test -f package-lock.json \
6
+ && npm ci --ignore-scripts \
7
+ && npm run build \
8
+ && npm prune --omit=dev --ignore-scripts
9
+
10
+ FROM gcr.io/distroless/nodejs24-debian13:nonroot@sha256:7781e8b4fccf59240bd539af6738cccf8dad4be303165c3a1fa065c48699b937
11
+ WORKDIR /app
12
+ ENV EMSEEPEA_DEPLOYMENT_MODE=production-behind-proxy
13
+ COPY --from=build --chown=65532:65532 /app/package.json ./package.json
14
+ COPY --from=build --chown=65532:65532 /app/node_modules ./node_modules
15
+ COPY --from=build --chown=65532:65532 /app/dist ./dist
16
+ USER 65532:65532
17
+ EXPOSE 3000
18
+ HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 CMD ["/nodejs/bin/node", "-e", "const port=process.env.PORT||'3000';fetch(`http://127.0.0.1:${port}/healthz`).then((r)=>process.exit(r.ok?0:1),()=>process.exit(1));"]
19
+ CMD ["dist/server.js"]
@@ -48,9 +48,13 @@ with Control-C. Remove the database container and local volume when you no
48
48
  longer need them:
49
49
 
50
50
  ```sh
51
- docker compose down --volumes
51
+ npm run db:reset
52
52
  ```
53
53
 
54
+ `npm run db:reset` deletes the local PostgreSQL volume and its data. You cannot
55
+ undo this action. Docker Compose starts PostgreSQL for local development only.
56
+ It is not a production deployment recipe.
57
+
54
58
  ## Use Managed PostgreSQL
55
59
 
56
60
  Set `DATABASE_URL` to a PostgreSQL connection string that every deployed
@@ -67,6 +71,26 @@ Use a different port or deployment endpoint for each process. You may set
67
71
  enters the MCP tool contract. Protect `DATABASE_URL` as a secret. Do not put it
68
72
  in source control or send it to an MCP client.
69
73
 
74
+ ## Build a production container
75
+
76
+ Run `npm install` first so the project has a lockfile. Then run:
77
+
78
+ ```sh
79
+ npm run container:build
80
+ ```
81
+
82
+ The image runs one `dist/server.js` process. Run separate containers for
83
+ separate production instances and point them at the same managed PostgreSQL
84
+ database.
85
+
86
+ The image is for a production deployment behind a trusted proxy. It starts with
87
+ the fail-closed production profile and needs a runtime-mounted deployment
88
+ configuration file. Keep secrets in your platform's runtime secret store, not in
89
+ the Dockerfile, build arguments, or deployment configuration file.
90
+
91
+ For the production proxy, runtime configuration, and hardening requirements, see
92
+ the [container guide](https://emseepea.github.io/emseepea/examples/#build-a-production-container).
93
+
70
94
  ## Tools
71
95
 
72
96
  - `save-harvest-report` saves the complete report for one garden bed and
@@ -7,18 +7,21 @@
7
7
  "scripts": {
8
8
  "build": "tsc -p tsconfig.json",
9
9
  "start": "node dist/start-two.js",
10
- "dev": "docker compose up --detach --wait database && npm run build && npm run db:setup && npm start",
10
+ "dev": "npm run db:start && npm run build && npm run db:setup && npm start",
11
11
  "start:instance": "node dist/server.js",
12
+ "db:start": "docker compose up --detach --wait database",
13
+ "db:reset": "docker compose down --volumes",
12
14
  "db:setup": "node dist/setup-database.js",
13
15
  "test": "npm run build && npm run test:built",
14
16
  "test:built": "node test/with-postgres.mjs node --test test/*.test.mjs",
15
17
  "test:llm": "npm run build && npm run test:llm:built",
16
18
  "test:llm:built": "node test/with-postgres.mjs emseepea-test eval",
17
- "lint": "oxlint src test eval"
19
+ "lint": "oxlint src test eval",
20
+ "container:build": "docker build --tag emseepea-server:local ."
18
21
  },
19
22
  "devDependencies": {
20
- "@emseepea/feedback": "0.2.3",
21
- "@emseepea/testing": "0.9.6",
23
+ "@emseepea/feedback": "0.2.6",
24
+ "@emseepea/testing": "0.9.9",
22
25
  "@modelcontextprotocol/client": "2.0.0",
23
26
  "@types/node": "24.13.3",
24
27
  "@types/pg": "8.23.1",
@@ -30,7 +33,7 @@
30
33
  },
31
34
  "private": true,
32
35
  "dependencies": {
33
- "@emseepea/server": "0.8.1",
36
+ "@emseepea/server": "0.10.0",
34
37
  "pg": "8.23.0",
35
38
  "zod": "4.4.3"
36
39
  }
@@ -1,9 +1,9 @@
1
- import { serveEmseepea } from "@emseepea/server";
1
+ import { loadDeploymentProfile, serveEmseepea } from "@emseepea/server";
2
2
  import { createMultiInstanceExample } from "./app.js";
3
3
 
4
4
  const instanceName = process.env.EMSEEPEA_INSTANCE ?? `instance-${process.pid}`;
5
5
  const databaseUrl = process.env.DATABASE_URL ?? "postgres://emseepea:emseepea@127.0.0.1:5432/emseepea";
6
- const { app, closeProvider } = await createMultiInstanceExample({ databaseUrl });
6
+ const { app, closeProvider } = await createMultiInstanceExample({ databaseUrl, deployment: loadDeploymentProfile() });
7
7
  const running = await serveEmseepea(app, {
8
8
  port: Number.parseInt(process.env.PORT ?? "3000", 10),
9
9
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@emseepea/create-multi-instance-postgres-server",
3
- "version": "0.0.10",
3
+ "version": "0.0.13",
4
4
  "description": "Create interchangeable Em See Pea server instances sharing PostgreSQL state.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -10,8 +10,10 @@
10
10
  "build:example": "tsc -p tsconfig.json",
11
11
  "build:initializer": "node ../../scripts/build-initializer.mjs",
12
12
  "start": "node dist/start-two.js",
13
- "dev": "docker compose up --detach --wait database && npm run build && npm run db:setup && npm start",
13
+ "dev": "npm run db:start && npm run build && npm run db:setup && npm start",
14
14
  "start:instance": "node dist/server.js",
15
+ "db:start": "docker compose up --detach --wait database",
16
+ "db:reset": "docker compose down --volumes",
15
17
  "db:setup": "node dist/setup-database.js",
16
18
  "test": "npm run build && npm run test:built",
17
19
  "test:built": "node test/with-postgres.mjs node --test test/*.test.mjs",
@@ -21,11 +23,11 @@
21
23
  "prepack": "npm run build:initializer"
22
24
  },
23
25
  "devDependencies": {
24
- "@emseepea/feedback": "0.2.3",
25
- "@emseepea/server": "0.8.1",
26
+ "@emseepea/feedback": "0.2.6",
27
+ "@emseepea/server": "0.10.0",
26
28
  "pg": "8.23.0",
27
29
  "zod": "4.4.3",
28
- "@emseepea/testing": "0.9.6",
30
+ "@emseepea/testing": "0.9.9",
29
31
  "@modelcontextprotocol/client": "2.0.0",
30
32
  "@types/node": "24.13.3",
31
33
  "@types/pg": "8.23.1",