📜 ⬆️ ⬇️

Caché Containerization

In this article I want to talk about how you can get your Docker image with InterSystems Caché / Ensemble.

Let's start from the beginning, i.e. with Dockerfile. Dockerfile is a simple yml text file with instructions for building an image.

I recommend using CentOS as the base image, since InterSystems officially supports RedHat as the main platform, and CentOS as the development platform.

FROM centos:6 

You can add yourself as the author of the file.
')
 MAINTAINER Dmitry Maslennikov <mrdaimor@gmail.com> 

The first step is to install some utilities that will be needed both during the installation process and for the operation of Caché. Here I have set up a time zone.

 # update OS + dependencies & run Caché silent instal RUN yum -y update \ && yum -y install which tar hostname net-tools wget \ && yum -y clean all \ && ln -sf /etc/locatime /usr/share/zoneinfo/Europe/Moscow 

Define a temporary folder for the distribution.

 ENV TMP_INSTALL_DIR=/tmp/distrib 

We define some arguments with default values, which can then be modified during assembly.

 ARG password="Qwerty@12" ARG cache=ensemble-2016.2.1.803.0 

Now you need to define the parameters for the automatic installation.

 ENV ISC_PACKAGE_INSTANCENAME="ENSEMBLE" \ ISC_PACKAGE_INSTALLDIR="/opt/ensemble/" \ ISC_PACKAGE_UNICODE="Y" \ ISC_PACKAGE_CLIENT_COMPONENTS="" \ ISC_PACKAGE_INITIAL_SECURITY="Normal" \ ISC_PACKAGE_USER_PASSWORD=${password} 

I decided to set Caché security to Normal, and therefore I need to set a password.

You can find more options in the documentation .

As a working directory, we will set a temporary folder for the distribution, this directive will create a folder if it did not exist before.

 WORKDIR ${TMP_INSTALL_DIR} 

You can immediately add a license file if you are not going to upload the image to public repositories.

 COPY cache.key $ISC_PACKAGE_INSTALLDIR/mgr/ 

Now we need a distribution kit to build, and there are several ways to get it:


Everything is ready to install, you can run.

 RUN ./$cache-lnxrhx64/cinstall_silent 

After installation is complete, you need to stop the server.

 RUN ccontrol stop $ISC_PACKAGE_INSTANCENAME quietly 

But that's not all; in Docker, for the operation of a container, one process controlling process is needed. And for this we need the project ccontainermain by Luca Ravazzolo . Let's load the binary directly from the github .

 # Caché container main process PID 1 (https://github.com/zrml/ccontainermain) RUN curl -L https://github.com/zrml/ccontainermain/raw/master/distrib/linux/ccontainermain -o /ccontainermain \ && chmod +x /ccontainermain 

Clean temporary folder.

 RUN rm -rf $TMP_INSTALL_DIR 

Remark if overlay driver is used
If the Docker is configured to work with the overlay driver, there may be problems, and you need to add such lines to add a wrapper on ccontrol, otherwise, when Caché starts, it will immediately fall out with an error <PROTECT>.

 # Workaround for an overlayfs bug which prevents Cache from starting with <PROTECT> errors COPY ccontrol-wrapper.sh /usr/bin/ RUN cd /usr/bin \ && rm ccontrol \ && mv ccontrol-wrapper.sh ccontrol \ && chmod 555 ccontrol 

The ccontrol-wrapper.sh wrapper code.

 #!/bin/bash # Work around a weird overlayfs bug where files don't open properly if they haven't been # touched first - see the yum-ovl plugin for a similar workaround if [ "${1,,}" == "start" ]; then find $ISC_PACKAGE_INSTALLDIR -name CACHE.DAT -exec touch {} \; fi /usr/local/etc/cachesys/ccontrol $@ 

You can check which driver is used in Docker by this command.

 docker info --format '{{.Driver}}' 

Workaround for Caché
Some details about the bug with OverlayFS

You need to tell Docker which network ports are used in the container, these are 57772 for Web access and 1972 for binary access, the standard default ports in Caché.

 EXPOSE 57772 1972 

Finally, let you know how to run the container.

 ENTRYPOINT ["/ccontainermain", "-cconsole", "-i", "ensemble"] 

As a result, the file takes the following form:

 FROM centos:6 MAINTAINER Dmitry Maslennikov <Dmitry.Maslennikov@csystem.cz> # update OS + dependencies & run Caché silent instal RUN yum -y update \ && yum -y install which tar hostname net-tools wget \ && yum -y clean all \ && ln -sf /etc/locatime /usr/share/zoneinfo/Europe/Prague ARG password="Qwerty@12" ARG cache=ensemble-2016.2.1.803.0 ENV TMP_INSTALL_DIR=/tmp/distrib # vars for Caché silent install ENV ISC_PACKAGE_INSTANCENAME="ENSEMBLE" \ ISC_PACKAGE_INSTALLDIR="/opt/ensemble/" \ ISC_PACKAGE_UNICODE="Y" \ ISC_PACKAGE_CLIENT_COMPONENTS="" \ ISC_PACKAGE_INITIAL_SECURITY="Normal" \ ISC_PACKAGE_USER_PASSWORD=${password} # set-up and install Caché from distrib_tmp dir WORKDIR ${TMP_INSTALL_DIR} ADD $cache-lnxrhx64.tar.gz . # cache distributive RUN ./$cache-lnxrhx64/cinstall_silent \ && ccontrol stop $ISC_PACKAGE_INSTANCENAME quietly \ # Caché container main process PID 1 (https://github.com/zrml/ccontainermain) && curl -L https://github.com/daimor/ccontainermain/raw/master/distrib/linux/ccontainermain -o /ccontainermain \ && chmod +x /ccontainermain \ && rm -rf $TMP_INSTALL_DIR WORKDIR ${ISC_PACKAGE_INSTALLDIR} # TCP sockets that can be accessed if user wants to (see 'docker run -p' flag) EXPOSE 57772 1972 ENTRYPOINT ["/ccontainermain", "-cconsole", "-i", "ensemble"] 

Now we are ready to assemble the image. It is necessary to execute such command in the folder where Dockerfile lies.
docker build -t ensemble-simple .

The build process will load the original image, and the Caché installation process itself.

You can change the values ​​of the parameters for the assembly as follows.

 docker build --build-arg password=SuperSecretPassword -t ensemble-simple . 

 docker build --build-arg cache=ensemble-2016.2.1.803.1 -t ensemble-simple . 

And you can run a new image with such a command.

 docker run -d -p 57779:57772 -p 1979:1972 ensemble-simple 

Here, 57779 and 1979, these are the ports through which the container will be accessible from the local machine.

Such a command can be seen, all running containers.

 docker ps 

  CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
 5f8d2cb3745a ensemble-simple "/ ccontainermain -..." 18 seconds ago Up 17 seconds 0.0.0.0:1979->1972/tcp, 0.0.0.0.ln7779->57772/tcp keen_carson 

Now you can open the management portal via the link http: // localhost: 57779 / csp / sys / UtilHome.csp . Our new system works and is available.

image

The sources can be found on the githaba here .

Source: https://habr.com/ru/post/323746/


All Articles