Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add env option to build_docker_image build step #10331

Closed
3 tasks done
jsopkin opened this issue Jul 28, 2023 · 7 comments
Closed
3 tasks done

Add env option to build_docker_image build step #10331

jsopkin opened this issue Jul 28, 2023 · 7 comments
Labels
enhancement An improvement of an existing feature

Comments

@jsopkin
Copy link
Contributor

jsopkin commented Jul 28, 2023

First check

  • I added a descriptive title to this issue.
  • I used the GitHub search to find a similar request and didn't find it.
  • I searched the Prefect documentation for this feature.

Prefect Version

2.x

Describe the current behavior

The prefect deploy build_docker_image step does not support passing in an env variable. Exporting the variable prior to running prefect deploy or running a shell script to export the variable does not work either. For example, attempting to export the env var through the run_shell_script step results in this error FileNotFoundError: [Errno 2] No such file or directory: 'export'

Describe the proposed behavior

There are cases where it would be necessary to have an env variable set prior to building the image. Expected behavior would be to have an option to pass an env var(s) directly.

Example Use

  - prefect_docker.deployments.steps.build_docker_image:
      id: build_image
      requires: prefect-docker>=0.3.0
      image_name: jsopkin/my-test-image
      tag: latest
      dockerfile: Dockerfile
      push: true
      env: {MY_VARIABLE: "my-value"}

Additional context

This issue is referring to a use case where DOCKER_BUILDKIT needs to be set prior to building the Docker image

@jsopkin jsopkin added enhancement An improvement of an existing feature status:triage labels Jul 28, 2023
@zhen0
Copy link
Member

zhen0 commented Aug 1, 2023

@serinamarie @desertaxle - Can I get your help triaging this one? Is it something you've already considered? Thank you!

@desertaxle
Copy link
Member

desertaxle commented Aug 1, 2023

The build_docker_image step doesn't execute Docker commands via a shell and generally doesn't inspect any environment variables other than those needed for authentication. This is due to the behavior of the underlying docker-py library.

If I understand correctly, the requested feature is to support Docker's BuildKit in build_docker_image. That has been requested in #12922, and we've seen this request at least thrice. Unfortunately, docker-py doesn't support using BuildKit, and we would need to switch prefect-docker's docker-py dependency to a different Docker library.

I understand that BuildKit makes Docker image builds faster, which is a nice feature, but it shouldn't be blocking any users. If it blocks users or many users are requesting this, we can explore our options for adding BuildKit support.

@jsopkin
Copy link
Contributor Author

jsopkin commented Aug 1, 2023

@desertaxle Apologies about the duplicate. This was specifically requested by a client attempting to build images with private libraries using BuildKit. I can advise them that this isn't supported and to use another method

@desertaxle
Copy link
Member

No worries @Bada-S! Feel free to add any details for their use case on the linked issue. If they absolutely need BuildKit, let us know and we can look into adding support.

@EmilRex
Copy link
Contributor

EmilRex commented Aug 2, 2023

Looks like perhaps it's settable at the daemon level. Might be a viable alternative.

@EmilRex
Copy link
Contributor

EmilRex commented Aug 2, 2023

Linking the relevant docker-py issue: docker/docker-py#2230

@desertaxle
Copy link
Member

Thanks for the info @EmilRex! I've linked to your comment in #12922.

I'm going to close this issue as a duplicate of #12922, but feel free to add comments on that issue as needed.

@desertaxle desertaxle closed this as not planned Won't fix, can't repro, duplicate, stale Aug 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement An improvement of an existing feature
Projects
None yet
Development

No branches or pull requests

4 participants