Building the Docker® images
Introduction
Some of the base images require authentication with the RedHat Container Registry. You must be logged in to the following registries:
registry.redhat.io
- For accessing
registry.redhat.io/rhel8/httpd-24
- Login using
docker login registry.redhat.io
- For accessing
registry.connect.redhat.com
- For accessing
registry.connect.redhat.com/ibm/ibmjava8-sdk-ubi8-minimal
- Login using
docker login registry.connect.redhat.com
- For accessing
For the docker
commands that follow you must set a DOCKER_REGISTRY
environment variable based on the container environment you are deploying:
The URL for this value can be retrieved using this command: oc registry info --public
For example:
export DOCKER_REGISTRY=default-route-openshift-image-registry.apps-crc.testing
export DOCKER_REGISTRY=minikube.local:5000
`$env:DOCKER_REGISTRY = "localhost:5000"`
export DOCKER_REGISTRY=us.icr.io
Now that all the elements are in place, build the images as follows:
Building the images
The following sections provide steps for building the Docker images.
Set the PROJECT
environment variable:
XML server image
To build the XML server image, run the following commands:
cd $SPM_HOME/dockerfiles/Liberty/docker build \--tag $DOCKER_REGISTRY/$PROJECT/xmlserver:latest \--build-arg "BASE_REGISTRY=registry.connect.redhat.com/" \--file XMLServer.Dockerfile .
cd $SPM_HOME/dockerfiles/Liberty/docker build \--tag $DOCKER_REGISTRY/$PROJECT/xmlserver:latest \--file XMLServer.Dockerfile .
cd $SPM_HOME/dockerfiles/Liberty/docker build `--tag $env:DOCKER_REGISTRY/$env:PROJECT/xmlserver:latest `--build-arg "BASE_REGISTRY=registry.connect.redhat.com/" `--file XMLServer.Dockerfile .
cd $env:SPM_HOME\dockerfiles\Liberty\docker build --tag $env:DOCKER_REGISTRY/$env:PROJECT/xmlserver:latest `--file XMLServer.Dockerfile .
For information on building an XML server sidecar performance monitoring image see Monitoring XML servers.
Utilities image
The utilities image is used at various stages of the deployment to check the state of the deployment.
To build the utilities image, run the following commands:
cd $SPM_HOME/dockerfiles/Liberty/docker build \--tag $DOCKER_REGISTRY/$PROJECT/utilities:latest \--build-arg "BASE_REGISTRY=registry.connect.redhat.com/" \--file Utilities.Dockerfile .
cd $SPM_HOME/dockerfiles/Liberty/docker build \--tag $DOCKER_REGISTRY/$PROJECT/utilities:latest \--file Utilities.Dockerfile .
cd $env:SPM_HOME\dockerfiles\Liberty\docker build `--tag $env:DOCKER_REGISTRY/$env:PROJECT/utilities:latest `--build-arg "BASE_REGISTRY=registry.connect.redhat.com/" `--file Utilities.Dockerfile .
cd $env:SPM_HOME\dockerfiles\Liberty\docker build --tag $env:DOCKER_REGISTRY/$env:PROJECT/utilities:latest `--file Utilities.Dockerfile .
Batch image
A .dockerignore
file is used to omit the EAR files from the build context for batch.
To build the batch image, run the following commands:
cd $SPM_HOME/dockerfiles/Liberty/echo -e 'content/release-stage/ear' > .dockerignoredocker build \--tag $DOCKER_REGISTRY/$PROJECT/batch:latest \--file Batch.Dockerfile .rm -f .dockerignore
cd $env:SPM_HOME\dockerfiles\Liberty\echo "content/release-stage/ear" | set-content .dockerignore -Encoding Asciidocker build `--tag $env:DOCKER_REGISTRY/$env:PROJECT/batch:latest `--file Batch.Dockerfile .del .dockerignore
Server Code image
To build the Server Code image, run the following commands:
cd $SPM_HOME/dockerfiles/Liberty/docker build \--tag $DOCKER_REGISTRY/$PROJECT/servercode:latest \--file ServerEAR.Dockerfile \--build-arg "MQ_RA_LICENSE=--acceptLicense" .
cd $env:SPM_HOME\dockerfiles\Liberty\docker build `--tag $env:DOCKER_REGISTRY/$env:PROJECT/servercode:latest `--file ServerEAR.Dockerfile `--build-arg "MQ_RA_LICENSE=--acceptLicense" .
Application images
Take note of the SERVERCODE_IMAGE
build argument which references the server code image - this gives the images a common base.
To build the application images, run the following commands for each of the applications (EAR files) needed:
cd $SPM_HOME/dockerfiles/Liberty/docker build \--tag $DOCKER_REGISTRY/$PROJECT/curam:latest \--file ClientEAR.Dockerfile \--build-arg "SERVERCODE_IMAGE=$DOCKER_REGISTRY/$PROJECT/servercode:latest" \--build-arg "EAR_NAME=Curam" .
cd $env:SPM_HOME\dockerfiles\Liberty\docker build `--tag $env:DOCKER_REGISTRY/$env:PROJECT/curam:latest `--file ClientEAR.Dockerfile \--build-arg "SERVERCODE_IMAGE=$env:DOCKER_REGISTRY/$env:PROJECT/servercode:latest" \--build-arg "EAR_NAME=Curam" .
For additional SPM applications (e.g. Rest, CitizenPortal), make the following changes to the command:
- the value of the
--tag
argument must be the application name in lowercase - the value of the
--build-arg EAR_NAME
argument must be the name of the EAR file without the file extension (that is, forRest.ear
, use the valueRest
)
docker build \--tag $DOCKER_REGISTRY/$PROJECT/rest:latest \--file ClientEAR.Dockerfile \--build-arg "SERVERCODE_IMAGE=$DOCKER_REGISTRY/$PROJECT/servercode:latest" \--build-arg "EAR_NAME=Rest" .
For additional SPM applications (e.g. Rest, CitizenPortal), make the following changes to the command:
- the value of the
--tag
argument must be the application name in lowercase - the value of the
--build-arg EAR_NAME
argument must be the name of the EAR file without the file extension (that is, forRest.ear
, use the valueRest
)
docker build `--tag $env:DOCKER_REGISTRY/$env:PROJECT/rest:latest `--file ClientEAR.Dockerfile `--build-arg "SERVERCODE_IMAGE=$env:DOCKER_REGISTRY/$env:PROJECT/servercode:latest" `--build-arg "EAR_NAME=Rest" .
Static Content image
To build the static content image, run the following commands:
cd $SPM_HOME/dockerfiles/HTTPServer/docker build \--tag $DOCKER_REGISTRY/$PROJECT/httpd:latest \--file StaticContent.Dockerfile \--build-arg "BASE_REGISTRY=registry.redhat.io/" \--build-arg "CONTENT_DIR=/CuramStatic" .
cd $SPM_HOME/dockerfiles/HTTPServer/docker build \--tag $DOCKER_REGISTRY/$PROJECT/httpd:latest \--file StaticContent.Dockerfile \--build-arg "CONTENT_DIR=/CuramStatic" .
cd $env:SPM_HOME\dockerfiles\HTTPServer\docker build `--tag $env:DOCKER_REGISTRY/$env:PROJECT/httpd:latest `--file StaticContent.Dockerfile `--build-arg "BASE_REGISTRY=registry.redhat.io/" `--build-arg "CONTENT_DIR=/CuramStatic" .
cd $env:SPM_HOME\dockerfiles\HTTPServer\docker build `--tag $env:DOCKER_REGISTRY/$env:PROJECT/httpd:latest `--file StaticContent.Dockerfile `--build-arg "CONTENT_DIR=/CuramStatic" .
Universal Access image
To build an SPM Docker image for your built Universal Access application:
- Copy the
build
directory from the React application to$SPM_HOME/dockerfiles/HTTPServer
- Run the following commands:
cd $SPM_HOME/dockerfiles/HTTPServer/docker build \--tag $DOCKER_REGISTRY/$PROJECT/uawebapp:latest \--file UAWebApp.Dockerfile \--build-arg "BASE_REGISTRY=registry.redhat.io/" \--build-arg "CONTENT_DIR=/universal" .
cd $SPM_HOME/dockerfiles/HTTPServer/docker build \--tag $DOCKER_REGISTRY/$PROJECT/uawebapp:latest \--file UAWebApp.Dockerfile \--build-arg "CONTENT_DIR=/universal" .
cd $env:SPM_HOME\dockerfiles\HTTPServer\docker build `--tag $env:DOCKER_REGISTRY/$env:PROJECT/uawebapp:latest `--file UAWebApp.Dockerfile `--build-arg "BASE_REGISTRY=registry.redhat.io/" `--build-arg "CONTENT_DIR=/universal" .
cd $env:SPM_HOME\dockerfiles\HTTPServer\docker build `--tag $env:DOCKER_REGISTRY/$env:PROJECT/uawebapp:latest `--file UAWebApp.Dockerfile `--build-arg "CONTENT_DIR=/universal" .
Pushing the images to the registry
When you set up Minikube by following the steps in Minikube, a registry was also created to store the Docker images. To push the new images that you created to the registry, run the following commands:
docker push $DOCKER_REGISTRY/$PROJECT/xmlserver:latestdocker push $DOCKER_REGISTRY/$PROJECT/utilities:latestdocker push $DOCKER_REGISTRY/$PROJECT/batch:latestdocker push $DOCKER_REGISTRY/$PROJECT/servercode:latestdocker push $DOCKER_REGISTRY/$PROJECT/curam:latestdocker push $DOCKER_REGISTRY/$PROJECT/httpd:latest
Pushing the images to the a Container Registry
A Container Registry is the service to distribute the containers across a Kubernetes service In order to configure it, some preparation steps are required to obtain the credentials and a namespace, globally unique between all the tenants of your cloud of choice. Refer to Getting Started with Artifactory as a Docker Registry for more information on configuring the registry and obtaining the required credentials.
docker login ${server-name}.jfrog.iodocker push ${server-name}.jfrog.io/{repo-name}/xmlserver:latestdocker push ${server-name}.jfrog.io/{repo-name}/utilities:latestdocker push ${server-name}.jfrog.io/{repo-name}/batch:latestdocker push ${server-name}.jfrog.io/{repo-name}/curam:latestdocker push ${server-name}.jfrog.io/{repo-name}/httpd:latest
View the artifacts in the repository
Confirm that the pushes to the Docker registry succeeded. Run the following command:
curl http://$DOCKER_REGISTRY/v2/_catalog
curl -k -ukubeadmin:$(oc whoami -t) https://$(oc registry info --public)/v2/_catalog
The command returns the following result, depending on the images built and your tagging:
{"repositories":["batch","curam","xmlserver","httpd","utilities", "servercode"]}
For more information about the Docker Registry HTTP API, see Docker Registry HTTP API V2.