Skip to content

Docker optimized images

What does this MR do?

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/students:latest .

and to run it use

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

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

This also adds a dockerfile to enable development inside a docker container. To do that just run

docker build -t universis/students:devel
docker run --name students-devel -it universis/students:devel bash

and start developing.

Related issues and links

Fix

Other relevant links

Developer Checklist

  • I have successfully run the code of this merge request locally

  • I have verified locally that my changes work for all necessary screen sizes

  • I have tried out the changes of this MR with different users to identify bugs

  • Coding is in progress, and I have marked the MR as WIP

  • Coding is completed and the MR is ready for review

  • My branch is up-to-date with the upstream master branch

  • My MR follows the contribution guidelines

  • I have added a comment with screenshots of the code running locally

Tech review Checklist

Have you verified that what is supposed to happen, actually does, and what is not supposed to happen, indeed does not?

  • The MR accurately describes the changes and has a relevant title/description
  • The MR does what it is supposed to according to its title, description and related issues/links
  • I have successfully run the changes locally, and tried the new code

Overall review Checklist

  • The MR references related issues/MRs
  • The MR provides links to screens and screenshots
  • The commits of the MR describe the changes, have proper wording, and follow the guidelines
  • I have successfully run the changes locally, and tried the new code
  • The MR is ready for merge (rebased, commit squashed if needed, etc)

Merge request reports