You are not logged in.

#1 2019-10-08 09:27:48

blochl
Member
Registered: 2018-08-31
Posts: 48

[Solved] Is it possible to build a Docker image during package build?

I need to create a package which would put a Docker image on the system. I could just create the image, and include it in the package separately, but I'd really prefer for all the process to be done by `makepkg`, since this will play well with the package-building automation I'm working with, and, I think, will be just more elegant to include a Dockerfile in sources, rather than a huge binary archive.

Can you please advise what would be the better way to build a Docker image during the package build?

Last edited by blochl (2019-10-10 18:02:45)

Offline

#2 2019-10-08 13:01:04

a821
Member
From: My Location
Registered: 2012-10-31
Posts: 133

Re: [Solved] Is it possible to build a Docker image during package build?

I do not see any complication. You could build the image in `build` and in `package` you  `install` the resulting image in `$pkgdir/path/to/my/image`. Unless I'm missing something...

Offline

#3 2019-10-08 14:03:35

blochl
Member
Registered: 2018-08-31
Posts: 48

Re: [Solved] Is it possible to build a Docker image during package build?

a821 wrote:

I do not see any complication. You could build the image in `build` and in `package` you  `install` the resulting image in `$pkgdir/path/to/my/image`. Unless I'm missing something...

The complication is that the user who builds it needs to be in the `docker` group, and the Docker daemon needs to run for that. You can't add the user who builds the package to a group, or launch the Docker daemon from the PKGBUILD, can you?

Offline

#4 2019-10-08 15:40:50

progandy
Member
Registered: 2012-05-17
Posts: 3,535

Re: [Solved] Is it possible to build a Docker image during package build?

Can you use podman (podman-compose) to build the container? Or depending on your automation, create a script that first assembles the container image and then calls makepkg.

Edit: A PKGBUILD is just a bash script. Theoretically you could do anything that your build user is allowed to in there.

A dockerfile in a package isn't really elegant regardless of the method used. Either you have the complete binary image as a source file or alternatively only the docker file as a source which will result in fetching files during build() or prepare() instead of the usual download step

Last edited by progandy (2019-10-08 15:57:46)


| alias CUTF='LANG=en_XX.UTF-8@POSIX ' |

Offline

#5 2019-10-08 15:55:56

a821
Member
From: My Location
Registered: 2012-10-31
Posts: 133

Re: [Solved] Is it possible to build a Docker image during package build?

There is also buildah for building images. Though according to the wiki some extra setup is needed. Might be an alternative.

Offline

#6 2019-10-10 18:11:31

blochl
Member
Registered: 2018-08-31
Posts: 48

Re: [Solved] Is it possible to build a Docker image during package build?

Thanks! Eventually I went for the separate script option, which prepares the image before makepkg.

a821, thanks - I didn't hear of Buildah, and indeed it looks like the tool for that. The problem is that now I have a Dockerfile, and although Buildah can work with them, it is not optimal, as the image becomes actually larger than with Docker, and all the tools for preparing the image are still on it. When I will get to optimizing this container build process, I'll likely switch to using Buildah.

Offline

Board footer

Powered by FluxBB