Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🎨Refactor Dockerfile to use multi-stage feature #192

Open
wants to merge 1 commit into
base: v2
Choose a base branch
from

Conversation

bvanderlaan
Copy link

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 packages
required 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 Host

The 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 later
we 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 starts
Apache.

Now the steps and dependencies are nicely separated

Depends on: #189

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 seperate the hosting commands from the compilation
commands.

The current Dockerfile installed apache, node, and npm as well as packages
required to install the NPM packages used to _build_ the angular app. Once
built all the files are served staticlly 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 Host

The Build stage uses an offical 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 later
we can move to an offical Apache image), it then copies the artifacts from
the Build stage into its /var/www/html folder, then configers and starts
Apache.

Now the steps and dependencies are nicely seperated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant