pyro-gateway provides an API for starting Ignition Docker containers from within JavaScript. This library is intended for use in testing environments where you need a short-lived, programmatically configured, ephemeral gateway.
Usage
Start a new Gateway
import { IgnitionContainer } from '@mussonindustrial/pyro-gateway'
const gateway = await new IgnitionContainer('8.1.33')
.withModules(['perspective'])
.withGatewayName('My New Gateway')
.start()
Start a Gateway from a Backup
import { IgnitionContainer } from '@mussonindustrial/pyro-gateway'
const gateway = await new IgnitionContainer('8.1.33')
.withGatewayBackup('/path/to/gateway.gwbk')
.start()
Setting Gateway Properties
Gateway properties can be set before startup through the various .with~ methods.
// Current available setter methods
.withEdition(edition: GatewayEdition)
.withHTTPPort(port: number)
.withHTTPSPort(port: number)
.withModules(modules: ModuleIdentifier[])
.withGatewayName(name: string)
.withGatewayBackup(path: string)
The eventual goal is to provide a complete set of setter methods.
In the meantime, if you wish the directly set environment or runtime variables, they can be accessed through gateway.env and gateway.runtime respectively.
While I salute the work done and the contribution to the ecosystem, I'm not sure I understand the use case for the example above. Does this allow to update files on a remote gateway ?
I guess my question is: What's the advantage of this over a bind mount ? Except for the obvious fact that it's not a bind mount ;p
Yup. Any gateway with the setup/boot-strapping endpoints can be updated. So you could develop your theme on a local gateway with live reloading, then push to production gateway once changes are finalized (or have a CI/CD pipeline do it for you, for multiple gateways).
You’re right, for this example of updating a theme a bind mount would work fine. But, the goal is to allow configuration of more than can be set via bind mounts (database and device connections, etc.).
Then when 8.3 releases, we can drop the WebDev functions and use the native capabilities.
v0.3.0 now allows you to perform project/resource imports on the running gateway.
The implementation is pretty naïve at the moment; if you import resources into a project that doesn't exist you'll end up with orphaned files. More work is coming to make it impossible to mess up, but at least it does work.
import { IgnitionContainer } from '@mussonindustrial/pyro-gateway'
const gateway = await new IgnitionContainer('inductiveautomation/ignition:latest')
.withGatewayBackup('/path/to/gateway.gwbk')
.start()
gateway.importProject('new-project', '/path/to/project.zip')
gateway.importProjectResources('existing-project', '/path/to/resources.zip')
Edit: Also, moved this post to the Automated Testing category since that is the intended use case.