Use from Docker
===============
Docker prerequisites
--------------------
1. `Docker `_
2. `Docker Compose `_
Building the Docker images locally
----------------------------------
To build the Docker images after first checking out the repository, run:
::
cd docker
script/bootstrap
Or after updating the repository:
::
cd docker
script/update
Pulling stable Docker images from Dockerhub
-------------------------------------------
Alternatively, you can pull stable images from Dockerhub by running:
::
cd docker
script/pull
.. _docker-server:
Running the TWKS server in Docker
---------------------------------
After building or pulling the Docker images,
::
cd docker
script/server
The Docker container exposes the server's REST and SPARQL APIs via HTTP on port 8080, which is bound to localhost.
The server Dockerfile has several declared VOLUMEs:
- ``/data``: where the server stores its data
- ``/extcp``: where the server loads `Service Provider Interface (SPI) `_ .jars
- ``/extfs``: where the server loads extension scripts
The volumes can be accessed by running any other container with ``--volumes-from``. After starting up the server:
::
docker run -it --volumes-from=twks-server ubuntu:bionic bash
which mounts the volumes at the paths listed above. You can add an additional bind mount of a host directory:
::
docker run -it -v $PWD:/host --volumes-from=twks-server ubuntu:bionic bash
and then copy files from the host to the appropriate ``twks-server`` volume e.g., ``cp /host/my-spi.jar /extcp``.
.. _docker-cli:
Running the TWKS command line interface with Docker
---------------------------------------------------
Run the server as above, then:
::
cd docker
cat nanopublication.trig | script/cli put-nanopublications --lang trig -
Explanation:
- ``script/cli`` runs the TWKS command line interface container and connects it to the server.
- ``put-nanopublication`` is the CLI sub-command
- ``--lang trig`` specifies that the input will be in Trig format
- ``put-nanopublications`` reads from stdin since ``-`` was specified (a ``-f file`` would be expected to be in the container; it is easier to use stdin)
- ``cat nanopublication.trig`` writes the contents of that file to the container's stdin