Skip to content

feat: pass secrets to Container.Build and Directory.Build - #4971

Merged
dolanor merged 2 commits into
dagger:mainfrom
dolanor:pass-secret-to-container-build
Apr 20, 2023
Merged

dolanor merged 2 commits into
dagger:mainfrom
dolanor:pass-secret-to-container-build

Conversation

@dolanor

@dolanor dolanor commented Apr 18, 2023 •

Copy link
Copy Markdown
Contributor

Now you can pass secrets to a Dockerfile build like in docker with

RUN --mount=type=secret,id=xxx,dst=/run/secrets/xxx
docker build --secret id=xxx,src=/my/file .

You can use

type Container {
    build(dockerfile: [String], platform: [Platform], buildArgs: [BuildArg!], target: String, secrets: [SecretID!]): Container!
}

type Directory {
    dockerBuild(dockerfile: [String], platform: [Platform], buildArgs: [BuildArg!], target: String, secrets: [SecretID!]): Container!
}

Limitations

It will mount in /run/secrets/<secret-id>, you cannot decide the target mount point with this current API.
It could be improved later on and discussed on how the API should look like.

@dolanor
dolanor marked this pull request as draft April 18, 2023 10:59
@dolanor dolanor linked an issue Apr 18, 2023 that may be closed by this pull request
@dolanor
dolanor force-pushed the pass-secret-to-container-build branch 4 times, most recently from 6ba36ae to 93be4ad Compare April 18, 2023 21:24
@dolanor
dolanor force-pushed the pass-secret-to-container-build branch from 93be4ad to 4fe94e2 Compare April 18, 2023 21:51
@dolanor
dolanor marked this pull request as ready for review April 18, 2023 22:14
@dolanor
dolanor requested review from marcosnils, sipsma and vito April 18, 2023 22:15
@dolanor
dolanor force-pushed the pass-secret-to-container-build branch from 4fe94e2 to e863c45 Compare April 18, 2023 22:24
Comment thread core/secret.go Resolved
Comment thread core/integration/container_test.go Resolved
@dolanor
dolanor force-pushed the pass-secret-to-container-build branch from e863c45 to bd70109 Compare April 19, 2023 21:23

@TomChv TomChv left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, left comments

Comment thread core/schema/container.graphqls Resolved
Comment thread core/schema/directory.graphqls Resolved
@dolanor
dolanor force-pushed the pass-secret-to-container-build branch from bd70109 to 5ea6513 Compare April 20, 2023 01:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Access secrets from a Dockerfile

3 participants