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 support for --secret option for buildkit support. #786

Closed
wants to merge 1 commit into from
Closed

Add support for --secret option for buildkit support. #786

wants to merge 1 commit into from

Conversation

ehengao
Copy link

@ehengao ehengao commented Mar 24, 2020

Signed-off-by: Heng GAO [email protected]

Description

I add a flag in the build command called --buildkit-secret to support one of the docker buildkit
option described in here:
https://docs.docker.com/develop/develop-images/build_enhancements/#new-docker-build-secret-information

The reason for this change is because i have this function depends on a private pypi repository which require senstive access information. To avoid put my credentials into the images, i decided to make this change to take the benifit of using docker buildkit to protect my secrets.

The flag added to the --buildkit-secret is same as the docker build --secret, i have successfully built this change and applied it locally to create a image using following command:

DOCKER_BUILDKIT=1 faas-cli build --no-cache --buildkit-secret id=netrc,src=${HOME}/.netrc -f hello.yml

And in my dockerfile, i need to specify following changes to make this work:

# syntax = docker/dockerfile:1.0-experimental
FROM openfaas/of-watchdog:0.7.2 as watchdog
FROM python:3.8-slim

...

RUN --mount=type=secret,id=netrc,dst=/root/.netrc pip install -r requirements.txt --extra-index-url ${EXTRA_INDEX_URL}

Motivation and Context

This change is required because user's function might have dependencies that hosted on private pypi or gitlab, this change will help user to built their functions more securely.

How Has This Been Tested?

New testing option added in the Test_buildFlagSlice to verify that the buildFlagSlice function can create the docker command flag correctly, and add a new testing function to make sure the docker command can be generated correctly.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I've read the CONTRIBUTION guide
  • I have signed-off my commits with git commit -s
  • I have added tests to cover my changes.
  • All new and existing tests passed.

@LucasRoesler
Copy link
Member

@ehengao i am not sure we are ready to merge this yet because we want to consider if there is a generic way to support a wider range of flags. Take a look at #785 (comment) and let us know what you think. Thanks

@talhof8
Copy link

talhof8 commented Oct 15, 2020

@LucasRoesler Any news or other plans to support the new Docker BuildKit?

@LucasRoesler
Copy link
Member

@talhof8 the design conversation is in #785 and we need to get @alexellis to approve

@simonoff simonoff mentioned this pull request Aug 9, 2022
10 tasks
@alexellis alexellis closed this Oct 18, 2022
@alexellis
Copy link
Member

We have gone for a simpler approach, and are validating it with OpenFaaS Pro customers.

Should anyone want to try this out, please contact us via the usual channels for customers.

@alexellis
Copy link
Member

/lock: resolved

@derek derek bot locked and limited conversation to collaborators Oct 18, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support for buildkit --secret option
5 participants