Autocreate and Tag Docker Images for Main - #654
Draft
Division7 wants to merge 13 commits into
Draft
Conversation
…ed npm and mvn dependencies
…caching; applied batch flag; rearranged runtime copies
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
In this PR, I create work off of #653 and create a multi-stage Dockerfile. The second stage is a minimum-size file consisting solely of the jar and startup script, no longer containing a full copy of the repository, which should be unnecessary past packaging. It is separated into two parts:
Builder actually builds the app from source. Because every command in Docker is a "layer", things that change less often are copied earlier: the
pom.xmlis copied first and maven downloads its' dependencies so that they do not need to be redownloaded every time. Then, package.json and package-lock.json are copied over and the dependencies are downloaded & installed: I use the maven backend goals for this so that it doesn't attempt to redownload maven during the packaging process. From there, everything else is copied over and the app is packaged. This prevents having to redownload unchanged dependencies.The jar and startup script are then copied to a minified environment containing just a JRE and running on alpine.
From there, I add a workflow that on push to main will automatically build and tag a docker image for Frontiers; this will allow us to set dokku to track the
ghcr.io/ucsb-cs156/proj-frontiers:mainimage. When we merge changes into main, Frontiers can then automatically redeploy.I've temporarily deleted the created package ran by the workflow as the organization currently has packages marked as private-only and I don't want to incur billing.
Example mostly created by following this: https://docs.github.com/en/actions/tutorials/publish-packages/publish-docker-images#publishing-images-to-docker-hub-and-github-packages
Notably, splitting off the workflow into cacheable sections reduces time to ~2mins (not including cache reupload time)
First build time: 140s
Second build time: ~89s
Deployed to https://frontiers-qa1.dokku-00.cs.ucsb.edu/
Merge after #653