NMS is the frontend code for SD-Core's Webconsole
.
It is based on the Next.js
React framework. In order to produce the final
binary that will be used to serve the frontend for SD-Core, we statically export the project in this repository, embed it in the Webconsole
application, and build the project together. The final webserver
binary is the output of Webconsole
's build command.
Since we only rely on the static export, this means that running the common npm run dev
script may produce unusual behaviour that doesn't exist in a deployed build. It also means that the project does not use any of Nextjs's server based features which can be found here.
We use a makefile to build and deploy the project. It has targets that will help with development. You can read more about what the makefile does in the Build
section below.
This target will produce the webconsole binary with the static export of NMS embedded as its frontend.
go
and nodejs
must be installed to use this option.
This target will produce a sdcore-nms.rock
OCI image file, which will have the webconsole binary as a service. It will use the master branch of webconsole by default.
If you want to use a specific tag for the webconsole repo, you must switch to the branch/tag in ./biuld/webconsole-src
rockcraft
must be installed to use this option.
This target will create an LXC VM called nms
, install docker, deploy the NMS
and MongoDB
OCI image, create a valid config file for NMS
, and start the program.
After the process is done, from your host machine you can run lxc list
, and use the IP address to connect to both mongodb and NMS. The port for NMS is :5000
and the port for mongodb is :27017
.
make rock
must have successfully completed and lxd
must be installed to use this option.
This target will take the webconsole binary, place it in the nms
container inside the LXC VM, and restart the pebble service. This is useful for quickly updating the locally deployed NMS program.
make deploy
must have successfully completed to use this option.
This target will print the last 20 log entries that was produced by the rock, which is the combination of pebble and webconsole logs.
make deploy
must have successfully completed to use this option.
This target will delete the rock, the binary, and destroy the VM.
This project uses ESLint and Prettier for linting and code formatting.
💡 We recommend using the Prettier extension for VSCode for easy on-save code formatting.
To run lint check:
npm run lint
There are 2 targets for building: the webconsole
binary and the sdcore-nms.rock
OCI image. The artifacts
for them are stored in the /artifacts
folder. Any files used in the build process are stored in the /build
folder.
go
and nodejs
is required to build webconsole.
The make webconsole
target is responsible for producing the binary that serves the NMS frontend. Once run, it will:
- Clone the
omec-project/webconsole
repository intobuild/webconsole-src
- Install the frontend dependencies by running
npm install
- Generate the static frontend files by running
npm run build
- Move the frontend files into
build/webconsole-src/ui/frontend_files
- Build the webconsole binary by running
go build --tags ui -o webconsole ./server.go
The binary will need to be run with a config file. An example is available in the examples/config
folder.
rockcraft
is required to create the OCI image.
The rock can be built with rockcraft pack
. This process will use the local NMS and a predefined tag of webconsole repo to create an OCI image. The webconsole branch/tag is defined in the rockcraft.yaml
file.
The make rock
target modifies this build process by directly using the build/webconsole-src
directory. This allows you to use a local version of webconsole in the OCI image instead of having to pull from the specified tag in rockcraft.yaml
. This is useful if you want to test changes to the backend rather than the frontend. The process is:
- Modify the
rockcraft.yaml
to usebuild/webconsole-src
- Run
rockcraft pack
- Restore the original
rockcraft.yaml
The binary requires a config file and an available mongodb deployment to operate. By default, the path for the config file is ./config/webuicfg.yaml
from the directory of the binary. The OCI image does not come with a config file preconfigured, but the repo contains an example at examples/config/webuicfg.yaml
.
make deploy
takes care of quickly getting a running program. It will:
- Create a VM in LXD called
nms
- Install docker and skopeo in the VM
- Load the
sdcore-nms.rock
OCI image and pull themongodb:noble
image into the local registry. - Run both images in docker
- Load the example config located in
examples/config/webuicfg.yaml
into thenms
docker image, and restart the program.