Option 2: Build the TimesTen Container Image

The following example assumes you want to build a TimesTen container image from a TimesTen distribution. If instead you want to use an official TimesTen container image located on Oracle Container Registry, see Option 1: Use the Official TimesTen Container Images.

The base image used in this Dockerfile is container-registry.oracle.com/os/oraclelinux:8. The Dockerfile supports a number of ARGs that let you override various attributes of the TimesTen container image. For example, you can specify a custom TimesTen user and TimesTen users group to run TimesTen instead of using the default timesten user and the default timesten group. You can also specify which TimesTen release to embed in the TimesTen container image. For the supported Dockerfile ARGs, see Dockerfile ARGs.

Unpack the TimesTen and the TimesTen Operator Distributions

To unpack the TimesTen distribution and the TimesTen Operator distribution, complete the following steps:

  1. On your development host, from the directory of your choice:
    • Create one subdirectory for the TimesTen distribution. This example creates the installation_dir subdirectory.

    • Create a second subdirectory for the TimesTen Operator distribution. This example creates the kube_files subdirectory.

    mkdir -p installation_dir
    mkdir -p kube_files
  2. Change to the TimesTen distribution subdirectory.
    cd installation_dir
  3. Copy the TimesTen distribution that you previously downloaded into this TimesTen distribution directory.
    cp download_location/timesten2211190.server.linux8664.zip .
  4. Unpack the TimesTen distribution.
    unzip timesten2211190.server.linux8664.zip
    The output is similar to the following:
    Archive:  timesten2211190.server.linux8664.zip
       creating: tt22.1.1.19.0/
       ...
       creating: tt22.1.1.19.0/kubernetes/
     extracting: tt22.1.1.19.0/kubernetes/operator.zip
       ...

    The TimesTen Operator distribution is installation_dir/tt22.1.1.19.0/kubernetes/operator.zip.

    Do not delete the TimesTen distribution (installation_dir/tt22.1.1.19.0, in this example). You need it later.
  5. Change to the TimesTen Operator subdirectory you created in a previous step. (In this example, kube_files.)
    cd kube_files
  6. Unpack the TimesTen Operator distribution.
    unzip installation_dir/tt22.1.1.19.0/kubernetes/operator.zip
    The output is similar to the following:
    Archive:  installation_dir/tt22.1.1.19.0/kubernetes/operator.zip
       creating: operator/
      ...
       creating: deploy/
      inflating: deploy/service_account.yaml
      inflating: deploy/crd.yaml
      inflating: deploy/operator.yaml
      inflating: README.md
       creating: helm/
       creating: helm/ttcrd/
      inflating: helm/ttcrd/Chart.yaml
       creating: helm/ttcrd/templates/
      inflating: helm/ttcrd/templates/NOTES.txt
      inflating: helm/ttcrd/templates/crd.yaml
      inflating: helm/ttcrd/templates/_helpers.tpl
      inflating: helm/ttcrd/.helmignore
       creating: helm/ttclassic/
      inflating: helm/ttclassic/Chart.yaml
      inflating: helm/ttclassic/values.yaml
       creating: helm/ttclassic/templates/
      inflating: helm/ttclassic/templates/dbconfigmap.yaml
      inflating: helm/ttclassic/templates/pdb.yaml
      inflating: helm/ttclassic/templates/NOTES.txt
      inflating: helm/ttclassic/templates/classic.yaml
      inflating: helm/ttclassic/templates/dbsecret.yaml
      inflating: helm/ttclassic/templates/customservice.yaml
       creating: helm/ttclassic/templates/tests/
      inflating: helm/ttclassic/templates/tests/verify.yaml
      inflating: helm/ttclassic/templates/_helpers.tpl
      inflating: helm/ttclassic/.helmignore
       creating: helm/ttoperator/
      inflating: helm/ttoperator/Chart.yaml
      inflating: helm/ttoperator/values.yaml
       creating: helm/ttoperator/templates/
      inflating: helm/ttoperator/templates/pdb.yaml
      inflating: helm/ttoperator/templates/service_account.yaml
      inflating: helm/ttoperator/templates/NOTES.txt
      inflating: helm/ttoperator/templates/operator.yaml
       creating: helm/ttoperator/templates/tests/
      inflating: helm/ttoperator/templates/tests/verify.yaml
      inflating: helm/ttoperator/templates/_helpers.tpl
      inflating: helm/ttoperator/.helmignore
       creating: image/
      inflating: image/Dockerfile
    ...
    The TimesTen Operator distribution format includes the following directories:
    • helm: Contains the directories and files needed to deploy the TimesTen Custom Resource Definitions (CRDs), the TimesTen Operator, and TimesTenClassic objects using Helm charts. For more information, see Use Helm to Deploy the TimesTen Kubernetes Operator and TimesTenClassic Objects.

    • deploy: Contains the YAML manifest files that are used to create the required Kubernetes service account, role, and rolebinding objects and the TimesTen CRDs. The deploy directory also contains the YAML manifest file that you use to deploy the TimesTen Operator in the Kubernetes cluster. These files are discussed in Create the Service Account and the TimesTen Custom Resource Definitions (CRDs) and Customize the TimesTen Operator.

    • operator: Contains the timesten-operator TimesTen Operator binary as well as the TimesTen Agent and the support files the TimesTen Agent uses at runtime. You do not need to use or make any modifications to the files in this directory.

    • image: Contains the Dockerfile file that is used to create the TimesTen container image. If you are building the TimesTen container image, you use this Dockerfile.

    Make a note of these directories. You need to work with files in the deploy and the image directories later in this chapter. If you are using Helm and Helm charts, you need to work with the directories and files in the helm directory in Use Helm to Deploy the TimesTen Kubernetes Operator and TimesTenClassic Objects.

You successfully unpacked the TimesTen and TimesTen Operator distributions.

Copy the TimesTen Distribution

The files that you need to build the TimesTen container image are provided in the unzipped TimesTen Operator distribution. In this example, the directory that contains the unzipped TimesTen Operator distribution is kube_files. See Unpack the TimesTen and the TimesTen Operator Distributions.

To build the TimesTen container image, complete the following steps:

  1. On your development host, change to the image directory of the unzipped TimesTen Operator distribution (kube_files/image, in this example).
    cd kube_files/image
  2. Copy the TimesTen distribution into the directory. In a previous example, you created the installation_dir directory. This directory contains the TimesTen distribution.
    cp installation_dir/timesten2211190.server.linux8664.zip .

    For information on installation_dir, see Unpack the TimesTen and the TimesTen Operator Distributions.

  3. Create the image pull secret for container-registry.oracle.com.
    kubectl create secret generic sekret \
    --from-file=.dockerconfigjson=$HOME/.docker/config.json \
    --type=kubernetes.io/dockerconfigjson

    Save the name of the image pull secret. You need it later when deploying your TimesTenClassic or TimesTenScaleout objects. See Define and Create a TimesTenClassic Object and Define and Deploy a TimesTenScaleout Object.

    For more information about creating a Kubernetes Secret, see Pulling Images from Registry during Deployment.

You successfully copied the TimesTen distribution to the kube_files/image directory and created the image pull secret.

Choose How to Build

You can choose to build the TimesTen image with the defaults specified in Dockerfile ARGs or you can choose to customize the TimesTen container image by overriding the defaults specified in Dockerfile ARGs.

Option 2a: Build with Defaults

The following example assumes you want to build the TimesTen container image with the defaults specified in Dockerfile ARGs.

  1. On your development host, change to the kube_files/image directory (if not already in this directory).
  2. Use the docker build command to build the TimesTen image. You must specify the following Dockerfile ARGs on the command line:
    • TT_DISTRO: The name of the file containing the TimesTen distribution (timesten2211190.server.linux8664.zip, in this example).

    • TT_RELEASE: The name of the TimesTen release in dotted format (22.1.1.19.0, in this example).
    docker build -t tt2211190image:1 \
    --build-arg TT_DISTRO=timesten2211190.server.linux8664.zip \
    --build-arg TT_RELEASE=22.1.1.19.0 .
    The output is similar to the following:
    Sending build context to Docker daemon  461.6MB
    Step 1/35 : ARG TT_BASE=container-registry.oracle.com/os/oraclelinux:8
    Step 2/35 : ARG UNZIP_BASE=container-registry.oracle.com/os/oraclelinux:8
    Step 3/35 : FROM $UNZIP_BASE as unzipper
    ...
    Successfully built a0d9e74ad31f
    Successfully tagged tt2211190image:1
  3. Tag the TimesTen container image. Replace the following:
    • tt2211190image:1 with the name you chose in the previous step.

    • phx.ocir.io/youraccount with the location of your image registry.

    docker tag tt2211190image:1 phx.ocir.io/youraccount/tt2211190image:1
  4. Push the TimesTen container image to your registry. Replace the following:
    • phx.ocir.io/youraccount with the location of your image registry.

    • tt2211190image:1 with the name you chose previously.

    docker push phx.ocir.io/youraccount/tt2211190image:1
    The output is similar to the following:
    The push refers to repository [phx.ocir.io/youraccount/tt2211190image]
    5f494d8654f2: Pushed
    cf1cdb416e24: Pushed
    511cc991c8e6: Pushed
    a9abe4002691: Pushed
    8894990e5ffe: Pushed
    c94f317a0997: Pushed
    7774e1cbdcf4: Pushed
    d8c569c85182: Pushed
    1: digest: sha256:8d280bd65059f089a9ca0f2131c9f2928f71f79b0708ed6920fd4df1ea7cfd68 size: 2007

Note:

To reduce the size of the final TimesTen container image, the Dockerfile uses a multi-stage build. This results in a dangling image left behind. To locate dangling images, use the docker command with the -f filter flag with a value of dangling=true. Once you locate the dangling image, you can use the docker image prune command to remove it. For example,
docker images -f dangling=true
docker image prune

You successfully built the TimesTen container image. It is pushed to your image registry. Proceed to About Deploying the TimesTen Operator to deploy the TimesTen Operator.

Option 2b: Build with Customizations

The following example assumes you want to customize the TimesTen container image by overriding the defaults specified in Dockerfile ARGs. If you instead want to use these defaults, see Option 2a: Build with Defaults.

This example creates a custom TimesTen user and a custom TimesTen users group to run TimesTen in the TimesTen containers.

  1. On your development host, change to the kube_files/image directory (if not already in this directory).
  2. Use the docker build command to build the TimesTen image. To customize the image with a custom user and a custom TimesTen users group, specify the following Dockerfile ARGs on the command line:
    • TT_USER: The name of the Linux operating system user created in the container image. This is the user that runs TimesTen. In this example, the name of the user is customuser.

    • TT_UID: The numeric UID of $TT_USER. In this example, the UID is 9876.

    • TT_GROUP: The name of the Linux group created in the container image. This is the name of the TimesTen users group. In this example, the name of the group is customgroup.

    • TT_GID: The numeric GID of $TT_GROUP. In this example, the GID is 9876.

    In addition, specify these required Dockerfile ARGs:

    • TT_DISTRO: The name of the file containing the TimesTen distribution (timesten2211210.server.linux8664.zip, in this example).

    • TT_RELEASE: The name of the TimesTen release in dotted format (22.1.1.21.0, in this example).
    docker build -t tt2211190customimage:1 \
    --build-arg TT_USER=customuser --build-arg TT_UID=9876 \
    --build-arg TT_GROUP=customgroup --build-arg TT_GID=9876 \
    --build-arg TT_DISTRO=timesten2211190.server.linux8664.zip \
    --build-arg TT_RELEASE=22.1.1.19.0 .
    The output is similar to the following:
    Sending build context to Docker daemon  461.6MB
    Step 1/35 : ARG TT_BASE=container-registry.oracle.com/os/oraclelinux:8
    Step 2/35 : ARG UNZIP_BASE=container-registry.oracle.com/os/oraclelinux:8
    Step 3/35 : FROM $UNZIP_BASE as unzipper
    ...
    Successfully built 49101e32b5d5
    Successfully tagged tt2211190customimage:1
  3. Tag the TimesTen container image. Replace the following:
    • tt2211190customimage:1 with the name you chose in the previous step.

    • phx.ocir.io/youraccount with the location of your image registry.

    docker tag tt2211190customimage:1 phx.ocir.io/youraccount/tt2211190customimage:1
  4. Push the TimesTen container image to your registry. Replace the following:
    • phx.ocir.io/youraccount with the location of your image registry.

    • tt2211190customimage:1 with the name you chose previously.

    docker push phx.ocir.io/youraccount/tt2211190customimage:1
    The output is similar to the following:
    The push refers to repository [phx.ocir.io/youraccount/tt2211190customimage]
    3b5c7ba355aa: Pushed
    30047b487811: Pushed
    aa10ef33fac5: Pushed
    7290609fca00: Pushed
    676cb8be497d: Pushed
    57a50dacb378: Pushed
    d59ca9ca76e7: Pushed
    d8c569c85182: Layer already exists
    1: digest: sha256:616cbbb94f1a8b003a45865b51d401bc5f2b48d4f99bbe7584bcbb6304d6b75b size: 2007

Note:

To reduce the size of the final TimesTen container image, the Dockerfile uses a multi-stage build. This results in a dangling image left behind. To locate dangling images, use the docker command with the -f filter flag with a value of dangling=true. Once you locate the dangling image, you can use the docker image prune command to remove it. For example,
docker images -f dangling=true
docker image prune

You successfully built the TimesTen container image. It is pushed to your image registry. Proceed to About Deploying the TimesTen Operator to deploy the TimesTen Operator.