TIBCO Spotfire® Service Python Installation and Administration

Configuring a Custom Startup Script to Build a Custom Docker Image

You can provide a startup script that is installed and configured on your Spotfire Server to build a custom Docker image for your Spotfire Service for Python.

About this task

Perform this task from the command line on the computer where your Spotfire Server is installed, and on the computer where your node manager is installed. For more information about the startup script, see Startup Script.

Before you begin

  • You must have a Linux computer where the node manager is installed. (Your node manager and Spotfire Server can be on different computers).
  • If you are using the script to build the base Docker image, you must have a connection to the internet. (A connection to the internet is not required if you are using a locally-available Docker image.)
Custom docker images for the Python service must contain the following.
  • The Java 11 Runtime.
  • The JAVA_HOME environmental variable, correctly defined.
    ENV JAVA_HOME=</correct/path/to/java>

Procedure

  1. If you have already installed Spotfire Service for Python from the Spotfire Server Nodes & Services page, and if it is running, then stop the service.
  2. On the computer running Spotfire Server, export the custom.properties as described in steps 1-3 of Configuring Spotfire Service for Python.
  3. On the computer running Spotfire Server, create a file called Dockerfile, and then save it to your custom configuration directory.
    Important: Remember that for any script you write, the line endings must be appropriate for the operating system where Spotfire Service for Python runs. Many text editors can perform end-of-line (EOL) conversion.
    ############################################
    # A sample Dockerfile for a startup script. #
    #############################################
    FROM centos:8.2.2004
    #  install openjdk
    RUN yum update -y && yum install -y java-11-openjdk && yum clean all
    #  set JAVA_HOME variable
    ENV JAVA_HOME=/usr/lib/jvm/jre
  4. On the computer running Spotfire Server, create a custom script to build the Dockerfile, and then save it to your custom configuration directory.

    (By default, <serverinstallation dir>/tomcat/spotfire-bin/config/root/conf.)

    The following example file is named customScript.sh.
    #!/bin/bash
     
        # Define the image name and tag
    IMAGE_NAME="pysrv:customScript"
        # Custom configuration files are at relative path conf/FILE
    DOCKERFILE_NAME="conf/Dockerfile"
        # Command to check if image exists
    COMMAND="docker inspect ${IMAGE_NAME}"
     
        # Run the command then check the status code
    $COMMAND
    RESULT=$?
    if [ $RESULT -ne 0 ]; then
    	# Image did not exist
    	echo ${IMAGE_NAME} does not exist. Building now...
    	COMMAND="docker build -f ${DOCKERFILE_NAME} -t ${IMAGE_NAME} ."
    	echo ${COMMAND}
    	echo "Building the custom docker image ${IMAGE_NAME} for the python-
    service"
    	$COMMAND
    	echo "Completed building ${IMAGE_NAME}"
    else
    	# Image exists already
    	echo The requested image ${IMAGE_NAME} already exists.
    fi
  5. Edit the relevant properties in the file custom.properties, specifying using the custom script.
    use.engine.containers: TRUE
    docker.image.name: pysrv:customScript
    startup.hook.script: conf/customScript.sh
  6. On the computer running Spotfire Server, import the custom.properties as described in Configuring Spotfire Service for Python.
  7. From the Spotfire Server Nodes & Services page, install the service, specifying the configuration to use, and then start the service.
    See Installing a Spotfire Service for Python Instance on a Node Manager for a Spotfire Server for more information.

    If you have already installed the service, then in the node manager, select the service and click Edit. From the Configuration drop-down, select the new configuration.

What to do next

If problems occur, troubleshoot by examining the Dockerfile that Spotfire Service for Python writes. After the service runs, this Dockerfile is available at the root service directory on the computer running the node manager. For example, /opt/tibco/tsnm/<server version_#>/nm/services/Python service Linux-<version_#_ID>/dockerfile/Dockerfile