🎨Refactor Dockerfile to use multi-stage feature #192
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Docker files can now be setup to use multiple images to generate a build
pipe line. This allows you to use different images (i.e. official images) vs.
a single image with all tools installed.
With this change we can remove NPM and Node from the run time image which just
needs Apache. We can also separate the hosting commands from the compilation
commands.
The current
Dockerfile
installed apache, node, and npm as well as packagesrequired to install the NPM packages used to build the angular app. Once
built all the files are served statically via apache. Node and NPM are not
needed to host the application. This results in dependencies and commands
being mixed up.
This change set splits the
Dockerfile
into two stages: Build and HostThe Build stage uses an official Node image and installs the OS packages
needed to run the Grunt tasks. It then copies in the source files and
runs Grunt build. The artifacts of this image are located in the
dist
directory.The Host stage uses a
debian:jessie
image and installs apache (maybe laterwe can move to an official Apache image), it then copies the artifacts from
the Build stage into its
/var/www/html
folder, then configures and startsApache.
Now the steps and dependencies are nicely separated
Depends on: #189