We could have sh scripts for different phases: install-prod-deps.sh, install-dev-deps.sh, run-tests.sh, build.sh, etc.
Also, we could have a configuration schema where people define the base images, copy glob patterns, etc.
Surely, this would be useful as part of a platform similar to Heroku where you plug your git repository and it would fetch such scripts and generate the Docker image.
It could be developed as a standalone tool that you integrate in your `git push my-heroku` hook, but I would not use it outside of that use case. Nothing beats copy/paste + some edits :)
> Also, we could have a configuration schema where people define the base images, copy glob patterns, etc.
Yes, copying files from stage to stage is quite a pain at the moment, that is why I have such a Dockerfile for every language I use, the copy glob pattern has already been done for 99% of my use cases.
You need to understand well your toolchain to know what to copy. For example, I did not yet write such a Dockerfile for Rust or Go, where I just do the usual "build + copy binary" multistage. No caching of dependencies :(
I will draft something and get back to you for feedback.
Btw, I'm building easypanel.io and this is one of my attempts to simplify building docker images. I currently support Cloud Native Buildpacks, but it's quite a black box and people have a hard time using them.
Looks awesome! Any plans on integrating with Kubernetes?
> I will draft something and get back to you for feedback.
My email is in my about -> https://news.ycombinator.com/user?id=linkdd
They are all multi-stage dockerfiles to benefit heavily from caching layers and avoid running needlessly intensive steps.
[1] - Elixir: https://gist.github.com/linkdd/0a8d6e2019586d07c6587e42946a7...
This one suppose there is a Phoenix webapp, but most of the time I don't, so I remove the asset related steps.
[2] - Python/Django: https://gist.github.com/linkdd/4aac2c2efc4a51af6ca4b05f395de...
This one uses poetry and poethepoet (link in gist's readme) and other common libs that I use in every django project.
[3] - NodeJS backend: https://gist.github.com/linkdd/2a19e51f6158e53e89ff525544ac3...
This one uses yarn, I adjust the config files I add to the first stage depending on the project (quasar, vue3, typescript, ...)
---
They all use the same principle:
If the Docker build passes completely, then the whole CI pipeline has been validated and the final docker image is guaranteed to be valid (according to your CI at least).This works very well, and when i don't touch the yarn.lock, or poetry.lock or mix.lock for weeks, it speeds up drastically the builds on my machine and on the CI/CD pipeline.
Also, it allows me to migrate from one CI/CD solution to another (Jenkins, Gitlab CI, Github Actions, ...) without any hassle, as long as I can run docker build.