test(ci): add watch paths phase 4 fixture

This commit is contained in:
2026-11-17 05:00:23 +00:00
parent 0b0c0dabee
commit 70cdf742aa
12 changed files with 107 additions and 38 deletions

View File

@@ -1,5 +1,3 @@
*
!Dockerfile
!server.js
!public/
!public/**
node_modules
**/node_modules
.git

View File

@@ -1,36 +1,8 @@
# OpenAI Chat Demo
# Watch paths Phase 4 fixture
A small web chat service that sends questions to the OpenAI Responses API. The browser talks only to this app; `API_KEY` stays in the server container and is never sent to the browser.
Small two-service monorepo used to accept the per-service Gitea watch-path filtering flow.
## Configuration
- `web/` builds from repository root and uses `packages/shared`, root npm workspace manifests, and `healthcare-miniapp/package.json` as build inputs.
- `backend/` builds from its own directory and has no dependency on web files.
The container uses exactly two application environment variables:
| Variable | Purpose | Example |
| --- | --- | --- |
| `MODEL` | OpenAI model name to call | `gpt-4.1-mini` |
| `API_KEY` | OpenAI API key; configure this as a secret | Set it in the runtime secret manager |
The app listens on port `8080`.
## Run with Docker
Set the real key in your shell or secret manager, then run:
```sh
docker run --rm -p 8080:8080 \
-e MODEL=gpt-4.1-mini \
-e API_KEY \
lucnguyen666/aisp-openai-chat-demo:1.0.0
```
Open <http://localhost:8080>. For a platform deployment, map `MODEL` as a regular environment variable and `API_KEY` as a secret environment variable.
## Build locally
```sh
docker build -t aisp-openai-chat-demo:local .
docker run --rm -p 8080:8080 -e MODEL=gpt-4.1-mini -e API_KEY aisp-openai-chat-demo:local
```
The chat history is held in browser memory for the current page session. The server calls `POST https://api.openai.com/v1/responses` with `store: false`. It does not log prompts or API keys.
Both containers expose `/health` on port 8080. No external services or credentials are needed.

7
backend/Dockerfile Normal file
View File

@@ -0,0 +1,7 @@
FROM docker.io/library/node:22-alpine
WORKDIR /app
ENV NODE_ENV=production
COPY --chown=node:node server.js ./server.js
USER node
EXPOSE 8080
CMD ["node", "server.js"]

6
backend/server.js Normal file
View File

@@ -0,0 +1,6 @@
const http = require("node:http");
const server = http.createServer((request, response) => {
response.setHeader("Content-Type", "application/json");
response.writeHead(200).end(JSON.stringify({ status: "ok", service: "backend" }));
});
server.listen(8080, "0.0.0.0");

View File

@@ -0,0 +1 @@
{"name":"watch-paths-fixture-miniapp","version":"1.0.0","private":true}

42
package-lock.json generated Normal file
View File

@@ -0,0 +1,42 @@
{
"name": "watch-paths-phase4-fixture",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "watch-paths-phase4-fixture",
"workspaces": [
"web",
"packages/shared",
"healthcare-miniapp"
]
},
"healthcare-miniapp": {
"name": "watch-paths-fixture-miniapp",
"version": "1.0.0"
},
"node_modules/watch-paths-fixture-miniapp": {
"resolved": "healthcare-miniapp",
"link": true
},
"node_modules/watch-paths-fixture-shared": {
"resolved": "packages/shared",
"link": true
},
"node_modules/watch-paths-fixture-web": {
"resolved": "web",
"link": true
},
"packages/shared": {
"name": "watch-paths-fixture-shared",
"version": "1.0.0"
},
"web": {
"name": "watch-paths-fixture-web",
"version": "1.0.0",
"dependencies": {
"watch-paths-fixture-shared": "file:../packages/shared"
}
}
}
}

5
package.json Normal file
View File

@@ -0,0 +1,5 @@
{
"name": "watch-paths-phase4-fixture",
"private": true,
"workspaces": ["web", "packages/shared", "healthcare-miniapp"]
}

1
packages/shared/index.js Normal file
View File

@@ -0,0 +1 @@
module.exports = { fixtureName: "watch-paths-phase4" };

View File

@@ -0,0 +1 @@
{"name":"watch-paths-fixture-shared","version":"1.0.0","main":"index.js"}

14
web/Dockerfile Normal file
View File

@@ -0,0 +1,14 @@
FROM docker.io/library/node:22-alpine
WORKDIR /app
ENV NODE_ENV=production
COPY --chown=node:node package.json package-lock.json ./
COPY --chown=node:node packages/shared/package.json ./packages/shared/
COPY --chown=node:node healthcare-miniapp/package.json ./healthcare-miniapp/
COPY --chown=node:node web/package.json ./web/
RUN npm ci --omit=dev
COPY --chown=node:node packages/shared ./packages/shared
COPY --chown=node:node web ./web
WORKDIR /app/web
USER node
EXPOSE 8080
CMD ["npm", "start"]

11
web/package.json Normal file
View File

@@ -0,0 +1,11 @@
{
"name": "watch-paths-fixture-web",
"version": "1.0.0",
"private": true,
"scripts": {
"start": "node server.js"
},
"dependencies": {
"watch-paths-fixture-shared": "file:../packages/shared"
}
}

11
web/server.js Normal file
View File

@@ -0,0 +1,11 @@
const http = require("node:http");
const { fixtureName } = require("watch-paths-fixture-shared");
const server = http.createServer((request, response) => {
response.setHeader("Content-Type", "application/json");
if (request.url === "/health") {
response.writeHead(200).end(JSON.stringify({ status: "ok", service: "web", fixtureName }));
return;
}
response.writeHead(200).end(JSON.stringify({ service: "web", fixtureName }));
});
server.listen(8080, "0.0.0.0");