worried-painter-31382
09/02/2022, 1:57 PM--cache-from
argument to the docker_image
via some pants invocation?--docker-env-vars
sparse-lifeguard-95737
09/02/2022, 2:03 PMdocker buildx build
instead of docker build
, unless you write an entirely new plugin to replace the built-in docker support. we are working around this by running docker buildx install
everywhere as part of our standard setup processworried-painter-31382
09/02/2022, 2:06 PMDOCKER_BUILDKIT=1
, so was hoping for some luck with the --cache-from
argsparse-lifeguard-95737
09/02/2022, 2:06 PMregister.py
, you can copy-paste and delete the stuff for `--cache-to`:
from typing import Iterator
from pants.backend.docker.target_types import (
DockerBuildOptionFieldMixin,
DockerImageTarget,
OptionValueFormatter,
)
from pants.engine.target import StringField
from pants.util.strutil import softwrap
class DockerImageCacheFromField(DockerBuildOptionFieldMixin, StringField):
alias = "cache_from"
help = softwrap(
"""
External cache sources (e.g., "user/app:cache", "type=local,src=path/to/dir")
NOTE: To use this field, you must run `docker buildx install` on your host.
"""
)
docker_build_option = "--cache-from"
def option_values(self, *, value_formatter: OptionValueFormatter) -> Iterator[str]:
if self.value:
yield value_formatter(self.value)
class DockerImageCacheToField(DockerBuildOptionFieldMixin, StringField):
alias = "cache_to"
help = softwrap(
"""
Cache export destinations (e.g., "user/app:cache", "type=local,dest=path/to/dir")
NOTE: To use this field, you must run `docker buildx install` on your host.
"""
)
docker_build_option = "--cache-to"
def option_values(self, *, value_formatter: OptionValueFormatter) -> Iterator[str]:
if self.value:
yield value_formatter(self.value)
def rules():
return [
DockerImageTarget.register_plugin_field(DockerImageCacheFromField),
DockerImageTarget.register_plugin_field(DockerImageCacheToField),
]
worried-painter-31382
09/02/2022, 2:09 PMcurved-television-6568
09/02/2022, 2:38 PMhundreds-father-404
09/02/2022, 3:35 PMcurved-television-6568
09/02/2022, 3:37 PMuse_buildkit=true
we could set the DOCKER_BUILDKIT=1
env too)sparse-lifeguard-95737
09/02/2022, 3:39 PMdocker build
command pluggable you could possibly have a separate plugin that replaces build
with buildx build
, and adds support for all the buildx-specific fieldscurved-television-6568
09/02/2022, 3:45 PM