Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
37f8c5d
WIP Docker support
Houwie7000 Jan 5, 2025
88433e6
Docker dev deployment, works with nodemon.
Houwie7000 Jan 5, 2025
b33172f
DB health check + container order/dependencies changed
Houwie7000 Jan 5, 2025
4b1ab7b
Docker support finalized.
Houwie7000 Jan 6, 2025
64c0ebc
Docs updated
Houwie7000 Jan 6, 2025
d9ce74f
npm docker:test now prints results
Houwie7000 Jan 6, 2025
bbf622e
documentation fixes
Houwie7000 Jan 6, 2025
54f8e3b
disable Docker Deamon mode on dev and test config
Houwie7000 Jan 7, 2025
26a7231
version pinning
Houwie7000 Jan 7, 2025
09d8e68
Initial refactoring & streamlining of the dockerisation of ILG
isaachilly Jul 31, 2026
6ca723b
Slim the dockerfile, cache dependencies, drop prod stages, run as non…
isaachilly Aug 7, 2026
1e7f27e
Put database and simulator behind Compose profiles
isaachilly Aug 7, 2026
1ec209f
Write test scratch files to the OS temp dir
isaachilly Aug 7, 2026
5f539f1
Fix missing prod mention
isaachilly Aug 7, 2026
4adaa1e
Rewrite Docker docs in the README
isaachilly Aug 7, 2026
b0b3c14
Use a more secure temporary directory for test db files
isaachilly Aug 10, 2026
4539338
Make docker simulator improvements
isaachilly Aug 10, 2026
25da04b
Add profiles to docker cleanup cmd
isaachilly Aug 10, 2026
65da63d
Handle client cleanup on simulator shutdown
isaachilly Aug 10, 2026
66ac84b
Move Chromium into the test stage to slim the dev image
isaachilly Aug 11, 2026
ab0ac5b
Give the dev and test stacks separate Compose projects
isaachilly Aug 11, 2026
6d7c45b
Refactor dev Compose setup with DB seeder
isaachilly Aug 19, 2026
9524c89
Use service names in InfoLogger defaults
isaachilly Aug 19, 2026
bb9ef73
Fix small issues
isaachilly Aug 19, 2026
3965a3f
Fix dev DB seeder and relocate Docker assets
isaachilly Aug 20, 2026
9c3aeda
Clarify seeder logic
isaachilly Oct 5, 2026
a0c8553
Drop unused NODE_ENV from seeder, sim, test compose files
isaachilly Nov 20, 2026
6a580c3
Update environment variable configurations in Docker Compose for ease…
isaachilly Nov 23, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions InfoLogger/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Default ignore everything
*

# Project
!lib/
!package*.json
!public/
!index.js
!test/
!eslint.config.js
!config.js
!docker/
70 changes: 70 additions & 0 deletions InfoLogger/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
#
# ---- Base ----
FROM node:22-alpine AS base

RUN mkdir -p /home/node/app/node_modules && chown -R node:node /home/node/app

WORKDIR /home/node/app

#
# ---- Development Dependencies ----
FROM base AS developmentdependencies

# Must be set before `npm ci` otherwise Puppeteer will try to install Chrome. We'll be using the installed package.
ENV PUPPETEER_SKIP_DOWNLOAD=true

COPY package.json package-lock.json ./
# Installs modules from package-lock.json if there are changes, this ensures reproducible build
RUN npm --silent ci


#
# ---- Development ----
FROM developmentdependencies AS development

EXPOSE 8080

# Run the container as a non-root user 1000:1000, which is the default user in the node:22-alpine image
USER 1000:1000

CMD [ "npm", "run", "start:dev" ]

#
# ---- Seeder ----
# One-shot job, so the sources are copied in rather than bind-mounted
FROM developmentdependencies AS seeder

COPY docker/database/seed-messages.js ./docker/database/seed-messages.js
COPY test/fake-data ./test/fake-data
COPY test/utils ./test/utils

USER 1000:1000

CMD [ "npm", "run", "seed" ]

#
# ---- Test ----
FROM developmentdependencies AS test

RUN apk add --no-cache chromium
ENV PUPPETEER_EXECUTABLE_PATH=/usr/bin/chromium-browser

# Copy all files, except those ignored by .dockerignore
COPY . .

USER 1000:1000

CMD [ "npm", "run", "test" ]

#
# ---- Simul ----
FROM base AS simul

COPY test/live-simulator ./test/live-simulator
COPY test/fake-data ./test/fake-data
COPY test/utils ./test/utils
EXPOSE 6102

USER 1000:1000

CMD [ "node", "test/live-simulator/runInfoLoggerServer.js" ]
109 changes: 58 additions & 51 deletions InfoLogger/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
- [Interface User Guide](#interface-user-guide)
- [Requirements](#requirements)
- [Project Layout](#project-layout)
- [Scripts](#scripts)
- [Docker development](#docker-development)
- [Backend](#backend)
- [Frontend](#frontend)
- [Local Development](#local-development)
Expand Down Expand Up @@ -55,12 +57,41 @@ Screenshot of the current interface, running locally against a fake InfoLoggerSe
## Requirements

- `nodejs` >= `22.x`
- Docker/Docker Compose
- InfoLogger MariaDB database for Query mode
- InfoLoggerServer endpoint for Live mode

## Project Layout

ILG is a Node.js API Gateway and Single-Page Application built on top of the `@aliceo2/web-ui` framework. It serves as a unified interface to two separate operational backends: a **MariaDB database** for historical queries and an **InfoLoggerServer TCP endpoint** for live log streaming.
## Scripts
| Script | Description |
| --- | --- |
| `npm start` | Run the app (`node index.js`). |
| `npm run lint` | Lint the project with ESLint. |
| `npm run lint:fix` | Lint and automatically fix fixable problems. |
| `npm test` | Run the linter, then the Mocha test suite. |
| `npm run coverage` | Run the test suite under `nyc` and generate the coverage report. |
| `npm run coverage:report` | Generate HTML + JSON coverage reports under `coverage/` from the last run. |

Docker commands (`docker:dev`, `docker:dev:local-ilg`, `docker:dev:local-db`, `docker:dev:local-both`, `docker:test` and `docker:cleanup`) are documented under [Docker development](#docker-development).

### Docker development

The development image is approx. 500MB and the test image is approx 1.5GB, about 50% of that is due to puppeteer's chromium requirement.

`database` and `simulator` each live in their own Compose override file, so they only start when you ask for them. Rather than stacking `-f` flags by hand, use one of:

| Script | Compose files (on top of `docker-compose.yaml`) | Application | Database | Simulator |
| --- | --- | --- | --- | --- |
| `npm run docker:dev` | `dev` | ✅ | ❌ | ❌ |
| `npm run docker:dev:local-ilg` | `dev` + `dev.ilg` | ✅ | ❌ | ✅ |
| `npm run docker:dev:local-db` | `dev` + `dev.db` | ✅ | ✅ | ❌ |
| `npm run docker:dev:local-both` | `dev` + `dev.db` + `dev.ilg` | ✅ | ✅ | ✅ |

For services with a cross, point `config.js` at a remote host and port and change the credentials accordingly. For services with a checkmark, the script will start a local container for you.

Run `npm run docker:cleanup` to remove all containers created by the above and their data.

## Backend

Expand All @@ -71,6 +102,18 @@ ILG is a Node.js API Gateway and Single-Page Application built on top of the `@a
- **Profiles** - [ProfileService](lib/ProfileService.js) persists per-user column visibility/width to a JSON file ([JSONFileConnector](lib/JSONFileConnector.js)) via `getUserProfile` / `saveUserProfile`. The named-profile endpoint (`getProfile`) is a stub - it returns the hard-coded defaults regardless of the profile requested.
- **Utilities** - [utils/](lib/utils/) contains the InfoLogger message-command parser, SQL to native error mapping, prepared-statement parsing, and query cancellation.

## Docker development

The development, test and simul docker image will take up about 1.35 GB, about 50% of that is due to puppeteer's chromium requirement, the same reason why Electron apps are so big.

Should you want to run the ILG with the status quo (your changes applied) you can use the following commands:

1. npm run docker:dev (will run the ILG with Nodemon, a development database, the ILG simulator and phpMyAdmin).
2. npm run docker:test (will run the ILG npm run test command inside a Docker container and print the live log output).
3. npm run docker:simul (will run an ILG simulator with the port open so that whenever you run the ILG it will have live mode available).
4. npm run docker:cleanup (REMOVES all containers created with the above commands and their data).


## Frontend

Static files served from [public/](public/); no build step. A lightweight MVC app on top of `@aliceo2/web-ui`.
Expand All @@ -93,72 +136,36 @@ cp config-default.js config.js

Edit `config.js` for the setup you're using below.

`npm run dev` runs the backend under nodemon. The frontend has no hot reload - refresh the browser to pick up changes.

### Query & Live mode Against a remote backend (e.g. a staging instance)

1. Point `mysql` and `infoLoggerServer` in `config.js` at the remote host and port.
2. `npm start`, then open [http://localhost:8080](http://localhost:8080).
1. Point `mysql` and `infoLoggerServer` in `config.js` at a remote host and port. Ask your team for the correct values if you don't have them.
2. `npm run docker:dev`, then open [http://localhost:8080](http://localhost:8080).

### Live mode against synthetic logs (thoroughly test Live mode)

The bundled [fake InfoLoggerServer](test/live-simulator/) emits a log every 0-100 ms, shuffling through [test/live-simulator/fakeData.json](test/live-simulator/fakeData.json).
The bundled [fake InfoLoggerServer](test/live-simulator/) emits a log every 0-100 ms, shuffling through [test/fake-data/fakeData.json](test/fake-data/fakeData.json).

1. Set `infoLoggerServer` in `config.js` to `localhost:6102`.
2. Terminal 1: `npm run simul`.
3. Terminal 2: `npm run dev`.
4. Open [http://localhost:8080](http://localhost:8080) and click **Live**.
1. `npm run docker:dev:local-ilg` (sets `INFOLOGGER_HOST=simulator` for the application).
2. Open [http://localhost:8080](http://localhost:8080) and click **Live**.

### Query against a local DB

Requires [Docker Desktop](https://www.docker.com/products/docker-desktop/).

1. In a working dir, create `compose.yaml`:

```yaml
services:
mariadb:
image: mariadb
restart: unless-stopped
ports: ['3306:3306']
environment:
MARIADB_ROOT_PASSWORD: root # this is just an example, not intended to be a production configuration
phpmyadmin:
image: phpmyadmin
restart: unless-stopped
ports: ['9090:80']
environment:
- PMA_HOST=mariadb
```

Gives you a MariaDB server with phpMyAdmin on the latest image. Pin a specific version (e.g. `mariadb:11.5`) by changing the `image:` tag.

2. `docker compose up -d`.
3. Open [http://localhost:9090/](http://localhost:9090/) → log in `root` / `root` → **New** → create database `INFOLOGGER`.
4. Open the **SQL** tab, paste [docs/database-specs.sql](docs/database-specs.sql), click **Go**.
5. In `config.js`:

```js
mysql: {
host: '127.0.0.1',
user: 'root',
password: 'root',
database: 'INFOLOGGER',
port: 3306,
timeout: 60000,
retryMs: 5000,
},
```

6. `npm run dev` - startup should log `Connection to DB successfully established: 127.0.0.1:3306`.
1. `npm run docker:dev:local-db` (sets `MYSQL_HOST=database` for the application).
2. Open [http://localhost:8080](http://localhost:8080) and click **Query**.

The schema in [test/db/INFOLOGGER.sql](test/db/INFOLOGGER.sql) is applied once, when the database volume is
first created. The `seeder` service then runs [test/db/seed-messages.js](test/db/seed-messages.js) on **every**
`up`: it inserts a batch of messages if the table is empty, or re-dates the existing messages to keep them within the N many days specified in `seed-messages.js`. The seeder is idempotent, so you can run `docker compose up` repeatedly without accumulating duplicate messages. You only need to run 'npm run docker:cleanup' to remove the database volume if you have made changes to the schema or the seeder.

Need both at once? `npm run docker:dev:local-both` starts the simulator and the local DB together.

## Testing

- `npm test` - eslint + mocha. `npm run mocha` runs the suite alone.
- `npm run docker:test` - eslint + mocha.
- Backend tests: [test/lib/](test/lib).
- Frontend tests: [test/public/](test/public).
- Add or update the matching test when fixing a bug.
- `npm run eslint` - config in [eslint.config.js](eslint.config.js). Lint failures block CI.
- Lint failures block CI.

### Integration tests (live elsewhere)

Expand Down
4 changes: 2 additions & 2 deletions InfoLogger/config-default.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ module.exports = {
// optional data source, comment object if not used
// all options: https://github.com/mysqljs/mysql#connection-options
mysql: {
host: '127.0.0.1',
host: process.env.MYSQL_HOST ?? '127.0.0.1',
user: 'root',
password: 'root',
database: 'INFOLOGGER',
Expand All @@ -40,7 +40,7 @@ module.exports = {
// optional data source, comment object if not used
// all options: https://nodejs.org/api/net.html#net_socket_connect_options_connectlistener
infoLoggerServer: {
host: 'localhost',
host: process.env.INFOLOGGER_HOST ?? 'localhost',
port: 6102,
},
logging: {
Expand Down
63 changes: 63 additions & 0 deletions InfoLogger/docker-compose.dev.db.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# Local MariaDB to query, plus a one-shot seeder.
services:
application:
environment:
MYSQL_HOST: database
depends_on:
database:
condition: service_healthy
seeder:
condition: service_completed_successfully

database:
image: mariadb:10.5

# Fail the stack
restart: "no"

environment:
MYSQL_ROOT_PASSWORD: root
MYSQL_DATABASE: INFOLOGGER

# should you want to access the DB using a external program
ports:
- "3306:3306"

# The schema is applied once, when the data volume is first created.
# A directory mount, not a single file so can have multiple scripts.
volumes:
- type: bind
read_only: true
source: ./docker/database/initdb.d
target: /docker-entrypoint-initdb.d
- type: volume
source: database-data
target: /var/lib/mysql

healthcheck:
test: ["CMD", "healthcheck.sh", "--connect", "--innodb_initialized"]
interval: 5s
timeout: 20s
retries: 20

# One-shot job: re-seeds the messages table on every `up`, so the fake logs are
# always dated within the last day and a `-1d`/`-2d` filter shows them straight away.
seeder:
build:
target: seeder

restart: "no"

depends_on:
database:
condition: service_healthy

environment:
MYSQL_HOST: database
MYSQL_PORT: 3306
MYSQL_USER: root
MYSQL_PASSWORD: root
MYSQL_DATABASE: INFOLOGGER

volumes:
database-data:
18 changes: 18 additions & 0 deletions InfoLogger/docker-compose.dev.ilg.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Local InfoLogger server simulator, streaming fake logs on port 6102.
services:
application:
environment:
INFOLOGGER_HOST: simulator
# Ordering only, no healthcheck: InfoLoggerReceiver retries the connection every 5s
depends_on:
- simulator

simulator:
build:
target: simul

# Fail the stack
restart: "no"

ports:
- "6102:6102"
31 changes: 31 additions & 0 deletions InfoLogger/docker-compose.dev.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: infologger-dev
services:
application:
build:
target: development

restart: "no"

environment:
NODE_ENV: development

ports:
- "8080:8080"

volumes:
- type: bind
read_only: true
source: ./lib
target: /home/node/app/lib
- type: bind
read_only: true
source: ./public
target: /home/node/app/public
- type: bind
read_only: true
source: ./config.js
target: /home/node/app/config.js
- type: bind
read_only: true
source: ./index.js
target: /home/node/app/index.js
7 changes: 7 additions & 0 deletions InfoLogger/docker-compose.test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
name: infologger-test
services:
application:
build:
target: test

restart: "no"
5 changes: 5 additions & 0 deletions InfoLogger/docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
services:
application:
build:
context: .
dockerfile: Dockerfile
Loading