If you are beginning your journey with Senzing, please start with Senzing Quick Start guides.
You are in the Senzing Garage where projects are "tinkered" on. Although this GitHub repository may help you understand an approach to using Senzing, it's not considered to be "production ready" and is not considered to be part of the Senzing product. Heck, it may not even be appropriate for your application of Senzing!
Create a TGZ bundle of docker images for air-gapped environments
based on a docker-compose.yaml
file.
Process:
- In an internet-connected environment:
- "Normalize" a
docker-compose.yaml
file to instantiate variables. - Scan through the normalized
docker-compose.yaml
file looking forimage:
tags. - Create a shell script that does
docker pull
anddocker save
for the images. Example: save-images-example.sh - Run shell script to create TGZ file containing docker images
with a script to do
docker load
.
- "Normalize" a
- In an air-gapped environment:
- Uncompress the TGZ file.
- Run the script to perform
docker load
of the docker images.
- Preamble
- Related artifacts
- Expectations
- In an internet-connected environment
- In an air-gapped environment
- Develop
- Advanced
- Errors
- References
At Senzing, we strive to create GitHub documentation in a "don't make me think" style. For the most part, instructions are copy and paste. Whenever thinking is needed, it's marked with a "thinking" icon 🤔. Whenever customization is needed, it's marked with a "pencil" icon ✏️. If the instructions are not clear, please let us know by opening a new Documentation issue describing where we can improve. Now on with the show...
- 🤔 - A "thinker" icon means that a little extra thinking may be required. Perhaps there are some choices to be made. Perhaps it's an optional step.
- ✏️ - A "pencil" icon means that the instructions may need modification before performing.
⚠️ - A "warning" icon means that something tricky is happening, so pay attention.
- Space: This repository and demonstration require 1-3 GB free disk space per image saved.
- Time: Budget 10 minutes per image saved, depending on CPU and network speeds.
- Background knowledge: This repository assumes a working knowledge of:
- Software requirements on the internet-connected (i.e. not the air-gapped) system:
-
✏️ Identify the directory containing the
docker-compose.yaml
file. Example:export SENZING_DOCKER_COMPOSE_DIRECTORY=~/my-docker-compose
-
🤔 Optional: Set any needed environment variables. For instance, to specify the latest docker image tags for docker-compose.yaml files in docker-compose-demo environment variables can be set in this manner. Example:
curl -X GET \ --output ${SENZING_DOCKER_COMPOSE_DIRECTORY}/docker-versions-latest.sh \ https://raw.githubusercontent.com/Senzing/knowledge-base/main/lists/docker-versions-latest.sh source ${SENZING_DOCKER_COMPOSE_DIRECTORY}/docker-versions-latest.sh
-
Use docker-compose config to normalize the
docker-compose.yaml
file into a newdocker-compose-normalized.yaml
file.Example:
cd ${SENZING_DOCKER_COMPOSE_DIRECTORY} docker-compose \ --file docker-compose.yaml \ config \ > docker-compose-normalized.yaml
-
Get the latest version of
senzing/docker-compose-air-gapper
. Example:docker pull senzing/docker-compose-air-gapper:latest
-
Using a
senzing/docker-compose-air-gapper
docker container, create asave-images.sh
file in theSENZING_DOCKER_COMPOSE_DIRECTORY
directory. Example:docker run \ --env SENZING_DOCKER_COMPOSE_FILE=/data/docker-compose-normalized.yaml \ --env SENZING_OUTPUT_FILE=/data/save-images.sh \ --env SENZING_SUBCOMMAND=create-save-images \ --interactive \ --rm \ --tty \ --volume ${SENZING_DOCKER_COMPOSE_DIRECTORY}:/data \ senzing/docker-compose-air-gapper:latest
-
Run
save-images.sh
Example:cd ${SENZING_DOCKER_COMPOSE_DIRECTORY} chmod +x save-images.sh ./save-images.sh
-
After
save-images.sh
has completed, there will be a new~/docker-compose-air-gapper-0000000000.tgz
file. This is the file to be transferred to the air-gapped system. Example output:Done. Output file: /home/senzing/docker-compose-air-gapper-0000000000.tgz Which is a compressed version of /home/senzing/docker-compose-air-gapper-0000000000
- Software requirements on the air-gapped system:
- The
docker-compose-air-gapper-0000000000.tgz
needs to be transferred to the air-gapped system.
-
✏️ Set Environment variables. Identify the location of the
tgz
file (SENZING_TGZ_FILE
) and the location where the files should be extracted (SENZING_OUTPUT_DIRECTORY
). Example:export SENZING_OUTPUT_DIRECTORY=/tmp export SENZING_TGZ_FILE=~/docker-compose-air-gapper-0000000000.tgz
-
Extract
docker-compose-air-gapper-0000000000.tgz
file into specified directory. Example:tar \ --directory=${SENZING_OUTPUT_DIRECTORY} \ --extract \ --file=${SENZING_TGZ_FILE} \ --verbose
-
Change directory to the location of the extracted files. Example:
export SENZING_TGZ_FILENAME=${SENZING_TGZ_FILE##*/} export SENZING_INPUT_DIRECTORY=${SENZING_OUTPUT_DIRECTORY}/${SENZING_TGZ_FILENAME%%.tgz} cd ${SENZING_INPUT_DIRECTORY}
-
Run
load-images.sh
. This step loads the local docker repository with the images extracted from thedocker-compose-air-gapper-0000000000.tgz
file. Example:./load-images.sh
The following instructions are used when modifying and building the Docker image.
🤔 The following tasks need to be complete before proceeding. These are "one-time tasks" which may already have been completed.
For more information on environment variables, see Environment Variables.
-
Set these environment variable values:
export GIT_ACCOUNT=senzing export GIT_REPOSITORY=docker-compose-air-gapper export GIT_ACCOUNT_DIR=~/${GIT_ACCOUNT}.git export GIT_REPOSITORY_DIR="${GIT_ACCOUNT_DIR}/${GIT_REPOSITORY}"
-
Using the environment variables values just set, follow steps in clone-repository to install the Git repository.
-
Option #1: Using
docker
command and GitHub.sudo docker build \ --tag senzing/docker-compose-air-gapper \ https://github.com/senzing-garage/docker-compose-air-gapper.git#main
-
Option #2: Using
docker
command and local repository.cd ${GIT_REPOSITORY_DIR} sudo docker build --tag senzing/docker-compose-air-gapper .
-
Option #3: Using
make
command.cd ${GIT_REPOSITORY_DIR} sudo make docker-build
-
Have python 3 installed.
- Using pip3, install Python requirements in requirements.txt.
-
Get a local copy of docker-compose-air-gapper.py. Example:
-
✏️ Specify where to download file. Example:
export SENZING_DOWNLOAD_FILE=~/docker-compose-air-gapper.py
-
Download file. Example:
curl -X GET \ --output ${SENZING_DOWNLOAD_FILE} \ https://raw.githubusercontent.com/Senzing/docker-compose-air-gapper/main/docker-compose-air-gapper.py
-
Make file executable. Example:
chmod +x ${SENZING_DOWNLOAD_FILE}
-
This step creates the save-images.sh
shell script using a specified docker-compose.yaml
file.
-
✏️ Identify the file to hold a new shell script. This script will be used to download, save, and compress docker images into a single file. Example:
export SENZING_SAVE_IMAGE_FILE=~/save-images.sh
-
Create
save-images.sh
by usingdocker-compose config
to normalizedocker-compose.yaml
. The normalized output is used bydocker-compose-air-gapper.py
to createsave-images.sh
Example:cd ${SENZING_DOCKER_COMPOSE_DIRECTORY} docker-compose --file docker-compose.yaml config \ | ${SENZING_DOWNLOAD_FILE} create-save-images \ > ${SENZING_SAVE_IMAGE_FILE}
-
Make
save-image.sh
executable. Example:chmod +x ${SENZING_SAVE_IMAGE_FILE}
Since
docker-compose-air-gapper.py
only looks at a few properties in the docker-compose.yaml
file,
it's possible to make a skeleton docker-compose.yaml
file for the purposes of creating a TGZ file for an air-gapped enviroment.
-
For example, a
/tmp/docker-compose-skeleton.yaml
file could look like this:services: x: image: senzing/senzing-console:1.0.3 y: image: senzing/stream-loader:1.9.0 z: image: senzing/senzing-api-server:2.7.4
-
Since the
docker-compose-skeleton.yaml
file is already "normalized" (i.e. there are no variables for substitution), there is no need to rundocker-compose config
. -
Using a
senzing/docker-compose-air-gapper
docker container, create asave-images.sh
file in the/tmp
directory. Example:docker run \ --env SENZING_DOCKER_COMPOSE_FILE=/data/docker-compose-skeleton.yaml \ --env SENZING_OUTPUT_FILE=/data/save-images.sh \ --env SENZING_SUBCOMMAND=create-save-images \ --interactive \ --rm \ --tty \ --volume /tmp:/data \ senzing/docker-compose-air-gapper
-
Run
save-images.sh
. Example:chmod +x /tmp/save-images.sh /tmp/save-images.sh
- See docs/errors.md.