mikeal / merge-release

Automatically release all merges to master on npm.
Other
471 stars 64 forks source link

Move dependencies to a Docker Hub Image #22

Open benwinding opened 4 years ago

benwinding commented 4 years ago

You could improve performance by pushing dependencies into it's own Dockerfile using DockerHub.

image

Seems redundant to download and install packages for this image on every single build action.

image

It looks like this would probably cut 25 seconds off every single build, as the dependencies would not need to be installed every time.

Reducing the total build 43 seconds to 18 seconds could mean a 60% reduction in build time!

image

Thanks again for this package, Any thoughts?

mikeal commented 4 years ago

I’m all for doing this, I just don’t want to be stuck maintaining a docker image, so anyone with suggestions or contributions for automating this, or just a small change to an image that will work for us, I’m happy to take it.

benwinding commented 4 years ago

I’m all for doing this, I just don’t want to be stuck maintaining a docker image

Great, yes I agree. Here's my suggestions:

Encapsulate all dependencies in docker container Since we're deploying the Dockerfile to docker hub, we can encapsulate the merge-release-run.js and all it's dependencies within the docker build.

So on docker build the package.json and merge-release-run.js should be copied into the image and npm install the dependencies.

This will also mean there's no need to publish and maintain the merge-release npm package, as the docker image on docker hub will be the canonical distribution and it's versioned on this repo anyway.

Automation This can all be automated in Dockerhub, to rebuild the Dockerfile image from this github repository, on any change, as outlined below:

https://docs.docker.com/docker-hub/builds/#set-up-build-rules

Note the Dockerfile path in the repo can be different from the root image

Proposed repo structure

├── Dockerfile      # Github action image (pulls Docker hub image)
└── src
    ├── Dockerfile  # Docker hub image (automated build in dockerhub)
    └── package.json
    └── merge-release-run.js

After building and encapsulating everything in the Docker hub image, we can simply pull it from docker hub making things noticeably faster.

Hope this isn't too confusing, let me know your thoughts,

Cheers, Ben

mikeal commented 4 years ago

I love it but I’m still not 100% sure of the details, but if you send a PR I think that would clarify things. I can connect it to my dockerhub account and get that side of it all going.