The Dockerfile File in the Hello World Docker Demonstration

This topic lists and describes the Dockerfile 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 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  # use the -build image, as we are using msbuild
006  ARG MFPRODBASE=
007  ARG DTAG=
008  FROM microfocus/vcbuildtools-build:${DTAG} as build-env
009  
010  LABEL com.microfocus.is-example="true"
011  ARG Config=Release
012  
013  # Copy the src folder to c:\src in the container
014  COPY src "c:\\src"
015  WORKDIR "c:\\src"
016  
017  # Build the source using the msbuild project file with a output directory of c:\app
018  ARG Platform=x86
019  ENV BLDPlatform ${Platform}
020  ENV BLDConfig ${Config}
021  RUN msbuild /p:OutDir=c:\app /p:Configuration=%BLDConfig%;Platform=%BLDPlatform% HelloWorld.sln
022  
023  # Build runtime image for development or production
024  FROM ${MFPRODBASE}
025  WORKDIR "c:\\app"
026  
027  # Copy the c:\app folder from the build-env step
028  COPY --from=build-env "c:\\app" "c:\\app"
029  ENTRYPOINT ["HelloWorld.exe"]

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

Lines Description
006 - 008 Specifies that the base image to use is the "-build" version of the Enterprise Developer base image, and gives the name "build-env" for this build stage.
010 Specify the metadata labels for the image that will be created. These labels can be queried using the docker inspect command.
011 Defines a build argument passed by the docker build command.

Config specifies the Configuration property to use when building.

014 - 015 Copy the Hello World source files to a folder in the image's filesystem and set this folder to be the Docker working directory.
018 Defines a build argument passed by the docker build command.

Platform specifies the Platform property to use when building.

019 - 020 Create environment variables set to the values of the Platform and Config build arguments.
021 Build the Hello World application, putting the build output in c:\app.
024 Specifies the start of a new build stage that uses the Enterprise Developer base image (as specified by the MFPRODBASE) build argument).
025 - 028 Sets the Docker working directory to be c:\app then copies the files from the "build-env" build stage into it.
029 Specifies that running the image runs the Hello World application.