The build-stage would still be in the local cache (and can
be cleaned up with `docker system prune`) but the tagged
image (which usually wouldn't be removed) will take up
less space now.
Note that
- the binary is not statically linked, so we cannot use
a "from scratch" image
- in cases where the binary is cross-compiled (e.g.
on a non-linux machine), the image itself is not
really useful (we may want to consider not tagging
the image in that situation)
Before:
REPOSITORY TAG IMAGE ID CREATED SIZE
moby-buildx latest c9b2af465baf 7 minutes ago 1.71GB
After:
REPOSITORY TAG IMAGE ID CREATED SIZE
moby-buildx latest 345501e2df0a 2 minutes ago 820MB
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This patch removes the `BUILDX_COMMIT` make variable. With the
make variable removed, it no longer "masks" environment variables,
and there is no longer a need to export the variable.
A side effect of this change, is that (by default), the buildx
image is tagged as `moby-buildx:latest`. This likely isn't a
problem, because the build-cache would still be preserved in
intermediate images. Having the image tagged as `:latest` also
makes cleaning up easier (without having to remove the image
for each version tagged.
Otherwise, the behavior remains the same as before:
# default
rm -f bundles/buildx && make buildx
# => => naming to docker.io/library/moby-buildx:latest
github.com/docker/buildx v0.3.0 c967f1d
# using a make variable:
rm -f bundles/buildx && make BUILDX_COMMIT=v0.2.1 buildx
# => => naming to docker.io/library/moby-buildx:v0.2.1
github.com/docker/buildx v0.2.1 0eb2df5
# using an environment variable:
rm -f bundles/buildx && BUILDX_COMMIT=v0.2.2 make buildx
# => => naming to docker.io/library/moby-buildx:v0.2.2
github.com/docker/buildx v0.2.2 ab5fe3d
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
The variables were not substituted, because single-quotes were used.
While at it; change the fixed version/commit to use the actual commit
and version, using git.
before this change:
make buildx && ./bundles/buildx version
github.com/docker/buildx ${BUILDX_COMMIT} ${BUILDX_COMMIT}
after this change:
make buildx && ./bundles/buildx version
buildx v0.3.0 c967f1d
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Since the dockerfile now requires buildkit, let's just use buildx can
bootstrap itself into even an old version of Docker which does not
support buildkit.
This also decouples the Dockerfile/build from the version of Docker
which is installed.
One major downside:
If buildx needs to setup a container driver (ie, docker does not support
buildkit), the `make shell` target (and others which call
`DOCKER_RUN_DOCKER`) must export the image from buildkit and into
docker. This added an extra 70s to a full build for me (agan only for targets
which call `DOCKER_RUN_DOCKER`) and 40s on a rebuild (with no changes).
Signed-off-by: Brian Goff <cpuguy83@gmail.com>