Page: U8 Docker images
2019-12-13 19:12
U8 Docker images
To simplify using U8, the Docker images are provided for U8 as well as for some U8-based software.
Overview
The Universa Docker images are provided in the official Docker Hub repository. The whole Universa project area can be seen at hub.docker.com/r/universa. The following Docker images may be of interest to you:
- universa/u8 – the primary image with U8 runtime.
- universa/ubotserver – UBot server (U8-based).
- universa/node-u8 – Universa node implementation (U8-based).
These images are rebuilt automatically from the latest GitHub code.
Note: there are also other general Universa-related Docker images there; see the appropriate article for more details: Universa Docker images.
Docker prerequirements
To use Docker images, you need to install the Docker software itself. See the installation details at the official Docker site; below are some download shortcuts for your convenience.
- If you are running Linux: Centos, Debian, Fedora, Ubuntu, any other Linux variety. You may also to examine this article in Docker manuals.
- If you are running macOS: macOS Docker setup manual.
- If you are running Windows: Windows Docker setup manual.
If you are going to use Docker Compose, you may want to install it as well; see details here.
Images
universa/u8: JavaScript runtime engine
Usage
Note that if you want to execute some external JavaScript file using U8, you should bind the directory to the image (as in the examples below).
See help
docker run universa/u8
Selftest
docker run universa/u8 --selftest
Running some custom mytest.js
app
Assuming the mytest.js
file is present in the current directory, you need to run the image while mounting the directory, for the image to see it. In the example below, the current directory ($(pwd)
) is mounted to the /src
directory for the image, and the image is executed using the mounted path.
docker run \
--mount type=bind,source="$(pwd)",target=/src \
universa/u8 /src/mytest.js
Running the prepackaged apps
Some U8 JavaScript apps are available in the /u8scripts
directory. They are prepackaged into the Docker image, too.
Running helloworld.js
app
docker run universa/u8 /code/u8scripts/examples/helloworld.js
It should print Hello, world!
.
Running helloworld_http.js
app
To use some port-listening app (like helloworld_http.js
), you need to expose/publish the port being listened:
docker run \
--publish 127.0.0.1:8180:8080/tcp \
universa/u8 /code/u8scripts/examples/helloworld_http.js
After this, the script will be available at http://127.0.0.1:8180/hello.
Directory structure
Here is a map of source directories, and their in-image counterparts:
Source path | Image-mapped path |
---|---|
/code/jslib |
|
/code/u8scripts |
universa/node-u8: implementation of Universa Node on U8
Note: it is provided strictly as Early Access!
Usage
Use the following command to launch:
docker run universa/node-u8
Note that for proper execution, you’ll need to have PostgreSQL installed and reachable to the Docker container (you may need to add extra configuration); this may be either dedicated PostgreSQL setup or using the stock postgres Docker image from Docker Hub connected to the Docker container (probably, using Docker Compose).
Also you may need to specify the node configuration directory (and mount it to the Docker image).
universa/ubotserver: server for running UBots
Usage
- Make a logs directory like
logs
(note it won’t be mounted to the image). - Make a config directory like
ubot_config
(and put the needed data in it, so it will be mountable into the image as/ubot_config
; see the…/test/config/ubot_config/ examples in GitHub); theubot_config
directory should contain subdirectoriesconfig
andtmp
. - Then run the following command:
docker run \
--mount type=bind,source="$(pwd)/ubot_config",target=/ubot_config \
universa/ubotserver \
--config /ubot_config > logs/log.txt 2> logs/errlog.txt
Note that for proper execution, you’ll need to have PostgreSQL installed and reachable to the Docker container (you may need to add extra configuration); this may be either dedicated PostgreSQL setup or using the stock postgres Docker image from Docker Hub connected to the Docker container (probably, using Docker Compose).