Skip to contentSkip to conversation

Dealing with go dependencies in recipes - native docker-compose

DISCUSSION Konstantin Kletschke 2 participants 8 messages Oct 11, 2022 – Oct 19, 2022 1 message not in the archive

lore
Share & tools
lore
#0 lore raw

Today I realized, that the docker-compose in the meta-virtualization layer is the old python3 based one and a native solution is available. I tried to make a recipe for it to get rid of python3 (no other packages uses it in our setup) and the current python3-docker-compose is broken:

https://lore.kernel.org/yocto-meta-virtualization/[email protected]/

I tried to build the native solution proposed in
https://github.com/docker/compose/tree/v2.11.2.

So my current recipe docker-compose_2.11.2.bb looks like this:

LICENSE = "Apache-2.0"

inherit go
inherit go-mod

GO_IMPORT = "github.com/docker/compose"

SRC_URI = "git://${GO_IMPORT};protocol=https;branch=v2"

# v2.11.2
SRCREV = "616777eb4ad4d1101622d6727d9b7adaeb7943bb"

# S = "${WORKDIR}/git"

DEPENDS = "docker-ce"
RDEPENDS:${PN} = "docker-ce-cli"

With this I run into the issue, that go want's to download stuff while compiling. Which is forbidden and breaks the reliable build proposal. Totally understandable. Looks similair to this:

dial tcp: lookup proxy.golang.org: Temporary failure in name resolution

I read about a proposal allowing this by adding do_compile[network] = "1" to meta/classes/go.bb:

https://lore.kernel.org/all/[email protected]/

Of course, if this works, the reliable build thingy is gone, but while trying I discovered go loads external stuff, compiles it too. In my case (I have kirkstone with go-1.17) I run into modules demanding a go more recent:

ASH[build k8s.io/client-go/applyconfigurations/autoscaling/v2beta2]: "file containerresourcemetricsource.go Mas4-HIX5lGBEQNTIo58\n"

# github.com/docker/compose/v2/pkg/utils
pkg/utils/slices.go:23:6: missing function body
pkg/utils/slices.go:23:14: syntax error: unexpected [, expecting (
note: module requires Go 1.19
HASH[build k8s.io/client-go/applyconfigurations/certificates/v1beta1]
HASH[build k8s.io/client-go/applyconfigurations/certificates/v1beta1]: "go1.17.13"

which could be worked around by moving to landsdale release. Which bothers me, because I too want to keep my build reliable. And I do not want to mess around outside our meta layer in the distribution! How do I do this properly?
I see people pulling in each dependency by individual golang.org-x.bb recipes, how could such a recipe look like?

I read
https://lore.kernel.org/all/[email protected]/T/
where Mike is not happy with this appraoch either and comes up with a working recipe I don't get why this could work at all.

What am I missing here where is the missing link I did not get yet?

Also, I am jealous about the buildroot guys sometimes, how do they do this in a 22 lines makefile including comments:

https://git.busybox.net/buildroot/tree/package/docker-compose/docker-compose.mk

Regards
Konstantin

Signature · 14 lines
INSIDE M2M GmbH
Konstantin Kletschke
Berenbosteler Straße 76 B
30823 Garbsen

Telefon: +49 (0) 5137 90950136
Mobil: +49 (0) 151 15256238
Fax: +49 (0) 5137 9095010

[email protected]
http://www.inside-m2m.de 

Geschäftsführung: Michael Emmert, Ingo Haase, Dr. Fred Könemann, Derek Uhlig
HRB: 111204, AG Hannover
#1 lore raw
Quoted 7 lines · Konstantin Kletschke

Today I realized, that the docker-compose in the meta-virtualization layer is the old python3 based one and a native solution is available. I tried to make a recipe for it to get rid of python3 (no other packages uses it in our setup) and the current python3-docker-compose is broken:

https://lore.kernel.org/yocto-meta-virtualization/[email protected]/

Adding the missing setuptools does get things working.

Quoted 5 lines

I tried to build the native solution proposed in
https://github.com/docker/compose/tree/v2.11.2.

I actually have a prototype recipe for this that I was working on before ELCe, but I didn't get it into meta-virtualization yet, as it had a few rough edges.

If you give me a few days, I can post it to the meta-virtualization list, but I'm on the road right now and don't have access to all my build machines.

Quoted 23 lines

So my current recipe docker-compose_2.11.2.bb looks like this:

LICENSE = "Apache-2.0"

inherit go
inherit go-mod

GO_IMPORT = "github.com/docker/compose"

SRC_URI = "git://${GO_IMPORT};protocol=https;branch=v2"

# v2.11.2
SRCREV = "616777eb4ad4d1101622d6727d9b7adaeb7943bb"

# S = "${WORKDIR}/git"

DEPENDS = "docker-ce"
RDEPENDS:${PN} = "docker-ce-cli"

With this I run into the issue, that go want's to download stuff while compiling. Which is forbidden and breaks the reliable build proposal. Totally understandable. Looks similair to this:

Quoted 9 lines

dial tcp: lookup proxy.golang.org: Temporary failure in name resolution

I read about a proposal allowing this by adding do_compile[network] = "1" to meta/classes/go.bb:

https://lore.kernel.org/all/[email protected]/

Of course, if this works, the reliable build thingy is gone, but while

Right, it works, but would never make it into core due to it bypassing many of the fetcher properties.

Quoted 14 lines

trying I discovered go loads external stuff, compiles it too. In my case (I have kirkstone with go-1.17) I run into modules demanding a go more recent:

ASH[build k8s.io/client-go/applyconfigurations/autoscaling/v2beta2]:
"file containerresourcemetricsource.go Mas4-HIX5lGBEQNTIo58\n"

# github.com/docker/compose/v2/pkg/utils
pkg/utils/slices.go:23:6: missing function body
pkg/utils/slices.go:23:14: syntax error: unexpected [, expecting (
note: module requires Go 1.19
HASH[build k8s.io/client-go/applyconfigurations/certificates/v1beta1]
HASH[build k8s.io/client-go/applyconfigurations/certificates/v1beta1]:
"go1.17.13"
Quoted 7 lines

which could be worked around by moving to landsdale release. Which bothers me, because I too want to keep my build reliable. And I do not want to mess around outside our meta layer in the distribution! How do I do this properly?
I see people pulling in each dependency by individual golang.org-x.bb recipes, how could such a recipe look like?

There are many different discussions about how to generate go recipes, as well
as similar discussions for ruby/rust, etc, you can find them on the openembedded-core
and openembedded-architectures lists.

I also did a presentation at the yocto summit about "modern languages".

So I won't try and summarize all those discussions here, since they are archived
and do a much better job than I could here.

But to answer the specific question .. you can't really handle the individual
go dependencies as recipes. They are far too sensitive to versions and individual git hashes. Plus you'll end up with thousands of recipes of varying
versions.

There have been several proposals about how to generate go recipes to deal with
the dependencies. Some prototypes have been posted, but there hasn't been a lot of traffic on that topic for several months now.

You can see the approach that I take for this in the k3s and nerdctl recipes in meta-virtualization. My new docker-compose recipe is of similar format.

Quoted 7 lines

I read

https://lore.kernel.org/all/[email protected]/T/
where Mike is not happy with this appraoch either and comes up with a working recipe I don't get why this could work at all.

Quoted 9 lines

What am I missing here where is the missing link I did not get yet?

Also, I am jealous about the buildroot guys sometimes, how do they do this in a 22 lines makefile including comments:

https://git.busybox.net/buildroot/tree/package/docker-compose/docker-compose.mk

If we just bypass the fetcher, offline builds, some of licensing and SBOM and reproducible builds .. you can have a simple recipe like that as well :)

Bruce

Quoted 33 lines

Regards
Konstantin

--
INSIDE M2M GmbH
Konstantin Kletschke
Berenbosteler Straße 76 B
30823 Garbsen

Telefon: +49 (0) 5137 90950136
Mobil: +49 (0) 151 15256238
Fax: +49 (0) 5137 9095010

[email protected]
http://www.inside-m2m.de

Geschäftsführung: Michael Emmert, Ingo Haase, Dr. Fred Könemann, Derek Uhlig
HRB: 111204, AG Hannover

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group. View/Reply Online (#58323):
https://lists.yoctoproject.org/g/yocto/message/58323
Mute This Topic: https://lists.yoctoproject.org/mt/94264665/1050810
Group Owner: [email protected]
Unsubscribe: https://lists.yoctoproject.org/g/yocto/unsub [ [email protected]]
-=-=-=-=-=-=-=-=-=-=-=-

Signature · 3 lines
- Thou shalt not follow the NULL pointer, for chaos and madness await thee
at its end
- "Use the force Harry" - Gandalf, Star Trek II
#2 lore raw
Quoted 1 line · Bruce Ashfield

Adding the missing setuptools does get things working.

Oh my, I was still looking for python3-distutils (deprecated, not available) and did not realize I now need setuptools. Thanks for clarifying, however, I investigated the gao approach then...

Quoted 3 lines

I actually have a prototype recipe for this that I was working on before ELCe, but I didn't get it into meta-virtualization yet, as it had a few rough edges.

I suppose, those go recipes look extremly difficult to do.

Quoted 3 lines

If you give me a few days, I can post it to the meta-virtualization list, but I'm on the road right now and don't have access to all my build machines.

Of course I have patience and I am very curious to test this out! Currently I have no urge but in future it will be extremely handy to have the native docker compose approach available. It is a bit smaller then the python approach (if python is only used by this docker-compose, a third disk space is used by native approach).

Quoted 1 line

I also did a presentation at the yocto summit about "modern languages".

Opps, interesting. No need to summarize here, I agree. I will dig this up in the internet. Interesting...

Quoted 2 lines

You can see the approach that I take for this in the k3s and nerdctl recipes in meta-virtualization. My new docker-compose recipe is of similar format.

As I vaguely mentioned above, those recipes look far more complex than I would have imagined when starting to dig into the go world... astonishing!

Quoted 2 lines

If we just bypass the fetcher, offline builds, some of licensing and SBOM and reproducible builds .. you can have a simple recipe like that as well :)

Yea, and I already learned to lovae this reproducibility approach.

Signature · 14 lines
INSIDE M2M GmbH
Konstantin Kletschke
Berenbosteler Straße 76 B
30823 Garbsen

Telefon: +49 (0) 5137 90950136
Mobil: +49 (0) 151 15256238
Fax: +49 (0) 5137 9095010

[email protected]
http://www.inside-m2m.de 

Geschäftsführung: Michael Emmert, Ingo Haase, Dr. Fred Könemann, Derek Uhlig
HRB: 111204, AG Hannover
#3 lore raw
Quoted 30 lines · Konstantin Kletschke
Quoted 1 line · Bruce Ashfield

Adding the missing setuptools does get things working.

Oh my, I was still looking for python3-distutils (deprecated, not available) and did not realize I now need setuptools. Thanks for clarifying, however, I investigated the gao approach then...

Quoted 3 lines

I actually have a prototype recipe for this that I was working on before ELCe, but I didn't get it into meta-virtualization yet, as it had a few rough edges.

I suppose, those go recipes look extremly difficult to do.

Quoted 3 lines

If you give me a few days, I can post it to the meta-virtualization list, but I'm on the road right now and don't have access to all my build machines.

Of course I have patience and I am very curious to test this out! Currently I have no urge but in future it will be extremely handy to have the native docker compose approach available. It is a bit smaller then the python approach (if python is only used by this docker-compose, a third disk space is used by native approach).

Quoted 1 line

I also did a presentation at the yocto summit about "modern languages".

Opps, interesting. No need to summarize here, I agree. I will dig this up in the internet. Interesting...

Quoted 9 lines
Quoted 1 line

You can see the approach that I take for this in the k3s and nerdctl

recipes

Quoted 1 line

in meta-virtualization. My new docker-compose recipe is of similar

format.

As I vaguely mentioned above, those recipes look far more complex than I would have imagined when starting to dig into the go world... astonishing!

FYI: Here's the very lightly tested RFC version of the recipe:

https://git.yoctoproject.org/meta-virtualization/commit/?h=master-next&id=fa24cfc08b129de5c7ba36099985359cc0228630

Cheers,

Bruce

Quoted 35 lines
Quoted 2 lines

If we just bypass the fetcher, offline builds, some of licensing and SBOM and reproducible builds .. you can have a simple recipe like that as

well :)

Yea, and I already learned to lovae this reproducibility approach.

--
INSIDE M2M GmbH
Konstantin Kletschke
Berenbosteler Straße 76 B
30823 Garbsen

Telefon: +49 (0) 5137 90950136
Mobil: +49 (0) 151 15256238
Fax: +49 (0) 5137 9095010

[email protected]
http://www.inside-m2m.de

Geschäftsführung: Michael Emmert, Ingo Haase, Dr. Fred Könemann, Derek Uhlig
HRB: 111204, AG Hannover

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group. View/Reply Online (#58332):
https://lists.yoctoproject.org/g/yocto/message/58332
Mute This Topic: https://lists.yoctoproject.org/mt/94264665/1050810
Group Owner: [email protected]
Unsubscribe: https://lists.yoctoproject.org/g/yocto/unsub [ [email protected]]
-=-=-=-=-=-=-=-=-=-=-=-

Signature · 3 lines
- Thou shalt not follow the NULL pointer, for chaos and madness await thee
at its end
- "Use the force Harry" - Gandalf, Star Trek II
#4 lore raw
Quoted 3 lines · Bruce Ashfield

FYI: Here's the very lightly tested RFC version of the recipe:

https://git.yoctoproject.org/meta-virtualization/commit/?h=master-next&id=fa24cfc08b129de5c7ba36099985359cc0228630

Thanks for the kind notification.

My stuff is based upon kirkstone, I stuffed the recipe from master-next into my kirkstone build. One package of this new docker-compose is depending upon go-1.19 (kirkstone provides go-1.17) so I pulled in go-1.19 from langdale also into my kirkstone build.

The compiling and building works just fine! The recipe(s) for docker-compose look impressive, I would not have expected them being so complex. But they work.

Two notes:

After installing the package provides /bin/docker-compose. I realized other parties provide this as /usr/lib/docker/cli-plugins/docker-compose which make something like "docker compose version" working. For me this does not harm, only as remark. May be this is intentional.

Upon investigating I realized the version reported by docker-compose is "dev" instead of the expected "v2.11.2".

Great work, thank you!

Regards Konstantin

#5 lore raw
Quoted 15 lines · Konstantin Kletschke
Quoted 3 lines · Bruce Ashfield

FYI: Here's the very lightly tested RFC version of the recipe:

https://git.yoctoproject.org/meta-virtualization/commit/?h=master-next&id=fa24cfc08b129de5c7ba36099985359cc0228630

Thanks for the kind notification.

My stuff is based upon kirkstone, I stuffed the recipe from master-next into my kirkstone build. One package of this new docker-compose is depending
upon go-1.19 (kirkstone provides go-1.17) so I pulled in go-1.19 from langdale also into my kirkstone build.

Quoted 5 lines

The compiling and building works just fine! The recipe(s) for docker-compose look impressive, I would not have expected them being so complex. But they work.

The amount of fetches is certainly impressive, but it is like that for any non-vendored go application, whether we can see it or not. When the recipes are simple, all of the fetching and source structuring takes place behind the scenes (I know, I'm stating the obvious), just in a manner we don't control.

I just yank the complexity out to the front, and go directly to the upstream sources of all the go libraries/packages. If we let go fetch it, we have to both rely on the versions being in the fetch locations "forever", or the infrastructure always being available (it should, but you never know). We then have to setup our own go proxy/mirror infrastructure to get around those two issues, and have now become curators of our own repositories and infrastructure. That infrastructure isn't really hard to setup, but in a maintenance mode, updating it, and getting new versions of the code for CVEs, etc, could be challenging.

By doing the fetches directly, all of the established infrastructure, archiving, mirrors, licensing, etc, "just work", and we can bump the SRCREV of any dependency if a CVE or issue is found.

Definitely a balancing act, with no 'one true answer' yet, so I've been going with what I know works :)

Two notes:

Quoted 6 lines

After installing the package provides /bin/docker-compose. I realized other parties provide this as /usr/lib/docker/cli-plugins/docker-compose which make something like "docker compose version" working. For me this does not harm, only as remark. May be this is intentional.

Completely random. I just put it there. I'll make that adjustment in the recipe.

Quoted 3 lines

Upon investigating I realized the version reported by docker-compose is "dev" instead of the expected "v2.11.2".

I saw the same thing, and was looking into fixing it, I figured it was worth getting the recipe out, before I did more tweaking.

Quoted 3 lines

Great work, thank you!

I appreciate the testing and the report, very helpful!

Bruce

Quoted 15 lines

Regards Konstantin

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group. View/Reply Online (#58354):
https://lists.yoctoproject.org/g/yocto/message/58354
Mute This Topic: https://lists.yoctoproject.org/mt/94264665/1050810
Group Owner: [email protected]
Unsubscribe: https://lists.yoctoproject.org/g/yocto/unsub [ [email protected]]
-=-=-=-=-=-=-=-=-=-=-=-

Signature · 3 lines
- Thou shalt not follow the NULL pointer, for chaos and madness await thee
at its end
- "Use the force Harry" - Gandalf, Star Trek II

A message that is not in the archive (sent off-list or not yet received): [email protected]

#7 lore raw
Quoted 60 lines · Bruce Ashfield via lists.yoctoproject.org
Quoted 15 lines · Konstantin Kletschke
Quoted 3 lines · Bruce Ashfield

FYI: Here's the very lightly tested RFC version of the recipe:

https://git.yoctoproject.org/meta-virtualization/commit/?h=master-next&id=fa24cfc08b129de5c7ba36099985359cc0228630

Thanks for the kind notification.

My stuff is based upon kirkstone, I stuffed the recipe from master-next into my kirkstone build. One package of this new docker-compose is depending
upon go-1.19 (kirkstone provides go-1.17) so I pulled in go-1.19 from langdale also into my kirkstone build.

Quoted 5 lines

The compiling and building works just fine! The recipe(s) for docker-compose look impressive, I would not have expected them being so complex. But they work.

The amount of fetches is certainly impressive, but it is like that for any non-vendored go application, whether we can see it or not. When the recipes are simple, all of the fetching and source structuring takes place behind the scenes (I know, I'm stating the obvious), just in a manner we don't control.

I just yank the complexity out to the front, and go directly to the upstream sources of all the go libraries/packages. If we let go fetch it, we have to both rely on the versions being in the fetch locations "forever", or the infrastructure always being available (it should, but you never know). We then have to setup our own go proxy/mirror infrastructure to get around those two issues, and have now become curators of our own repositories and infrastructure. That infrastructure isn't really hard to setup, but in a maintenance mode, updating it, and getting new versions of the code for CVEs, etc, could be challenging.

By doing the fetches directly, all of the established infrastructure, archiving, mirrors, licensing, etc, "just work", and we can bump the SRCREV of any dependency if a CVE or issue is found.

Definitely a balancing act, with no 'one true answer' yet, so I've been going with what I know works :)

Two notes:

Quoted 6 lines

After installing the package provides /bin/docker-compose. I realized other parties provide this as /usr/lib/docker/cli-plugins/docker-compose which make something like "docker compose version" working. For me this does not harm, only as remark. May be this is intentional.

Completely random. I just put it there. I'll make that adjustment in the recipe.

Quoted 7 lines
Quoted 3 lines

Upon investigating I realized the version reported by docker-compose is "dev" instead of the expected "v2.11.2".

I saw the same thing, and was looking into fixing it, I figured it was worth getting the recipe out, before I did more tweaking.

emux86-64-c9 login: root

root@qemux86-64-c9:~# /usr/lib/docker/cli-plugins/docker-compose version

Docker Compose version v2.11.2

Cheers,

Bruce

Quoted 35 lines
Quoted 4 lines

Great work, thank you!

I appreciate the testing and the report, very helpful!

Bruce

Quoted 7 lines

Regards Konstantin

--
- Thou shalt not follow the NULL pointer, for chaos and madness await thee at its end
- "Use the force Harry" - Gandalf, Star Trek II

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group. View/Reply Online (#58355):
https://lists.yoctoproject.org/g/yocto/message/58355
Mute This Topic: https://lists.yoctoproject.org/mt/94264665/1050810
Group Owner: [email protected]
Unsubscribe: https://lists.yoctoproject.org/g/yocto/unsub [ [email protected]]
-=-=-=-=-=-=-=-=-=-=-=-

Signature · 3 lines
- Thou shalt not follow the NULL pointer, for chaos and madness await thee
at its end
- "Use the force Harry" - Gandalf, Star Trek II
#8 lore raw
Quoted 3 lines · Bruce Ashfield
root@qemux86-64-c9:~# /usr/lib/docker/cli-plugins/docker-compose version

Docker Compose version v2.11.2

root@insidem2m:~/docker-nginx-demo# docker compose version
Docker Compose version v2.11.2

I did a test run with a small docker-compose.yml for a nginx hello world demo. It worked flawlessly, downloading, installing and starting went really fine.

Perfect, nice work!

Kind Regards
Konstantin

Signature · 14 lines
INSIDE M2M GmbH
Konstantin Kletschke
Berenbosteler Straße 76 B
30823 Garbsen

Telefon: +49 (0) 5137 90950136
Mobil: +49 (0) 151 15256238
Fax: +49 (0) 5137 9095010

[email protected]
http://www.inside-m2m.de 

Geschäftsführung: Michael Emmert, Ingo Haase, Dr. Fred Könemann, Derek Uhlig
HRB: 111204, AG Hannover