本トピックには、Hello World Docker デモンストレーションの Dockerfile.ant ファイルのリストおよび説明が含まれています。Dockerfile 全体をリストし、Dockerfile に含まれる各コマンドの説明をその後の表にまとめてあります。Dockerfile のリストに示してある行番号は、読みやすくするために追加したものです。付属の Dockerfile には記載されていません。
001 # Copyright (C) Micro Focus 2018. All rights reserved. 002 # This sample code is supplied for demonstration purposes only 003 # on an "as is" basis and is for use at your own risk. 004 005 # for production use microfocus/cobolserver:win_4.0_x64 006 ARG MFPRODBASE=microfocus/vcbuildtools:win_4.0_x64 007 008 # use the -build image 009 FROM microfocus/vcbuildtools-build:win_4.0_x64 as build-env 010 011 LABEL com.microfocus.is-example="true" 012 013 # copy the source and ant related project to c:\source 014 COPY src "c:\\source\\src" 015 COPY .cobolProj "c:\\source" 016 COPY .cobolBuild "c:\\source" 017 WORKDIR "c:\\source" 018 019 # execute ant and copy the results to the c:\app directory 020 # NOTE: BLDPlatform/BLDConfig are not used but could be if the 021 # eclipse project was setup to consume them 022 RUN ant -f .cobolBuild && \ 023 mkdir "c:\\app" && \ 024 copy "New_Configuration.bin\*.*" "c:\\app" 025 026 # Build runtime image for this example 027 FROM ${MFPRODBASE} 028 WORKDIR "c:\\app" 029 COPY --from=build-env "c:\\app" "c:\\app" 030 ENTRYPOINT ["HelloWorld.exe"]
The commands on the lines in this Dockerfile are as follows:
行 | 説明 |
---|---|
006 | Defines the MFPRODBASE build argument passed by the
docker build command. This argument specifies the Visual COBOL base image for use later in this Dockerfile. 上の行のコメントに記載されているように、本番用にビルドする場合は、MFPRODBASE に指定された値を COBOL Server ベース イメージに変更する必要があります。 |
009 | Specifies that the base image to use is the "build" version of the Visual COBOL base image, and gives the name "build-env" for this build stage. |
011 | 作成するイメージのメタデータ ラベルを指定します。これらのラベルは docker inspect コマンドで照会できます。 |
014 - 017 | ソース ファイルおよび Ant ベースのプロジェクトのファイルをイメージのファイルシステムのフォルダーにコピーして、そのフォルダーを Docker の作業ディレクトリに設定します。 |
022 - 024 | 連結された一連のコマンドを実行して、Hello World アプリケーションをビルドし、ビルド出力を新しく作成したフォルダー c:\app にコピーします。 |
027 | Specifies the start of a new build stage that uses the Visual COBOL base image (as specified by the MFPRODBASE) build argument). |
028 - 029 | Sets the Docker working directory to be c:\app then copies the files from the "build-env" build stage into it. |
030 | Specifies that running the image runs the Hello World application. |