The senzing/senzingapi-runtime Docker image has the Senzing binaries "baked-in". This Docker image and its corresponding senzingapi-runtime GitHub repository can be used in a number of ways to simplify development using the Senzing SDK library.
There a few techniques to consider when building a custom "Senzing base image". Each choice produces similar result, so the choice will depend upon the existing Docker environment.
- Simple inheritance - Start with Senzing's stock base image and build upon it
- Extend existing image with Senzing binaries - Start with a non-Senzing image and add Senzing binaries to it
- Add Docker instructions to existing Dockerfile - Manually customize a Docker image
Once a Senzing base image has been created it can be used to:
Docker images consist of layers.
The Dockerfile's FROM
instruction identifies the initial layer.
The senzing/senzingapi-runtime
image can be used as an initial layer.
-
Use in a Dockerfile
FROM
instruction. Example:FROM senzing/senzingapi-runtime :
-
It's recommended to use a "pinned" version of an image. So in practice, it would look something more like:
FROM senzing/senzingapi-runtime:3.5.0 :
To find the latest versioned release, visit senzing/senzingapi-runtime tags.
The following steps creates a new Docker image by wrapping an existing image with Senzing binaries.
-
✏️ Set environment variables.
- DOCKER_BASE_IMAGE - The Docker image to build upon.
It will be used as the Dockerfile's
FROM
value. This may be an image that has been "blessed" by an organization. The image must be a debian-based Linux distribution (e.g.debian
,ubuntu
, and others) Please note thatubuntu:22.04
is currently not supported. - DOCKER_IMAGE_SUFFIX - A suffix to append to the output Docker image.
This is meant to differentiate between the "stock"
senzing/senzingapi-runtime
Docker image and a customizedsenzing/senzingapi-runtime-xyz
Docker image.
Example:
export DOCKER_BASE_IMAGE=ubuntu:20.04 export DOCKER_IMAGE_SUFFIX=mycompany
- DOCKER_BASE_IMAGE - The Docker image to build upon.
It will be used as the Dockerfile's
-
Get versions of Docker images. This step sets environment variables that will be used when creating Docker images. Example:
curl -X GET \ --output /tmp/docker-versions-stable.sh \ https://raw.githubusercontent.com/Senzing/knowledge-base/main/lists/docker-versions-stable.sh source /tmp/docker-versions-stable.sh
-
Synthesize environment variables. This step sets environment variables that simplify following steps. Example:
export DOCKER_IMAGE_TAG=senzing/senzingapi-runtime-${DOCKER_IMAGE_SUFFIX}:${SENZING_DOCKER_IMAGE_VERSION_SENZINGAPI_RUNTIME} echo ${DOCKER_IMAGE_TAG}
-
Build new Docker image that will become the "base image" for other Docker images. Example:
docker pull ${DOCKER_BASE_IMAGE} docker build \ --build-arg BASE_IMAGE=${DOCKER_BASE_IMAGE} \ --tag ${DOCKER_IMAGE_TAG} \ https://github.com/senzing-garage/senzingapi-runtime.git#${SENZING_DOCKER_IMAGE_VERSION_SENZINGAPI_RUNTIME}
This technique is to copy, paste, and modify Docker instructions into the "original" Dockerfile to install Senzing.
-
Using the
senzing/senzingapi-runtime
Dockerfile as a guide, copy the Docker instructions into yourDockerfile
-
The following environment variable are important:
LD_LIBRARY_PATH
Once a customized base image has been created by one of these methods:
- Simple inheritance
- Extend existing image with Senzing binaries
- Add Docker instructions to existing Dockerfile
or any other method, then the following instructions will create customized versions of "stock" Senzing Docker images:
-
List the Github repository, DockerHub repository, version tag, and user for each Docker image and their corresponding environment variable name.
Format:
GitHub repository
;DockerHub repository
;tag
;user
whereuser
defaults to1001
.Example:
export BASE_IMAGES=( \ "docker-senzing-console;senzing/senzing-console;${SENZING_DOCKER_IMAGE_VERSION_SENZING_CONSOLE:-latest}" \ "docker-sshd;senzing/sshd;${SENZING_DOCKER_IMAGE_VERSION_SSHD:-latest};0" \ "docker-xterm;senzing/xterm;${SENZING_DOCKER_IMAGE_VERSION_XTERM:-latest}" \ "entity-search-web-app-console;senzing/entity-search-web-app-console;${SENZING_DOCKER_IMAGE_VERSION_ENTITY_SEARCH_WEB_APP_CONSOLE:-latest}" \ "redoer;senzing/redoer;${SENZING_DOCKER_IMAGE_VERSION_REDOER:-latest};1001" \ "senzing-api-server;senzing/senzing-api-server;${SENZING_DOCKER_IMAGE_VERSION_SENZING_API_SERVER:-latest}" \ "senzing-poc-server;senzing/senzing-poc-server;${SENZING_DOCKER_IMAGE_VERSION_SENZING_POC_SERVER:-latest}" \ "senzingapi-tools;senzing/senzingapi-tools;${SENZING_DOCKER_IMAGE_VERSION_SENZINGAPI_TOOLS:-latest}" \ "stream-loader;senzing/stream-loader;${SENZING_DOCKER_IMAGE_VERSION_STREAM_LOADER:-latest}" \ )
-
Build each of the Docker images in the list. Example:
for BASE_IMAGE in ${BASE_IMAGES[@]}; \ do \ IFS=";" read -r -a BASE_IMAGE_DATA <<< "${BASE_IMAGE}" BASE_IMAGE_REPOSITORY="${BASE_IMAGE_DATA[0]}" BASE_IMAGE_NAME="${BASE_IMAGE_DATA[1]}" BASE_IMAGE_VERSION="${BASE_IMAGE_DATA[2]}" BASE_IMAGE_USER="${BASE_IMAGE_DATA[3]}" docker build \ --build-arg BASE_IMAGE=${DOCKER_IMAGE_TAG} \ --build-arg USER=${BASE_IMAGE_USER:-1001} \ --tag ${BASE_IMAGE_NAME}-${DOCKER_IMAGE_SUFFIX}:${BASE_IMAGE_VERSION} \ https://github.com/senzing-garage/${BASE_IMAGE_REPOSITORY}.git#${BASE_IMAGE_VERSION} done
-
Verify each of the images was created. Example:
docker images | grep ${DOCKER_IMAGE_SUFFIX}