A TypeScript API for provisioning evault instances on Nomad. This service allows you to spin up evault instances with Neo4j backends for different tenants.
- Node.js 18+
- Docker
- Nomad (see setup instructions below)
- OrbStack (for macOS users)
Due to CNI bridge plugin requirements, running Nomad on macOS is best done through OrbStack:
- Install OrbStack: https://orbstack.dev/
- Create a new VM in OrbStack
- SSH into the VM and install Nomad:
# Install Nomad
curl -fsSL https://apt.releases.hashicorp.com/gpg | sudo apt-key add -
sudo apt-add-repository "deb [arch=amd64] https://apt.releases.hashicorp.com $(lsb_release -cs) main"
sudo apt-get update && sudo apt-get install nomad
# Install CNI plugins
sudo mkdir -p /opt/cni/bin
curl -L https://github.com/containernetworking/plugins/releases/download/v1.3.0/cni-plugins-linux-amd64-v1.3.0.tgz | sudo tar -C /opt/cni/bin -xz- Start Nomad in dev mode:
sudo nomad agent -dev -network-interface=eth0 -log-level=DEBUG -bind=0.0.0.0- Install Nomad:
# Install Nomad
curl -fsSL https://apt.releases.hashicorp.com/gpg | sudo apt-key add -
sudo apt-add-repository "deb [arch=amd64] https://apt.releases.hashicorp.com $(lsb_release -cs) main"
sudo apt-get update && sudo apt-get install nomad
# Install CNI plugins
sudo mkdir -p /opt/cni/bin
curl -L https://github.com/containernetworking/plugins/releases/download/v1.3.0/cni-plugins-linux-amd64-v1.3.0.tgz | sudo tar -C /opt/cni/bin -xz- Start Nomad in dev mode:
sudo nomad agent -dev -network-interface=eth0 -log-level=DEBUG -bind=0.0.0.0- Install dependencies:
npm install- Build the project:
npm run build- Start the server:
npm startFor development with auto-reload:
npm run devGET /health
Returns the health status of the API.
POST /provision
Provisions a new evault instance for a tenant.
Request body:
{
"tenantId": "your-tenant-id"
}Response:
{
"success": true,
"message": "Successfully provisioned evault for tenant your-tenant-id",
"jobName": "evault-your-tenant-id"
}The provisioner creates a Nomad job that consists of two tasks:
-
Neo4j Task:
- Runs Neo4j 5.15
- Exposes ports: 7687 (bolt) and 7474 (browser)
- Uses dynamic ports for flexibility
- 2GB memory allocation
-
Evault Task:
- Runs the evault application
- Connects to Neo4j via localhost
- Uses dynamic port allocation
- 512MB memory allocation
- Depends on Neo4j task
PORT- Port to run the API on (default: 3000)NOMAD_ADDR- Nomad API address (default: http://localhost:4646)
-
Port Allocation Issues:
- Ensure Nomad is running with CNI plugins installed
- Check that the network interface is correctly specified
- Verify that ports are not already in use
-
Container Networking:
- Ensure Docker is running
- Check that the bridge network is properly configured
- Verify container-to-container communication
-
Nomad Job Failures:
- Check Nomad logs for detailed error messages
- Verify that all required images are available
- Ensure resource allocations are sufficient
To debug Nomad issues:
# View Nomad logs
journalctl -u nomad -f
# Check Nomad status
nomad status
# View specific job details
nomad job status evault-<tenant-id>
# View allocation details
nomad alloc status <allocation-id>The project uses TypeScript for type safety and better development experience. The source files are in the src directory and are compiled to the dist directory.
For development, you can use npm run dev which uses tsx to run the TypeScript files directly without compilation.