There are a few things that will make managing your pico engine and writing KRL code easier.
...
Update to the Latest Version
You also use the npm install
command to get the latest version, or the variant shown above if you want a specific version rather than the latest, using the command:
Code Block |
---|
npm install -g pico-engine |
Check Your Version
You can see which version you are using near the bottom-right corner of the developer UI page (localhost:3000):
or by running the command:
Code Block |
---|
npm ls -g pico-engine |
...
Code Block |
---|
PORT=3001 PICO_ENGINE_HOME=~/.pico-engine-1 pico-engine |
Using Docker
The pico engine repository contains a Dockerfile
that can be used to build a Docker image for use locally or in a cloud service like AWS Fargate.
To build a container use docker build
:
Code Block |
---|
docker build -t <username>/<container-name> github.com/picolab/pico-engine |
For example:
Code Block |
---|
docker build -t pjw/pico-engine github.com/picolab/pico-engine |
builds a container named pjw/pico-engine for your use.
To run the image use docker run
:
Code Block |
---|
docker run -p <port>:3000 -v <mount-point>:/var/pico-image -d <username>/container-name> |
For example:
Code Block |
---|
docker run -p 3001:3000 -v ~/images/pico-image:/var/pico-image -d pjw/pico-engine |
runs the docker with a port of 3001 and the image files located at ~/tmp/pico-image on the local machine.
If you need to set the URL for your engine, you can add the PICO_ENGINE_BASE_URL
env variable. For example:
Code Block |
---|
docker run -p 80:3000 -v ~/images/pico-image:/var/pico-image -d pjw/pico-engine -e PICO_ENGINE_BASE_URL=https://picos.picolabs.io |
would use https://picos.picolabs.io
and the engine URL.
You can run the same container multiple times with different ports and mount points to have multiple engines running at the same time.
Code Block |
---|
docker run -p 3000:3000 -v ~/images/dnd_game_image:/var/pico-image -d pjw/pico-engine docker run -p 3001:3000 -v ~/images/iot_image:/var/pico-image -d pjw/pico-engine |
would run two different pico engines, each with their own collection of picos, one on port 3000 and one on port 3001.
Hosting Code
Because the rules engine reads your KRL program from the Web, it has to be available online. You can host it anywhere. There are a few options:
- GitHub works well, with one caveat. See these instructions for more information about how to use GitHub to host KRL. The caveat is that GitHub caches the resources on raw URLs for about 5 minutes. If you're making frequent changes, it can be frustrating to wait out the cache. Alternatively, GitLab should give you fewer caching problems. (raw URLs to rulesets in private repositories need an account access token)
- AWS S3 works well. Be sure to make the URL for the ruleset is readable by the engine.
...
To validate using the second method, Install the KRL Compiler using this command:
Code Block | ||
---|---|---|
| ||
npm install -g krl-compiler krl-compiler -v # v1.0.1 |
...