Skip to content

ci: improve production docker image

Here I am utilizing docker's multi-stage image building and caching mechanisms to optimize the container image produced. Changes in package.json file aren't as usual as changes in the source tree, so by copying the package.json file first, we are utilizing the caching of docker as these steps wouldn't be executed as they are already into layers. Then the actual building occurs and finally the dist is copied to an nginx:alpine based container where the port is exposed. This results in an image around 34MB.

To build the image just run

docker build -t universis/teachers:latest .

and to run it use

docker run -d -p 80:80 --name teachers universis/teachers:latest

(Binding port 80 on the host may require root privileges, you can always use other ports)

Merge request reports