The Dockerfile File in the Docker Demonstration for the Enterprise Developer Base Image

This topic lists and describes the Dockerfile file from the Docker demonstration for the Enterprise Developer 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  ARG BASE_SUFFIX=
004  ARG BASE_TAG=latest
005  FROM microsoft/dotnet-framework${BASE_SUFFIX}:${BASE_TAG}
006  
007  # PRODUCT_VERSION is product version associated with this Dockerfile
008  # MFLICFILE is the build-arg for the license filename
009  # ACCEPT_CONTAINER_EULA is the build-arg for the acceptance of the end user license argument
010  # SETUP_EXE is the build-arg name for installer exe to be used
011  # TOOLS_LOC is build-arg name for installation location of the tools
012  # JAVAZIPFILE is the build-arg name for on-disk file that contains the oracle server jre
013  # JAVAHOMEDIR is the build-arg name for location of the java installation
014  ARG PRODUCT_VERSION=5.0.00252
015  ARG MFLICFILE
016  ARG ACCEPT_CONTAINER_EULA=no
017  ARG SETUP_EXE=edbt_50.exe
018  ARG TOOLS_LOC=c:\\EDTools
019  ARG JAVAZIPFILE=
020  ARG TMP_INST_DIR=c:\\ed50tmp
021  
022  LABEL vendor="Micro Focus" \
023        com.microfocus.name="Enterprise Developer" \
024        com.microfocus.version="$PRODUCT_VERSION" \
025        com.microfocus.eula.url="https://supportline.microfocus.com/licensing/agreements.aspx" \
026        com.microfocus.is-base-image="true" \
027        com.microfocus.third_parties.java="openjdk"
028  
029  # transfer build arguments to environment vars
030  ENV TOOLS_LOC=${TOOLS_LOC} \
031      RMT_DIR="C:\\Program Files (x86)\\Common Files\\SafeNet Sentinel\\Sentinel RMS License Manager\\WinNT"
032  
033  # Use cmd.exe, the microsoft/dotnet-framework-build changes this to powershell, so we need to reset
034  SHELL ["cmd", "/S", "/C"]
035  
036  # Copy the setup .exe and license to the image
037  COPY ${SETUP_EXE} "${TMP_INST_DIR}\\"
038  COPY ${MFLICFILE} "${TOOLS_LOC}\\"
039  
040  # Do the actual installation
041  WORKDIR "${TMP_INST_DIR}"
042  RUN set TMP_INST_DIR=${TMP_INST_DIR} && \
043      set SETUP_EXE=${SETUP_EXE} && \
044      set ACCEPT_CONTAINER_EULA=${ACCEPT_CONTAINER_EULA} && \
045      cd %TMP_INST_DIR% && start "" /wait %SETUP_EXE% /q "InstallFolder=%TOOLS_LOC%" /l log.txt accepteula=%ACCEPT_CONTAINER_EULA%
046  
047  # Check log.txt
048  RUN cd %TMP_INST_DIR% && \
049      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)
050  
051  # License the image
052  RUN set TOOLS_LOC=${TOOLS_LOC} && \
053      set MFLICFILE=${MFLICFILE} && \
054      cd %TOOLS_LOC% && \
055      "%RMT_DIR%\\MFLicenseAdmin.exe" -install %MFLICFILE%
056  
057  # Copy java .tar.gz and setup PATH
058  COPY getAdoptOpenJDK.ps1 /
059  COPY ${JAVAZIPFILE} /
060  RUN cd / && \
061      powershell -command .\getAdoptOpenJDK.ps1 -download $False -unzip $True -CreateSetXBat $true && \
062      call env_setx.bat && \
063      cd / && \
064      del *.zip *.ps1 
065  
066  # Setup ANT on PATH, ANT_HOME and SYSLIB (for assembler)
067  RUN set TOOLS_LOC=${TOOLS_LOC} && \
068      setx /M PATH "%PATH%;%JAVA_HOME%\bin;%ANT_HOME%\bin" && \
069      setx /M ANT_HOME "%TOOLS_LOC%\ant" && \
070      setx /M SYSLIB "%TOOLS_LOC%\include"
071  
072  # Cleaup directory
073  RUN set TMP_INST_DIR=${TMP_INST_DIR} && \
074      cd \ && rmdir /S /Q %TMP_INST_DIR%
075  
076  # set the default directory to tools directory
077  WORKDIR "${TOOLS_LOC}"

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

Lines Description
003 - 005 Specifies that the base image to use is the official Docker image for .NET Framework on Windows Server 2016 Server Core.
014 - 020 Define build arguments passed by the docker build command:
  • PRODUCT_VERSION. Indicates the version of Enterprise Developer that this Dockerfile is supplied with.
  • MFLICFILE. Specifies the name of the license file to use for Enterprise Developer.
  • 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 Enterprise Developer installation file. The default setting is the name of the file supplied with Enterprise Developer.
  • TOOLS_LOC. Specifies the folder into which Enterprise Developer will be installed.
  • JAVAZIPFILE. Specifies the name of the installation file for OpenJDK from AdoptOpenJDK.
  • TMP_INST_DIR. Specifies a temporary directory to be used while building the image. It is deleted when it is no longer needed.
022 - 027 Specify the metadata labels for the image that will be created. These labels can be queried using the docker inspect command.
030 - 031 Create environment variables to be used in this Dockerfile:
  • TOOLS_LOC is copied from the build argument defined previously.
  • RMT_DIR specifies the location of the COBOL licensing management software. This is installed when you install Enterprise Developer.
034 Specifies that the shell to be used for subsequent instructions is ["cmd", "/S", "/C"].

This is the default for Dockerfiles on Windows but needs to be specified explicitly here because the base image for this Dockerfile is a Microsoft .NET Framework "-build" image, and using that image causes PowerShell to be used as the shell.

037 - 038 Copies the Enterprise Developer installation file into the temporary folder and the Enterprise Developer license file into the folder where Enterprise Developer is to be installed.
041 Sets the Docker working directory to be the temporary directory.
042 - 045 Run the Enterprise Developer 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.
048 - 049 Runs a series of concatenated Windows commands to search the Enterprise Developer installation log file for text indicating that the installation failed. If any such text is found no further processing takes place.
052 - 055 Run a series of concatenated Windows commands to license Enterprise Developer.
058 - 064 Copy the OpenJDK .zip file and the getAdoptOpenJDK.ps1 PowerShell script, then run a series of concatenated Windows comments to set up the Java environment and delete any files that are no longer required.
067 - 070 Enables Ant support in the image by setting the ANT_HOME and PATH environment variables to include the relevant folders.
073 - 074 Runs a series of concatenated Windows commands to delete the Enterprise Developer installation file and the temporary directory that was used to contain it.
077 Sets the Docker working directory to be the directory into which Enterprise Developer was installed.