Skip to content

Commit

Permalink
Merge branch 'main' into feat/FORMS-1671-chefs-nats
Browse files Browse the repository at this point in the history
  • Loading branch information
usingtechnology authored Jan 9, 2025
2 parents 66e543c + 678e5e6 commit 8db6c1c
Show file tree
Hide file tree
Showing 8 changed files with 84 additions and 273 deletions.
6 changes: 3 additions & 3 deletions .devcontainer/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ There are limitations running this devcontainer, such as all networking is withi

The `.devcontainer` folder contains the `devcontainer.json` file which defines this container. We are using a `Dockerfile` and `post-install.sh` to build and configure the container run image. The `Dockerfile` is simple but in place for simplifying image enhancements. The `post-install.sh` will install the required node libraries for CHEFS including the frontend and formio components.

In order to run CHEFS you require Postgresql (seeded) and the CHEFS backend/API and frontend/UX. Previously, this was a series of downloads and configuration updates and numerous commands to run. See `.devcontainer/chefs_local` files.
In order to run CHEFS you require Postgresql (seeded) and the CHEFS backend/API and frontend/UX - optionally you will use a [NATS](https://nats.io/) server for event streaming. Previously, this was a series of downloads and configuration updates and numerous commands to run. See `.devcontainer/chefs_local` files.

**NODE_CONFIG_DIR** to simplify loading a default configuration to the CHEFS infrastructure (Postgresql, etc), we set an environment variable [`NODE_CONFIG_DIR`](https://github.com/node-config/node-config/wiki/Environment-Variables#node_config_dir). This supercedes the files found under `app/config`. Running node apps and commands (ex. knex, launch configurations) will use this environment variable and load configuration from `.devcontainer/chefs_local`.

Expand Down Expand Up @@ -44,15 +44,15 @@ When the devcontainer is built, it copies `.devcontainer/chefs_local/local.sampl

### Run/Debug

1. start Postgresql. Many ways to start...
1. start Postgresql and NATS. Many ways to start...
- right click on `.devcontainer/chefs_local/docker-compose.yml` and select `Compose up`
- or use command palette `Docker: Compose Up` then select `.devcontainer/chefs_local/docker-compose.yml`
- or `Terminal | Run Task...|chefs_local up`
2. start CHEFS
- Run and Debug, select 'CHEFS' which will start both the API and the frontend.
3. debug Frontend with Chrome
- Run and Debug, select 'CHEFS Frontend - chrome' which will start a Chrome browser against the frontend, will allow breakpoints in `/app/frontend/src`
4. stop Postgresql. Many ways to stop...
4. stop Postgresql and NATS. Many ways to stop...
- right click on `.devcontainer/chefs_local/docker-compose.yml` and select `Compose down`
- or use command palette `Docker: Compose Down` then select `.devcontainer/chefs_local/docker-compose.yml`
- or `Terminal | Run Task...|chefs_local down`
Expand Down
File renamed without changes.
64 changes: 64 additions & 0 deletions .devcontainer/chefs_local/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,22 @@
volumes:
postgres_kc_data:
driver: local
n1-data:
driver: local
n2-data:
driver: local
n3-data:
driver: local

networks:
nats:
driver: bridge
ipam:
driver: default
config:
- subnet: "192.168.0.0/24"
gateway: "192.168.0.1"

services:
postgres:
image: postgres:14.2
Expand All @@ -13,3 +29,51 @@ services:
- POSTGRES_USER=app
- POSTGRES_PASSWORD=admin
- POSTGRES_DB=chefs

n1:
container_name: n1
image: nats:2.10.12
entrypoint: /nats-server
command: "--config /config/jetstream.conf --server_name S1"
networks:
- nats
ports:
- 4222:4222
volumes:
- ./config:/config
- n1-data:/data/nats-server/jetstream

n2:
container_name: n2
image: nats:2.10.12
entrypoint: /nats-server
command: "--config /config/jetstream.conf --server_name S2"
networks:
- nats
ports:
- 4223:4222
volumes:
- ./config:/config
- n2-data:/data/nats-server/jetstream

n3:
container_name: n3
image: nats:2.10.12
entrypoint: /nats-server
command: "--config /config/jetstream.conf --server_name S3"
networks:
- nats
ports:
- 4224:4222
volumes:
- ./config:/config
- n3-data:/data/nats-server/jetstream

natsbox:
container_name: natsbox
image: natsio/nats-box:latest
tty: true
stdin_open: true
command: sh
networks:
- nats
5 changes: 4 additions & 1 deletion .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,10 @@
5173, // CHEFS Frontend
5432, // PostgreSQL
8080, // CHEFS Backend
8081
8081,
4222, //nats
4223, //nats
4224 // nats
],

// Use 'postCreateCommand' to run commands after the container is created.
Expand Down
4 changes: 2 additions & 2 deletions .vscode/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ Tasks can be run from the `Terminal` > `Run Task...` menu item. The `tasks.json`
- `Unit Tests - Frontend`: run the unit tests for the Frontend
- `Components Build`: build the formio components
- `Components Deploy`: deploy the formio components. Build and deploy before serving the frontend will save lots of time.
- `chefs_local up`: when inside the devcontainer, will bring up postgresql for local CHEFS deployment.
- `chefs_local down`: when inside the devcontainer, will tear down running postgresql for local CHEFS deployment.
- `chefs_local up`: when inside the devcontainer, will bring up postgresql and nats for local CHEFS deployment.
- `chefs_local down`: when inside the devcontainer, will tear down running postgresql and nats for local CHEFS deployment.

Tip: You can run the builtin `All Tests` task to run both of the unit tests at the same time. This is possible since they're both configured to be in the `test` group.

Expand Down
201 changes: 0 additions & 201 deletions app/frontend/LICENSE

This file was deleted.

12 changes: 11 additions & 1 deletion event-stream-service/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,21 @@

To use `natsbox` in the devcontainer:

In one terminal (project root):

- run `docker compose -f .devcontainer/chefs_local/docker-compose.yml up`

Start natsbox and login

- terminal into `natsbox`
- run `nats context add nats --server nats://n1:4222 --description "N1" --select`.
- Under Docker tab, right click natsio/nats-box:latest and "Attach Shell"
- run `nats context add admin --server nats://n1:4222 --description "admin" --user=admin --password=password --select`.

This will allow you to run `nats` command line commands against the local nats server.

Get information about the `CHEFS` stream:

- run `nats stream info CHEFS`
- run `nats s report`

- run `exit` to leave shell
Loading

0 comments on commit 8db6c1c

Please sign in to comment.