How To: Create a Docker Linux Image for Liquibase Enterprise
Docker containers are a great fit for CI/CD pipelines built using cloud orchestration tools. This document will explain how to create a Docker image with Liquibase Enterprise installed. You can use the Docker image in your CI/CD pipeline to deploy code to your databases.
Overview
This article assumes that you have a basic understanding of Docker. To create the Docker image, you will need the following:
A server or VM with Docker installed and running
Access to the internet to download Liquibase Enterprise software
Your Liquibase Enterprise license key
The Docker build will download and install the Liquibase Enterprise software, add the license key, and generate an image that is ready to run Liquibase Enterprise. Upload the image to your private Docker repository to make it available to your CI/CD pipelines. Since the image contains your license key, it should not be uploaded to a public repository.
Create a Docker Image
Follow these steps to create a Docker image with Liquibase Enterprise.
Step 1: Configure the DockerFile
Copy the DockerFile shown below to your server or VM where Docker is running. The file should be named DockerFile. Make the following configuration changes to the DockerFile:
Select the base Linux image according to your internal system standards.
Supply the version of Liquibase Enterprise including the last 4 digits of the version number.
Optionally install additional database clients.
Provide the name of your license file.
DockerFile
# Select a RHEL 8 compatible base image. The following 3 images have been tested.
# Note that RHEL ubi8 does not have the libnsl package required for the Oracle client and will not work.
FROM rockylinux:8
#FROM almalinux:8
#FROM oraclelinux:8
# Liquibase Enterprise Release Version
# Enter the full version including the last 4 digits.
ARG LIQUIBASE_ENTERPRISE_VERSION=<X.X.XXXX>
# Install required utilities
# - The libaio and libnsl packages are needed for the Oracle instant client. They can be removed if not deploying to Oracle targets.
# - Install the Postgres client if deploying to Postgres targets.
RUN \
yum clean all && \
yum -y update && \
ACCEPT_EULA=Y yum -y install \
libaio \
libnsl \
git \
java-11-openjdk-devel \
zip \
unzip && \
# Install the postgresql client (optional) by uncommenting the next three lines.
# yum install -y https://download.postgresql.org/pub/repos/yum/reporpms/EL-8-x86_64/pgdg-redhat-repo-latest.noarch.rpm && \
# yum module disable -y postgresql && \
# yum install -y postgresql14.x86_64 && \
yum clean packages && \
yum clean metadata && \
yum clean all
# Create liquibase user
RUN \
groupadd liquibase && \
useradd -d /opt/liquibase -g liquibase liquibase && \
echo 'liquibase:liquibase' | chpasswd
# Setup installation directories
RUN \
mkdir /opt/liquibase/installers && \
mkdir /opt/liquibase/license && \
chown -R liquibase /opt/liquibase
WORKDIR /opt/liquibase
# Copy autoinstallers file to image
COPY --chown=liquibase:liquibase autoInstall.xml /opt/liquibase/installers
# Copy License File to image
# Update the name of your_license file.
COPY --chown=liquibase:liquibase <your_license>.lic /opt/liquibase/license
# Change to the liquibase user
USER liquibase
ENV PATH=$PATH:/opt/liquibase/repl
#Install Liquibase Enterprise
RUN set -x \
&& curl -o ./installers/DaticalDB-linux.gtk.x86_64-${LIQUIBASE_ENTERPRISE_VERSION}.jar https://download.liquibase.com/Datical_DB_Software/Datical_DB_${LIQUIBASE_ENTERPRISE_VERSION}/DaticalDB-linux.gtk.x86_64-${LIQUIBASE_ENTERPRISE_VERSION}.jar \
&& curl -o ./installers/DaticalDBCompositeRepo-${LIQUIBASE_ENTERPRISE_VERSION}.zip https://download.liquibase.com/Datical_DB_Software/Datical_DB_${LIQUIBASE_ENTERPRISE_VERSION}/DaticalDBCompositeRepo-${LIQUIBASE_ENTERPRISE_VERSION}.zip \
&& java -jar /opt/liquibase/installers/DaticalDB-linux.gtk.x86_64-${LIQUIBASE_ENTERPRISE_VERSION}.jar /opt/liquibase/installers/autoInstall.xml \
&& export PATH=$PATH:/opt/liquibase/repl \
&& echo "export PATH=$PATH:/opt/liquibase/repl" >> ~/.bashrc \
&& cp /opt/liquibase/license/*.lic /opt/liquibase/repl \
&& hammer installDrivers jar:file:/opt/liquibase/installers/DaticalDBCompositeRepo-${LIQUIBASE_ENTERPRISE_VERSION}.zip\!/ \
# Cleanup files to reduce the size of the image.
&& rm /opt/liquibase/installers/DaticalDB-linux.gtk.x86_64-${LIQUIBASE_ENTERPRISE_VERSION}.jar \
&& rm /opt/liquibase/installers/DaticalDBCompositeRepo-${LIQUIBASE_ENTERPRISE_VERSION}.zip \
# Remove Oracle instant client if it is not needed
# && rm -rf /opt/liquibase/instantclient \
&& rm -rf /opt/liquibase/configuration \
&& rm -rf /opt/liquibase/plugins
#For Liquibase Enterprise Project Info
VOLUME /liquibase/project
#For Liquibase Packager using SQL Source Code Repo
VOLUME /liquibase/src
ENTRYPOINT ["/bin/bash"]
Step 2: Configure the autoInstall.xml file for Liquibase
Liquibase will be installed using ‘silent mode’. This requires a response file to provide the required information for the installer.
Copy the file below and update <your_license> to match your license key. Make sure to name the file autoInstall.xml. Place the file in the same folder as the DockerFile.
autoInstall.xml
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<AutomatedInstallation langpack="eng">
<com.izforge.izpack.panels.HelloPanel id="UNKNOWN (com.izforge.izpack.panels.HelloPanel)"/>
<com.izforge.izpack.panels.LicencePanel id="UNKNOWN (com.izforge.izpack.panels.LicencePanel)"/>
<com.izforge.izpack.panels.TargetPanel id="UNKNOWN (com.izforge.izpack.panels.TargetPanel)">
<installpath>/opt/liquibase</installpath>
</com.izforge.izpack.panels.TargetPanel>
<com.izforge.izpack.panels.PacksPanel id="UNKNOWN (com.izforge.izpack.panels.PacksPanel)">
<pack index="0" name="Liquibase Enterprise Desktop" selected="true"/>
<pack index="1" name="Liquibase Enterprise CLI" selected="true"/>
<pack index="2" name="Liquibase Enterprise license manager" selected="true"/>
<pack index="3" name="Java 11 Runtime" selected="true"/>
<pack index="4" name="Oracle Instant Client" selected="true"/>
<pack index="5" name="Edbplus Client" selected="true"/>
</com.izforge.izpack.panels.PacksPanel>
<com.izforge.izpack.panels.UserInputPanel id="SelectLicenseFilePanel">
<userInput>
<entry key="license.path" value="/opt/liquibase/license/<your_license>.lic"/>
</userInput>
</com.izforge.izpack.panels.UserInputPanel>
<com.izforge.izpack.panels.InstallPanel id="UNKNOWN (com.izforge.izpack.panels.InstallPanel)"/>
<com.izforge.izpack.panels.ShortcutPanel id="UNKNOWN (com.izforge.izpack.panels.ShortcutPanel)"/>
<com.izforge.izpack.panels.FinishPanel id="UNKNOWN (com.izforge.izpack.panels.FinishPanel)"/>
</AutomatedInstallation>
Step 3: Copy your Liquibase license file.
Copy your Liquibase license file to the folder containing the DockerFile and autoInstall.xml.
Step 4: Build the Docker image
Run the following command from the directory where the DockerFile is located.
Replace <imagename>:<version> with your preferred tag. For example, liquibase:v8.1.
docker image build -f DockerFile . -t <imagename>:<version>
Step 5: Verify the Docker image
Run the following commands to start the Docker container and verify the Liquibase installation.
# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
liquibase v8.1 cf6cabe8f895 3 days ago 1.24GB
# docker container run -dit liquibase:v8.1
7fd5debecca08664fd6f1c9be845d0c1f8dcdc1f54fc16e79ac755662a35af41
# docker container ls
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
7fd5debecca0 liquibase:v8.1 "/bin/bash" 13 seconds ago Up 11 seconds compassionate_brattain
# docker container attach 7fd5debecca0
[liquibase@7fd5debecca0 ~]$ id
uid=1000(liquibase) gid=1000(liquibase) groups=1000(liquibase)
[liquibase@7fd5debecca0 ~]$ hammer show version
Using Java from: /opt/liquibase/repl/../jre/bin/java
Liquibase Enterprise CLI 8.1
Component Versions:
Liquibase Enterprise Core 8.1.7474
Liquibase Enterprise CLI 8.1.7474.20221021103330
Liquibase 3.5.11501
Stored Logic extension 1.0.278.20221021102043
AppDBA extension 1.0.436.20221021101352
Java 11.0.15
[liquibase@7fd5debecca0 ~]$ exit
exit
Step 5: Upload the Docker image
The steps to upload the Docker image will vary depending upon the repository of your choice. Consult your local Docker repository administrator for assistance uploading the image.
Make sure that the Docker repository is private to your organization since the image contains your Liquibase license key!
Related content
Copyright © Datical 2012-2020 - Proprietary and Confidential