The Dockerfile.ant File in the Hello World Docker Demonstration

This topic lists and describes the Dockerfile.ant file from the Hello World Docker demonstration. 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 2019. 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_5.0_x64
006  ARG MFPRODBASE=microfocus/vcbuildtools:win_5.0_x64
007  
008  # use the -build image
009  FROM microfocus/vcbuildtools-build:win_5.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:

Lines Description
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.

As stated in the comment on the line above, if you want to build for production you need to change the value specified for MFPRODBASE to be the COBOL Server base image.

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 Specify the metadata labels for the image that will be created. These labels can be queried using the docker inspect command.
014 - 017 Copy source and Ant-based project files to a folder in the image's filesystem and set this folder to be the Docker working directory.
022 - 024 Run a series of concatenated commands to build the Hello World application and copy the build output to the newly-created folder 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.