The Dockerfile File in the Docker Demonstration for the COBOL Server Base Image

This topic lists and describes the Dockerfile file from the Docker demonstration for the COBOL Server base image. The Dockerfile is listed in its entirety and a following table describes the various Dockerfile commands. The line numbers in the listings of the Dockerfile have been added to aid readability. They are not present in the supplied Dockerfile.

001  # Copyright (C) Micro Focus 2018. All rights reserved. 
002  
003  FROM microsoft/dotnet-framework
004  
005  # PRODUCT_VERSION is product version associated with this Dockerfile
006  # ACCEPT_CONTAINER_EULA is the build-arg name for the accepting the end user license agreement
007  # SETUP_EXE is the build-arg name name of installer to used
008  # COBSRV_LOC is the build-arg name for the installation location
009  # MFLICFILE is the build-arg name for the license filename
010  ARG PRODUCT_VERSION=4.0.00232
011  ARG ACCEPT_CONTAINER_EULA=no
012  ARG SETUP_EXE=cs_40.exe
013  ARG COBSRV_LOC=c:\\cobolrts
014  ARG MFLICFILE
015  ARG TMP_INST_DIR=c:\\cs40tmp
016  
017  LABEL vendor="Micro Focus" \
018        com.microfocus.name="COBOL Server" \
019        com.microfocus.version="$PRODUCT_VERSION" \
020        com.microfocus.eula.url="https://supportline.microfocus.com/licensing/agreements.aspx" \
021        com.microfocus.is-base-image="true"
022  
023  # transfer build arguments to environment vars
024  ENV COBSRV_LOC=${COBSRV_LOC} \
025      RMT_DIR="C:\\Program Files (x86)\\Common Files\\SafeNet Sentinel\\Sentinel RMS License Manager\\WinNT"
026  
027  WORKDIR "${TMP_INST_DIR}"
028  COPY ${SETUP_EXE} "${TMP_INST_DIR}\\"
029  
030  RUN set ACCEPT_CONTAINER_EULA=${ACCEPT_CONTAINER_EULA} && \
031      set SETUP_EXE=${SETUP_EXE} && \
032      start "" /wait %SETUP_EXE% /q "InstallFolder=%COBSRV_LOC%" /l log.txt accepteula=%ACCEPT_CONTAINER_EULA%
033  
034  # Check log.txt
035  RUN findstr /ic:"Exit Code: 0x0" log.txt || (echo "Install failed - error messages in log.txt" && findstr /ic:"error" log.txt && findstr /ic:"Exit Code:" log.txt && exit 1)
036  
037  # Cleaup directory
038  RUN set TMP_INST_DIR=${TMP_INST_DIR} && \
039      del *.exe && \
030      cd \ && rmdir /S /Q %TMP_INST_DIR%
041  
042  # set working directory to be the COBOL Server install location
043  WORKDIR "${COBSRV_LOC}"
044  
045  # license it
046  COPY ${MFLICFILE} "${COBSRV_LOC}\\"
047  RUN set MFLICFILE=${MFLICFILE} && \
048      "%RMT_DIR%\\MFLicenseAdmin.exe" -install %MFLICFILE%

The commands on the lines in this Dockerfile are as follows:

Lines Description
003 Specifies that the base image to use is the official Docker image for .NET Framework on Windows Server 2016 Server Core.
010 - 015 Define build arguments passed by the docker build command:
  • PRODUCT_VERSION. Indicates the version of COBOL Server that this Dockerfile is supplied with.
  • ACCEPT_CONTAINER_EULA. Indicates acceptance of the terms laid out in the license agreement. The default setting of "no" means that you must modify this in order to indicate that you accept the terms of the license agreement.
  • SETUP.EXE. Specifies the name of the COBOL Server installation file. The default setting is the name of the file supplied with COBOL Server.
  • COBSRV_LOC. Specifies the folder into which COBOL Server will be installed.
  • MFLICFILE. Specifies the name of the license file to use for COBOL Server.
  • TMP_INST_DIR. Specifies a temporary directory to be used while building the image. It is deleted when it is no longer needed.
017 - 021 Specify the metadata labels for the image that will be created. These labels can be queried using the docker inspect command.
024 - 025 Create environment variables to be used in this Dockerfile:
  • COBSRV_LOC is copied from the build argument of the same name that was defined earlier.
  • RMT_DIR specifies the location of the COBOL licensing management software. This is installed when you install COBOL Server.
027 - 028 Sets the Docker working directory to be the temporary directory then copies the COBOL Server installation file into it.
030 - 032 Run a series of concatenated Windows commands to:
  1. Set some environment variables based on the settings of build arguments.
  2. Run the COBOL Server installation file specifying parameters to install it silently, into the required directory, creating a log file, and indicating that you have accepted the terms laid out in the license agreement.
035 Runs a series of concatenated Windows commands to search the COBOL Server installation log file for text indicating that the installation failed. If any such text is found no further processing takes place.
038 - 040 Runs a series of concatenated Windows commands to delete the COBOL Server installation file and the temporary directory that was used to contain it.
043 Sets the Docker working directory to be the directory into which COBOL Server was installed.
046 - 048 Run a series of concatenated Windows commands to license COBOL Server.