You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
TLDR: publishTask first triggers publishLocalTask which runs docker build even for multiplatform builds that require docker buildx build; docker buildx build is only triggered in the publishTask later. I'd guess that dockerBuildCommand should check dockerBuildxPlatforms to select between build and buildx build such that publishLocal issues a single build, and publish just pushes the tags from the local build instead of triggering a new build.
Multiplatform builds require using buildx with the docker-container driver, which I am doing
I have modified stage0 to include a layer that builds a binary (not the easiest thing since #1417 is open and #1437 was closed without comment). This layer is now a slow process and so I want the layer cached. Because this is only in stage0 the layer is not included in the final docker image publish. The way to solve this is to add --cache-to and --cache-from such that even intermediate layers get cached and reused
[error] ERROR: cache export feature is currently not supported for docker driver. Please switch to a different driver (eg. "docker buildx create --use")
[info] Removing intermediate image(s) (labeled "snp-multi-stage-id=739842cd-6d16-4c12-8195-67def738cf32")
[info] Total reclaimed space: 0B
[error] java.lang.RuntimeException: Nonzero exit value: 1
[error] at com.typesafe.sbt.packager.docker.DockerPlugin$.publishLocalDocker(DockerPlugin.scala:691)
[error] at com.typesafe.sbt.packager.docker.DockerPlugin$.$anonfun$projectSettings$42(DockerPlugin.scala:267)
[error] at com.typesafe.sbt.packager.docker.DockerPlugin$.$anonfun$projectSettings$42$adapted(DockerPlugin.scala:259)
This is unexpected and means publishLocalDocker is using the docker driver and not using buildx with the docker-container driver I set.
Indeed, publishLocalDocker is called in publishLocalTask with
And publishLocalTask is invoked as the first step in publishTask with val _ = publishLocal.value. At this point, dockerBuildCommand is docker build ... and dockerExecCommand is docker. Only later in publishTask does it check for a multiplatform build and alter the exec command to be docker buildx build ... --push.
This results in a docker build for the host architecture using the docker driver, followed by a docker buildx build for any configured platforms. In the presence of --cache-from and --cache-to, the initial docker build fails. If the host architecture matches a configured cross-platform, the docker buildx build will reuse those layers, and if not then the docker build is wasted work.
This can be worked around by resetting dockerBuildCommand:
TLDR:
publishTask
first triggerspublishLocalTask
which runsdocker build
even for multiplatform builds that requiredocker buildx build
;docker buildx build
is only triggered in thepublishTask
later. I'd guess thatdockerBuildCommand
should checkdockerBuildxPlatforms
to select betweenbuild
andbuildx build
such thatpublishLocal
issues a single build, andpublish
just pushes the tags from the local build instead of triggering a new build.Multiplatform builds require using
buildx
with thedocker-container
driver, which I am doingI have modified
stage0
to include a layer that builds a binary (not the easiest thing since #1417 is open and #1437 was closed without comment). This layer is now a slow process and so I want the layer cached. Because this is only instage0
the layer is not included in the final docker image publish. The way to solve this is to add--cache-to
and--cache-from
such that even intermediate layers get cached and reusedRunning this setup results in an error
This is unexpected and means
publishLocalDocker
is using thedocker
driver and not usingbuildx
with thedocker-container
driver I set.Indeed,
publishLocalDocker
is called inpublishLocalTask
withAnd
publishLocalTask
is invoked as the first step inpublishTask
withval _ = publishLocal.value
. At this point,dockerBuildCommand
isdocker build ...
anddockerExecCommand
isdocker
. Only later inpublishTask
does it check for a multiplatform build and alter the exec command to bedocker buildx build ... --push
.This results in a
docker build
for the host architecture using thedocker
driver, followed by adocker buildx build
for any configured platforms. In the presence of--cache-from
and--cache-to
, the initialdocker build
fails. If the host architecture matches a configured cross-platform, thedocker buildx build
will reuse those layers, and if not then thedocker build
is wasted work.This can be worked around by resetting
dockerBuildCommand
:It is only a workaround since
buildx build
gets invoked twice, but at least the second time is already cached locally.Expected behaviour
Multiplatform builds consistently use
docker buildx build
and only build onceActual behaviour
Multiplatform builds start with a
docker build
and later issue adocker buildx build
Information
The text was updated successfully, but these errors were encountered: