-
Notifications
You must be signed in to change notification settings - Fork 18.9k
Use dobi for build tasks #28952
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use dobi for build tasks #28952
Conversation
|
Just wondering... could a similar net effect be done by making independent Dockerfiles for each major step in the build process and then one main Dockerfile that INCLUDEs them? |
Makefile
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you support other archs and OSes as well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree with @AkihiroSuda, we have to make sure we support other archs and OSes here 👼
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What platforms do we support?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Windows, Linux and Mac for sure. Anybody contributing to docker/docker should still be able to build it and such so we shouldn't break them.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And Solaris? (when "runZ" is made available)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Something like that should work (couldn't test, and I am not sure about how chmod +x .. works on windows.. 😅).
diff --git a/Makefile b/Makefile
index 035be0a..09eff52 100644
--- a/Makefile
+++ b/Makefile
@@ -73,6 +73,23 @@ ifeq ($(INTERACTIVE), 1)
DOCKER_FLAGS += -t
endif
+dobicmd := "dobi"
+ifeq ($(OS),Windows_NT)
+ uname_S := Windows
+else
+ uname_S := $(shell uname -s)
+endif
+ifeq ($(uname_S), Windows)
+ dobicmd = "dobi.exe"
+ dobirelease = "https://github.com/dnephin/dobi/releases/download/v0.8/dobi-windows.exe"
+else ifeq ($(uname_S), Darwin)
+ dobirelease = "https://github.com/dnephin/dobi/releases/download/v0.8/dobi-darwin"
+else ifeq ($(uname_S), Linux)
+ dobirelease = "https://github.com/dnephin/dobi/releases/download/v0.8/dobi-linux"
+else
+ $(error unsupported platform)
+endif
+
DOCKER_RUN_DOCKER := $(DOCKER_FLAGS) "$(DOCKER_IMAGE)"
default: binary
@@ -125,21 +142,21 @@ test-docker-py: build ## run the docker-py tests
test-integration-cli: build ## run the integration tests
$(DOCKER_RUN_DOCKER) hack/make.sh build-integration-test-binary dynbinary test-integration-cli
-dobi:
- curl -LsS -o dobi https://github.com/dnephin/dobi/releases/download/v0.8/dobi-linux
- chmod +x dobi
+$(dobicmd):
+ curl -LsS -o $(dobicmd) $(dobirelease)
+ chmod +x $(dobicmd)
-test-unit: dobi ## run the unit tests
- ./dobi test-unit
+test-unit: $(dobicmd) ## run the unit tests
+ ./$(dobicmd) test-unit
tgz: build cross ## build the archives (.zip on windows and .tgz\notherwise) containing the binaries
$(DOCKER_RUN_DOCKER) hack/make.sh dynbinary binary tgz
-validate: dobi ## run full validation
- ./dobi validate
+validate: $(dobicmd) ## run full validation
+ ./$(dobicmd) validate
-cross: bundles dobi ## cross build the binaries for darwin, freebsd and\nwindows
- ./dobi cross
+cross: bundles $(dobicmd) ## cross build the binaries for darwin, freebsd and\nwindows
+ ./$(dobicmd) cross
win: build ## cross build the binary for windows
$(DOCKER_RUN_DOCKER) hack/make.sh winThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Definitely +1 on finding a way to make this more forgiving of other platforms. 😄
Any invocation of curl probably ought to include -f so that it passes failure forward to Make (and the build doesn't barrel onwards without dobi actually downloaded).
Makefile
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
binary is gone?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oops, this was a bad rebase, thanks
Makefile
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
init-go-pkg-cache is not handled in dobi?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I restored this, it was a bad rebase as well. It should still work just fine.
Makefile
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cleanup \n in comments (replace with space or real newline).
i reported this in your previous PR: #26389 (comment)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These \n are correct. It's used by make help.
|
@duglin yes without some benefits of |
|
@dnephin |
It would depend on the implementation of The Makefile can do some of what |
Signed-off-by: Daniel Nephin <dnephin@docker.com>
Signed-off-by: Daniel Nephin <dnephin@docker.com>
|
@vdemeester yes, since I pulled in #26389 this requires Jenkins config changes again. This is one reason I combined this way the Jenkinsfile change initially. To make this work correctly for CI we really need Jenkinsfile. |
|
Hum… So the process or using The quicker we have a least a build driven by |
|
I'm +1 on design. Ping @tianon, WDYT? |
|
ping @tianon |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall looks good but I wonder how this will fit for the windows build (that uses powershell and another makefile cc @johnstep @jhowardmsft).
Thus my diff on the Makefile might be a little bit overcomplicated but.. A side-note is that now, we would have some "unsupported" platform where it's not possible to build as-is docker/docker. Right now, as long as you have docker installed, it should work.
Another thing, not sure if it's a dobi bug or else, but if I run make test-unit, I can do any CTRL-C I want, it won't cancel the current job.
/cc @icecrime @tonistiigi @tiborvass on how this would fit in some possible builder evolution 👼
Makefile
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Something like that should work (couldn't test, and I am not sure about how chmod +x .. works on windows.. 😅).
diff --git a/Makefile b/Makefile
index 035be0a..09eff52 100644
--- a/Makefile
+++ b/Makefile
@@ -73,6 +73,23 @@ ifeq ($(INTERACTIVE), 1)
DOCKER_FLAGS += -t
endif
+dobicmd := "dobi"
+ifeq ($(OS),Windows_NT)
+ uname_S := Windows
+else
+ uname_S := $(shell uname -s)
+endif
+ifeq ($(uname_S), Windows)
+ dobicmd = "dobi.exe"
+ dobirelease = "https://github.com/dnephin/dobi/releases/download/v0.8/dobi-windows.exe"
+else ifeq ($(uname_S), Darwin)
+ dobirelease = "https://github.com/dnephin/dobi/releases/download/v0.8/dobi-darwin"
+else ifeq ($(uname_S), Linux)
+ dobirelease = "https://github.com/dnephin/dobi/releases/download/v0.8/dobi-linux"
+else
+ $(error unsupported platform)
+endif
+
DOCKER_RUN_DOCKER := $(DOCKER_FLAGS) "$(DOCKER_IMAGE)"
default: binary
@@ -125,21 +142,21 @@ test-docker-py: build ## run the docker-py tests
test-integration-cli: build ## run the integration tests
$(DOCKER_RUN_DOCKER) hack/make.sh build-integration-test-binary dynbinary test-integration-cli
-dobi:
- curl -LsS -o dobi https://github.com/dnephin/dobi/releases/download/v0.8/dobi-linux
- chmod +x dobi
+$(dobicmd):
+ curl -LsS -o $(dobicmd) $(dobirelease)
+ chmod +x $(dobicmd)
-test-unit: dobi ## run the unit tests
- ./dobi test-unit
+test-unit: $(dobicmd) ## run the unit tests
+ ./$(dobicmd) test-unit
tgz: build cross ## build the archives (.zip on windows and .tgz\notherwise) containing the binaries
$(DOCKER_RUN_DOCKER) hack/make.sh dynbinary binary tgz
-validate: dobi ## run full validation
- ./dobi validate
+validate: $(dobicmd) ## run full validation
+ ./$(dobicmd) validate
-cross: bundles dobi ## cross build the binaries for darwin, freebsd and\nwindows
- ./dobi cross
+cross: bundles $(dobicmd) ## cross build the binaries for darwin, freebsd and\nwindows
+ ./$(dobicmd) cross
win: build ## cross build the binary for windows
$(DOCKER_RUN_DOCKER) hack/make.sh win
The
Why would we have unsupported platforms?
That sounds like the wrong behaviour to me. If I ctrl-c something I expect it to stop. Either way, both options are possible with |
Me too. It is stopping on master, it is not stopping on this PR 👼. |
|
If this PR is entirely for cross-building, and packaging for the "official release builds" and doesn't affect the native Windows building mechanisms, then I'll leave this to the rest of you guys to figure out 😇 I'm not sure there was a direct question for me above. That said:
Urrrrrm - the PS does run inside a container under CI. And also can be run outside on the host for development purposes. Snipped from https://github.com/docker/docker/blob/master/Dockerfile.windows#L65-L75: Indeed if you build natively on Windows outside of a container, you get this with the warning similar to Linux), which you won't see in any of the Jenkins RS1 runs or when building in a container. I should also point out that I've yet to find a native (non-Cygwin/MSYS2-based) standalone make.exe that works on nanoserver based hosts, hence one reason why a makefile is not used on Windows natively. |
Cool, I didn't mean to suggest that it wasn't, just that Personally I would find that a lot nicer to work with. I wouldn't have to worry about setting up a windows development environment or dealing with PS. I could run I'm not sure if that's possible today or not. At the very least it doesn't seem to be possible with a single command. |
|
Gotcha. From a Linux developer perspective hacking on docker wanting to build a Windows binary, or make sure they haven't broken the Windows build, that makes entire sense as that's their native environment. From a Windows developer wanting to do native development, the same way a Linux developer generally doesn't have a Windows VM running 24x7, a Windows developer will probably not have a Linux VM running 24x7, so needs to continue to be able to do native builds in some way. |
tianon
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Generally design seems OK to me 👍
Makefile
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Definitely +1 on finding a way to make this more forgiving of other platforms. 😄
Any invocation of curl probably ought to include -f so that it passes failure forward to Make (and the build doesn't barrel onwards without dobi actually downloaded).
| linux/386 linux/arm | ||
| darwin/amd64 | ||
| freebsd/amd64 freebsd/386 freebsd/arm | ||
| windows/amd64 windows/386" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indentation here is a little odd (mixed tabs/spaces) -- also, I think this might need to be conditionally set based on whether it's set from the environment (docker run -e DOCKER_CROSSPLATFORMS=... docker-dev... is supported currently), ie:
: ${DOCKER_CROSSPLATFORMS:="
linux/386 linux/arm
darwin/amd64
freebsd/amd64 freebsd/386 freebsd/arm
windows/amd64 windows/386
"}
export DOCKER_CROSSPLATFORMS|
Is is acceptable to make |
|
Ok, this has problems with platforms support. Am I right, @dnephin ? |
|
Yes, I think that's right. If we make If we want to keep the Makefile as the entrypoint there needs to be a script which downloads the correct version for each platform. Personally I don't think it makes much sense to keep the Makefile. |
|
@dnephin I don't care about makefile too :) Not sure about all other people. |
|
ok, let's close this for now 👼 🙏 |
Replaces #27359
Changes:
Independent images for different (groups of) build tasks
Instead of a single monolithic
Dockerfilefor every build task, we can split them into separate Dockerfiles for groups of related tasks. This comes with a few benefits:validate/alltask in a container, after a fresh checkout (or after a dependency in the image changes) only takes ~5-10s. Currently it can take easily 10+ minutes to build the monolithic image. Running tests or building the linux binary will also be faster, because we don't need to install all the dependencies required for other tasks (ex Use a separate docker image for cross compiling #26389). This is not just a one-time improvement. Every time we make a dependency change to an image we invalidate everything after it. By splitting the images, a change to one doesn't force us to rebuild the image for all the other tasks. We end up with much better cache hit rates.This PR adds two new images (from
Dockerfile.validate, andDockerfile.build), #26389 has one forcross, and there is already a separate image for man page generation. In the near future we can have one for generating the swagger types (#27117). We might also want images forbuild-rpmandbuild-dep.dobi for running build tasks
dobi is a tool I've been working on for "build automation". It is designed based on my experienced writing Makefiles both here and at previous employer, as well as a lot of feedback from Compose users who are attempting to use Compose as a Makefile replacement (which it is not designed to be). dobi is aimed at being a make-like tool that exposes docker resources from a declarative config file. It would eventually be a replacement for the Makefile.
As you can see from the initial
dobi.yamlin this PR, you define each resource (mount, image, job) and you can execute them as you would a make target withdobi <resource name>. There are also "actions" for each task, so to remove the build image you could rundobi builder:rm(see the task reference).dobi comes with a long list of improvements over a Makefile:
If you're interested in trying it out , you can run
dobi listto get a list of all the resources that have descriptions.