We'd love to be able to use the same Dockerfile's in skaffold that we use in production. The problem is that those Dockerfile's are actually a set of dependent Dockerfile's rather than a single Dockerfile.
The dependent Dockerfile's are currently structured like this so our build scripts can handle the dependency's:
ARG BASE_IMG
FROM ${BASE_IMG}
Initially I asked on slack for a mechanism to adjust tagging on a per-artifact basis and templated buildArgs to make this possible.
However, @balopat mentioned that build order isn't specified, you want the freedom to be able to build in parallel when that's possible.
So explicit support for dependent images may be easier/better than my initial ask for per-artifact tagging and templated buildArgs.
:+1: Would also like to see this. My project is structured as a monorepo with many microservices, and common library code that many of the services use:
|— microservice1
|—— Dockerfile
|— microservice2
|—— Dockerfile
|— ...
|— common
|—— Dockerfile
The common library is packaged into a Docker image that some of the other Dockerfiles inherit. Ideally Skaffold could detect changes in the common image’s workspace, rebuild it, and trigger rebuilds of any other images that depend on it. If I understand correctly with something like #635 the Docker workspace for the multi-stage image would have to be the project root, so changes to any microservice (whether it inherits the common image or not) would cause skaffold to rebuild everything unnecessarily. It works but would slow down development as I have 18 services at the moment.
@sean-schaefer, a single massive Dockerfile with multiple targets is working well for us and works fairly efficiently because of caching and because skaffold is really smart about only uploading files it actually needs to docker. Setting the 'useBuildkit' flag makes it even faster so it doesn't even try to evaluate unused stages.
End goal I would hope it's something as simple as this in our skaffold.yaml
apiVersion: skaffold/v1beta17
build:
artifacts:
- context: /home/gkarr/projects/mylib
image: mylib
- image: myproject
docker:
buildArgs:
MYBUILDARG: mylib
where the mylib would be updated to use the sha256 from it's current build
My $0.02: This seems entirely reasonable and we should make it happen.
@bryanlarsen do you mind commenting on the design doc for modules and artifact dependencies here: http://tinyurl.com/skaffold-modules? Thank you!!
With release v1.17.0 Skaffold now supports defining dependencies between artifacts.
End goal I would hope it's something as simple as this in our skaffold.yaml
apiVersion: skaffold/v1beta17 build: artifacts: - context: /home/gkarr/projects/mylib image: mylib - image: myproject docker: buildArgs: MYBUILDARG: mylibwhere the mylib would be updated to use the sha256 from it's current build
@georgekarrv Take a look at the microservices example where two images share the same base image:
build:
artifacts:
- image: leeroy-web
context: leeroy-web
requires:
- image: base
alias: BASE
- image: leeroy-app
context: leeroy-app
requires:
- image: base
alias: BASE
- image: base
context: base
For docker builder it automatically provides the latest base image as a build arg BASE when building the dependent images.
Ideally Skaffold could detect changes in the common image’s workspace, rebuild it, and trigger rebuilds of any other images that depend on it.
@sean-schaefer There's a tutorial demonstrating this targeted rebuild (rebuilding only dependency tree as against rebuilding everything) during dev.
Most helpful comment
:+1: Would also like to see this. My project is structured as a monorepo with many microservices, and common library code that many of the services use:
The common library is packaged into a Docker image that some of the other Dockerfiles inherit. Ideally Skaffold could detect changes in the common image’s workspace, rebuild it, and trigger rebuilds of any other images that depend on it. If I understand correctly with something like #635 the Docker workspace for the multi-stage image would have to be the project root, so changes to any microservice (whether it inherits the common image or not) would cause skaffold to rebuild everything unnecessarily. It works but would slow down development as I have 18 services at the moment.