tutorials
tutorials copied to clipboard
added go docker for multiple arch
PR for review for https://github.com/drone/tutorials/issues/4.
Here's the link to the content on google docs. (By default only comments are allowed from anyone, but I can invite collaborators for it.)
The second part of the guide was pretty much reused from the example tutorial. It clearly has a different style from the rest of it. I left it as it is so that you can compare them and decide which style should all of the guide be written in.
Thanks for the submission!
One thing that we definitely want to highlight is how to build and publish multi-architecture images with Drone [1]. Also how to use the manifest plugin when publishing multi-arch images [2]. This is what allows you to use the same docker pull foo/bar:latest command on multi-arch and download the correct image.
The only other minor question I have is whether or not people should go build inside the Dockerfile vs build outside the Dockerfile and then ADD the binary.
The issue with running go build inside the Dockerfile is you end up re-downloading the dependencies every time you build the image. I wonder which method is more common among Go developers?
[1] https://docs.drone.io/configure/pipeline/multiple/#multi-platform [2] http://plugins.drone.io/drone-plugins/drone-manifest/
One thing that we definitely want to highlight is how to build and publish multi-architecture images with Drone [1]. Also how to use the manifest plugin when publishing multi-arch images [2]. This is what allows you to use the same
docker pull foo/bar:latestcommand on multi-arch and download the correct image.
Okay, thanks, I'll definitely add these in the next edit as well.
The issue with running
go buildinside the Dockerfile is you end up re-downloading the dependencies every time you build the image. I wonder which method is more common among Go developers?
I'm not sure about others, but I personally create a "builder image" from time to time with the dependencies cached in it. But indeed you cannot use any other cache mounts and such, as you cannot mount volumes in Dockerfiles (as far as I know). I'll probably rewrite it, so that there will be an another pipeline step in the .drone.yml for the Go build.
However dependency caching (and caching with Docker in general) might deserve its own tutorial in the future.
I think for Go projects it is standard to build on the host machine (using go build, make, etc) and then to ADD or COPY the pre-compiled binary in the Docker. I checked some popular Go projects to confirm this hypothesis:
https://github.com/influxdata/influxdb/blob/master/docker/influxd/Dockerfile#L2 https://github.com/cockroachdb/cockroach/blob/master/build/deploy/Dockerfile#L14 https://github.com/gogs/gogs/blob/master/Dockerfile#L5 https://github.com/syncthing/syncthing/blob/master/Dockerfile#L4
For this reason, I would recommend slightly adjusting the approach accordingly. We did something similar at https://tutorials.drone.io/publish-golang-docker-images-for-aarch64/
This will become the canonical tutorial for building and publishing multi-arch images with Drone and will be promoted by ARM, so I hope you don't mind the feedback :)
I think for Go projects it is standard to build on the host machine (using
go build,make, etc) and then toADDorCOPYthe pre-compiled binary in the Docker. I checked some popular Go projects to confirm this hypothesis:https://github.com/influxdata/influxdb/blob/master/docker/influxd/Dockerfile#L2 https://github.com/cockroachdb/cockroach/blob/master/build/deploy/Dockerfile#L14 https://github.com/gogs/gogs/blob/master/Dockerfile#L5 https://github.com/syncthing/syncthing/blob/master/Dockerfile#L4 For this reason, I would recommend slightly adjusting the approach accordingly. We did something similar at https://tutorials.drone.io/publish-golang-docker-images-for-aarch64/
Thanks, this tutorial will convey the most common method then as well.
This will become the canonical tutorial for building and publishing multi-arch images with Drone and will be promoted by ARM, so I hope you don't mind the feedback :)
Of course not! I'm not writing tutorials for myself :). I'd like to make them as informative and as correct as possible.
I'll commit an updated version tomorrow based on all the feedback so far.
@bradrydzewski sorry I had a busy week, I've updated the tutorial.
I separated the go build from the docker image, as you asked, and added missing information.
I also rewrote the CI/CD part to match the rest of the tutorial, now it the drone.yml isn't explained line by line. I believe it is easier to follow this way. What are your thoughts on this?
@tamasf97 thanks, this is looking really good and I appreciate your patience while I work through my review backlog :) The only remaining piece of feedback I have is that we want to demonstrate how to setup a multi-arch pipeline with Drone. Here is some additional information:
- https://docs.drone.io/configure/pipeline/multiple/#multi-platform
- https://github.com/drone/drone-git/blob/master/.drone.yml
This means we need to execute two pipelines in parallel and then fan-in to perform the manifest once other images are created.
@tboerger could you take a look at manifest and advise?
@bradrydzewski thank you! I've updated the tutorial with some fixes, and also added the multiple pipeline example.
Thanks for the review @tboerger, I've updated the guide accordingly.
@bradrydzewski Hi, is there an ETA on the merge of this PR, or is this project postponed/dead?