• Topic
  • Discussion
  • VOS.VirtuosoDocker(Last) -- Owiki? , 2018-04-13 12:09:57 Edit owiki 2018-04-13 12:09:57

    How to Deploy Virtuoso in a Docker Container

    To simplify deployment, Virtuoso Open Source Edition can be run in a Docker container.

    Building a VOS Base Image

    The Dockerfiles below provide two VOS images:

    • A base image which provides a compiled, installed VOS binary.
    • A deployment image, built from the base image, which starts a VOS instance on the specified ports using the given VOS virtuoso.ini configuration file and, optionally, an existing Virtuoso database.

    To build the base image:


    docker build -f Dockerfile.vos_base -t openlink/vos_base:v0 .
    

    Dockerfile.vos_base builds VOS from the VOS GitHub sources, as described in the VOS Wiki, and installs VOS in /opt/virtuoso-opensource.

    Dockerfile.vos_base


    FROM ubuntu:trusty
    
    ENV VIRT_HOME /opt/virtuoso-opensource
    
    ENV VIRT_BUILD_OPTS --with-readline
    
    ENV VIRT_DB /var/lib/virtuoso/db
    
    RUN apt-get -y update && \
      apt-get -y clean && \
      apt-get -y install dpkg-dev build-essential && \
      apt-get -y install autoconf automake libtool flex bison git gperf gawk m4 make libxml2-dev libssl-dev libreadline-dev wget && \
      rm -rf /var/lib/apt/lists/* && \
      rm -rf /tmp/*
    
    WORKDIR /opt
    RUN git clone git://github.com/openlink/virtuoso-opensource.git virtuoso-opensource.src
    WORKDIR /opt/virtuoso-opensource.src
    RUN git checkout develop/7
    RUN ./autogen.sh && ./configure --prefix=$VIRT_HOME $VIRT_BUILD_OPTS && make && make install
    
    WORKDIR /opt/virtuoso-opensource/share/virtuoso/vad
    RUN wget http://download3.openlinksw.com/uda/vad-packages/7.2/cartridges_dav.vad 
    

    Building a VOS Deployment Image

    To build the deployment image:


    docker build -f Dockerfile.vos -t openlink/vos:v0 .
    

    The image created by Dockerfile.vos runs Virtuoso in the foreground and assumes Virtuoso listens for HTTP connections on port 8890 and SQL connections on port 1111.

    Dockerfile.vos


    FROM openlink/vos_base:v0
    
    ENV VIRT_HOME /opt/virtuoso-opensource
    ENV VIRT_DB /opt/virtuoso-opensource/var/lib/virtuoso/db
    
    RUN export PATH=$PATH:/opt/virtuoso-opensource/bin
    
    EXPOSE 1111
    EXPOSE 8890
    
    WORKDIR $VIRT_DB
    CMD /opt/virtuoso-opensource/bin/virtuoso-t -f
    

    Running VOS within Docker

    Initializing a new database

    In order to retain changes to the Virtuoso database, the database should be held in the host file system. The database location on the host should reflect the installation directory used by the base image. Create directory /opt/virtuoso-opensource/var/lib/virtuoso/db in the host file system and provide a virtuoso.ini configuration file.


    sudo mkdir -p /opt/virtuoso-opensource/var/lib/virtuoso/db
    
    sudo cp ./virtuoso.ini.template /opt/virtuoso-opensource/var/lib/virtuoso/db/virtuoso.ini
    

    The virtuoso.ini.template assumes the installation directory is /opt/virtuoso-opensource, with the Virtuoso HTTP server listening on port 8890 and SQL client connections made through port 1111.

    Starting the VOS Container

    Start a VOS container by running:


    sudo docker run -v /opt/virtuoso-opensource/var/lib/virtuoso/db:/opt/virtuoso-opensource/var/lib/virtuoso/db -t -p 1111:1111 -p 8890:8890 -i openlink/vos:v0
    

    If the db directory contains only a virtuoso.ini file, a new database will be created when the container is started for the first time. All subsequent changes to the database will be persisted to the host file system.

    Using an existing database

    If the db directory in the host file system contains an existing Virtuoso database, that database will be used by the container. Again, all subsequent changes to the database will be persisted to the host file system.

    Installing the Cartridges VAD

    The Virtuoso Sponger and its associated transformers are distributed as a VAD (Virtuoso Application Distribution). When a new database instance is created, VOS will automatically install the Virtuoso Conductor UI. However it will not automatically install the Cartridges nor any other VAD.

    The latest Cartridges VAD is available for download from the Virtuoso download page, via the "Linked Open Data Transformation Middleware ("Sponger") link. This VAD is automatically downloaded as part of the VOS base image build and included in the image at /opt/virtuoso-opensource/share/virtuoso/vad.

    Once a VOS instance has been initialized and the Cartridges or other VAD downloaded, the desired VAD can be installed by logging into the Virtuoso Conductor (http://{container_host}:8890/conductor), navigating to the System Admin --> Packages tab, and clicking on the Install link. Alternatively, iSQL may be used, with a command of this form:


    DB.DBA.VAD_INSTALL('{vad-name}.vad',0);
    

    Once installed, enable the desired cartridges through the Linked Data --> Sponger panel.