devspace icon indicating copy to clipboard operation
devspace copied to clipboard

Docker targets when building image are ignored

Open alexissellier opened this issue 2 years ago • 1 comments

What happened? When building images, docker target are ignored

What did you expect to happen instead?

How can we reproduce the bug? (as minimally and precisely as possible) Build two images with different target and you would see in the log that your Dockerfile instructions are executed, not only the one related to your target.

My devspace.yaml:

[...]
images:
  monolith:
    image: ${IMAGES_REG}/monolith:${DEVSPACE_GIT_COMMIT}
    dockerfile: devspace.Dockerfile
    target: monolith-dev
    buildArgs:
      PHP_IMAGE_BASE: stable
  assets:
    image: ${IMAGES_REG}/assets:${DEVSPACE_GIT_COMMIT}
    dockerfile: devspace.Dockerfile
    target: assets-dev
[...]

Local Environment:

  • DevSpace Version: 6.1.1
  • Operating System: Linux and Mac
  • ARCH of the OS: AMD64 | ARM64 | i386 Kubernetes Cluster: local kind cluster

Anything else we need to know?

I've checked the code and the logs of my docker daemon and it saw that the Version field in the types.ImageBuildOptions (builder/docker/docker.go) is not mentioned and thus defaulted to '1' which is not the buildkit builder.

When setting Version to types.BuilderBuildKit, my targets are taking into account and everything is right but no logs are displayed. The log lines seem to lie in the Aux variable of the JSONMessage as base64d string and I've not find any auxCallback to decode them

/kind bug

alexissellier avatar Sep 16 '22 10:09 alexissellier

FYI, I've done 90 % of the work to fix that. The only thing I need to fix is that devspace relies on github.com/docker/docker v20.10.5+incompatible and for the fix I need to follow the instruction here https://github.com/moby/buildkit/issues/1973 and I end up with I guess, a circular dependency

alexissellier avatar Sep 19 '22 12:09 alexissellier

Could you tell me what is the reason for devspace to have a constraint on the github.com/docker/docker lib version ?

alexissellier avatar Sep 26 '22 09:09 alexissellier

@alexissellier they were a couple of problems combined with Kubernetes and docker/distribution, but I believe we can revisit that and check if its still necessary

FabianKramm avatar Sep 27 '22 11:09 FabianKramm

@alexissellier is this still a problem for you?

FabianKramm avatar Nov 07 '22 15:11 FabianKramm