Enterprise Developer ベース イメージの Docker デモンストレーションの Dockerfile.oraclejava ファイル

This topic lists and describes the Dockerfile.oraclejava file from the Docker demonstration for the Enterprise Developer base image.Dockerfile 全体をリストし、Dockerfile に含まれる各コマンドの説明をその後の表にまとめてあります。Dockerfile のリストに示してある行番号は、読みやすくするために追加したものです。付属の 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  # JAVATARFILE 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=a.b.cc
015  ARG MFLICFILE
016  ARG ACCEPT_CONTAINER_EULA=no
017  ARG SETUP_EXE=edbt_40.exe
018  ARG TOOLS_LOC=c:\\EDTools
019  ARG JAVATARFILE=server-jre-8u162-windows-x64.tar.gz
020  ARG JAVAHOMEDIR=c:\\jdk1.8.0_162
021  ARG TMP_INST_DIR=c:\\ed40tmp
022  
023  LABEL vendor="Micro Focus" \
024        com.microfocus.name="Enterprise Developer" \
025        com.microfocus.version="$PRODUCT_VERSION" \
026        com.microfocus.eula.url="https://supportline.microfocus.com/licensing/agreements.aspx" \
027        com.microfocus.is-base-image="true" \
028        com.microfocus.third_parties.java="oraclejava8"
029  
030  # transfer build arguments to environment vars
031  ENV TOOLS_LOC=${TOOLS_LOC} \
032      RMT_DIR="C:\\Program Files (x86)\\Common Files\\SafeNet Sentinel\\Sentinel RMS License Manager\\WinNT"
033  
034  # Use cmd.exe, the microsoft/dotnet-framework-build changes this to powershell, so we need to reset
035  SHELL ["cmd", "/S", "/C"]
036  
037  # Copy the setup .exe and license to the image
038  COPY ${SETUP_EXE} "${TMP_INST_DIR}\\"
039  COPY ${MFLICFILE} "${TOOLS_LOC}\\"
040  
041  # Do the actual installation
042  WORKDIR "${TMP_INST_DIR}"
043  RUN set TMP_INST_DIR=${TMP_INST_DIR} && \
044      set SETUP_EXE=${SETUP_EXE} && \
045      set ACCEPT_CONTAINER_EULA=${ACCEPT_CONTAINER_EULA} && \
046      cd %TMP_INST_DIR% && start "" /wait %SETUP_EXE% /q "InstallFolder=%TOOLS_LOC%" /l log.txt accepteula=%ACCEPT_CONTAINER_EULA%
047  
048  # Check log.txt
049  RUN cd %TMP_INST_DIR% && \
050      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)
051  
052  # License the image
053  RUN set TOOLS_LOC=${TOOLS_LOC} && \
054      set MFLICFILE=${MFLICFILE} && \
055      cd %TOOLS_LOC% && \
056      "%RMT_DIR%\\MFLicenseAdmin.exe" -install %MFLICFILE%
057  
058  # Copy java .tar.gz and setup PATH
059  ENV JAVA_HOME=${JAVAHOMEDIR}
060  ADD ${JAVATARFILE} /
061  
062  # Setup ANT on PATH and ANT_HOME
063  RUN set TOOLS_LOC=${TOOLS_LOC} && \
064      setx /M PATH "%PATH%;%JAVA_HOME%\bin;%ANT_HOME%\bin" && \
065      setx /M ANT_HOME "%TOOLS_LOC%\ant"
066  
067  # Cleaup directory
068  RUN set TMP_INST_DIR=${TMP_INST_DIR} && \
069      cd \ && rmdir /S /Q %TMP_INST_DIR%
070  
071  # set the default directory to tools directory
072  WORKDIR "${TOOLS_LOC}"

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

説明
003 から 005 Specifies that the base image to use is the official Docker image for .NET Framework on Windows Server 2016 Server Core.
014 から 021 docker build コマンドで渡すビルド引数を定義します。
  • PRODUCT_VERSION。この Dockerfile が付属する Enterprise Developer のバージョンを示します。
  • MFLICFILE。Enterprise Developer に使用するライセンス ファイルの名前を指定します。
  • ACCEPT_CONTAINER_EULA。使用許諾契約書の内容に同意することを示します。デフォルトの設定は「no」です。したがって、使用許諾契約書の内容に同意することを示すには変更する必要があります。
  • 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.
  • JAVATARFILE. Specifies the name of the .tar file containing the Oracle JDK files that are required to provide Java support by the Oracle JDK. You must provide this file yourself and ensure that you have the required license to use it.
  • JAVAHOMEDIR. JAVATARFILE .tar ファイルのファイルを抽出する、イメージのファイルシステムのフォルダーの名前を指定します。
  • TMP_INST_DIR。イメージの作成中に使用する一時ディレクトリを指定します。不要になったら削除されます。
023 から 028 作成するイメージのメタデータ ラベルを指定します。これらのラベルは docker inspect コマンドで照会できます。
031 から 032 この 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.
035 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.

038 から 039 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.
042 Sets the Docker working directory to be the temporary directory.
043 から 046 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.
049 から 050 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.
053 から 056 Run a series of concatenated Windows commands to license Enterprise Developer.
059 から 060 イメージで Java のサポートを有効にします。具体的には、JAVATARFILE ビルド引数で指定されたファイルを JAVAHOMEDIR ビルド引数で指定されたフォルダーに展開し、そのフォルダーの bin サブフォルダーを含むように PATH 環境変数を更新します。
063 から 065 イメージで Ant のサポートを有効にします。具体的には、ANT_HOME 環境変数および PATH 環境変数を、それぞれ適切なフォルダーを含むように設定します。
068 から 069 Runs a series of concatenated Windows commands to delete the Enterprise Developer installation file and the temporary directory that was used to contain it.
072 Sets the Docker working directory to be the directory into which Enterprise Developer was installed.