ldez / seihon

A simple tool to build and publish multi-arch images on the Docker Hub.
Other
21 stars 1 forks source link

Seihon docker image? #4

Closed andig closed 5 years ago

andig commented 5 years ago

Ok, time to use Seihon for distributing it. An ldez/seihon container would be nice to get around curl'ing it and polluting local folders. This would require a docker image with docker binary (e.g. library:docker) as runtime image.

andig commented 5 years ago

On a quick test, this already seems to work:

./seihon publish --base-runtime-image docker --image-name andig/seihon --targets amd64,arm.v6,arm64.v8 -v latest --dry-run=false

The docker base image doesn't have more platforms. And indeed this image does (almost) work after adding /source as WORKDIR:

docker run -v /var/run/docker.sock:/var/run/docker.sock -v $(pwd):/source --entrypoint /bin/sh andig/seihon -c "cd /source && /usr/bin/seihon publish --base-runtime-image docker --image-name andig/seihon --targets amd64 -v latest --template /source/tmpl.Dockerfile --dry-run=false"

Its only missing the docker credentials:

Sending build context to Docker daemon  11.09MB
Step 1/12 : FROM golang:1-alpine as builder
...
Successfully built be9ec8a31718
Successfully tagged andig/seihon:latest-amd64

Error: failed to push: &{/usr/local/bin/docker [docker push andig/seihon:latest-amd64] [HOSTNAME=cc779ce4d622 SHLVL=1 HOME=/root OLDPWD=/ PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin DOCKER_CHANNEL=stable DOCKER_VERSION=18.09.6 PWD=/source DOCKER_CLI_EXPERIMENTAL=enabled]  <nil> The push refers to repository [docker.io/andig/seihon]
andig commented 5 years ago

Permissions can be passed using ENV vars and adding a docker login -u ... -p step. Verfied I do get a working seihon container that can dockerize itself that way:

❯ docker run andig/seihon:latest version
seihon:
version     : v0.4.2
commit      : 8f46d75
build date  : 2019-05-10_12:41:09PM
go version  : go1.12.4
go compiler : gc
platform    : linux/amd64
ldez commented 5 years ago

Could you explain what do you think it's a good idea? I'm not sure to use Docker in Docker is good.

andig commented 5 years ago

I'm not sure to use Docker in Docker is good.

As far as I understand this is not docker in docker (dind). It is using a docker client talking to the docker server on the host, bascially what many CI pipelines do for building images. But I may be wrong.

Could you explain what do you think it's a good idea?

To some extend because it can be done and I was wondering why it didn't come that way. The one thing it does for me is that it's alsways current and does not need to be installed locally. Maybe I got carried away.

But you're right- it won't do more in docker than outside and the boilerplate needed to get docker login inside the container doesn't make it any sexier.

Happy to have this closed and thanks for bearing with me.

ldez commented 5 years ago

The one thing it does for me is that it's always current and does not need to be installed locally.

With Docker "latest" is not always the latest if you don't pull force every time, and friends don't let friends use "latest". :smiley:

I published seihon to my homebrew-tap repo and also to the AUR.

It's just a binary that only depends on Docker, so I don't see the need to install it locally as a problem.

A little bit off-topic but have you see https://github.com/features/package-registry? This looks promising.

andig commented 5 years ago

A little bit off-topic but have you see https://github.com/features/package-registry? This looks promising.

Not sure what to think yet. Embrace and extend or added value?