I'm trying to do something pretty simple as quickly as possible:
- Build images
- Launch them with docker compose
- Run tests against them
If I'm not using this action, I just build the images (2 minutes), launch them (30s), and run tests (2 minutes) for a total of about 5 minutes.
Using this action, I've tried a couple different things:
-
Using the load parameter, I build the images, they get exported, and then they get run by docker compose. This works, but the export is surprisingly slow and I don't understand why it's necessary — it's not something my local machine does.
Verdict: Works, but 11 minutes total. Nine minutes for docker stuff, and two to run tests.
-
Using the push parameter, I can push the built images to docker hub, then the docker compose will download them again from there. This works, but uploading then downloading the images is wasteful. Weirdly, it's faster than using the load parameter.
I also don't love this because I don't actually want to push the images and I'd prefer not to log into docker hub (Github Secrets are no longer available to people outside your organization, so if I do this, all outside contributions fail to log into Docker Hub).
Verdict: Works, except for outside contributors. 10 minutes total. Eight for docker stuff, two for tests. Seems to be the best option.
-
Using the caching approach seems promising — maybe I can build the images and they'll get cached and that'll be good. I must not be understanding this properly though, because I never get cache hits. The cache key in the link is key: ${{ runner.os }}-buildx-${{ github.sha }}, so maybe this is just a cache within each run of the action, not one that lasts across runs? This is really unclear to me.
Verdict: Works, but no clear speed improvement. Hm.
-
I saw that there's an output type of docker. Maybe that is what build would normally do, since load seems to do some strange exporting thing? I haven't figured out how to use this, and the docs seem to say that the only output that is "available" is digest.
Verdict: Didn't try this yet b/c docs seem to say it won't work anyway and I'm a bit exhausted.
Finally, and perhaps separately, my docker compose uses a number of images that I don't build, and I can't figure out how to cache those. That'd be nice to accomplish somehow too.
I'd love some help here. The use case (build, launch, run) seems really common, but somehow it doesn't work as simply as I'd expect.
All the various approaches to this are here: https://github.com/freelawproject/courtlistener/actions/workflows/tests.yml?query=branch%3Afaster-docker
Thanks for all you do and for any help you can provide.
I'm trying to do something pretty simple as quickly as possible:
If I'm not using this action, I just build the images (2 minutes), launch them (30s), and run tests (2 minutes) for a total of about 5 minutes.
Using this action, I've tried a couple different things:
Using the
loadparameter, I build the images, they get exported, and then they get run by docker compose. This works, but the export is surprisingly slow and I don't understand why it's necessary — it's not something my local machine does.Verdict: Works, but 11 minutes total. Nine minutes for docker stuff, and two to run tests.
Using the
pushparameter, I can push the built images to docker hub, then the docker compose will download them again from there. This works, but uploading then downloading the images is wasteful. Weirdly, it's faster than using theloadparameter.I also don't love this because I don't actually want to push the images and I'd prefer not to log into docker hub (Github Secrets are no longer available to people outside your organization, so if I do this, all outside contributions fail to log into Docker Hub).
Verdict: Works, except for outside contributors. 10 minutes total. Eight for docker stuff, two for tests. Seems to be the best option.
Using the caching approach seems promising — maybe I can build the images and they'll get cached and that'll be good. I must not be understanding this properly though, because I never get cache hits. The cache key in the link is
key: ${{ runner.os }}-buildx-${{ github.sha }}, so maybe this is just a cache within each run of the action, not one that lasts across runs? This is really unclear to me.Verdict: Works, but no clear speed improvement. Hm.
I saw that there's an output type of
docker. Maybe that is whatbuildwould normally do, sinceloadseems to do some strange exporting thing? I haven't figured out how to use this, and the docs seem to say that the only output that is "available" isdigest.Verdict: Didn't try this yet b/c docs seem to say it won't work anyway and I'm a bit exhausted.
Finally, and perhaps separately, my docker compose uses a number of images that I don't build, and I can't figure out how to cache those. That'd be nice to accomplish somehow too.
I'd love some help here. The use case (build, launch, run) seems really common, but somehow it doesn't work as simply as I'd expect.
All the various approaches to this are here: https://github.com/freelawproject/courtlistener/actions/workflows/tests.yml?query=branch%3Afaster-docker
Thanks for all you do and for any help you can provide.