Skip to content

docs: mount dir as secret cookbook - #5502

Merged
grouville merged 1 commit into
dagger:mainfrom
grouville:mount-dir-as-secret-docs
Jul 28, 2023
Merged

grouville merged 1 commit into
dagger:mainfrom
grouville:mount-dir-as-secret-docs

Conversation

@grouville

@grouville grouville commented Jul 21, 2023 •

Copy link
Copy Markdown
Member

Fixes #4896

⚠️ PUBLISH AFTER v0.8.0 RELEASE, depends on #5500

Small cookbook example / wrapper with the .with() method showing how to mount directories securely

@grouville

grouville commented Jul 24, 2023 •

Copy link
Copy Markdown
Member Author

For reference purposes, it works perfectly: https://gist.github.com/grouville/8aae4c02c1036ebdfac196545f0cb3ac.

Here is the output:

Go SDK

go run .
12: resolve image config for docker.io/library/alpine:3.17
12: > in from alpine:3.17
12: resolve image config for docker.io/library/alpine:3.17 DONE

34: pull docker.io/library/alpine:3.17
34: > in from alpine:3.17
34: resolve docker.io/library/alpine:3.17@sha256:e95676db9e4a4f16f6cc01a8915368f82b018cc07aba951c1bd1db586c081388
34: resolve docker.io/library/alpine:3.17@sha256:e95676db9e4a4f16f6cc01a8915368f82b018cc07aba951c1bd1db586c081388 [0.01s]
34: pull docker.io/library/alpine:3.17 DONE

31: exec chmod 700 /root/.gnupg CACHED
31: exec chmod 700 /root/.gnupg CACHED

32: exec apk add --no-cache gnupg CACHED
32: exec apk add --no-cache gnupg CACHED

30: exec chmod 700 /root/.gnupg/private-keys-v1.d CACHED
30: exec chmod 700 /root/.gnupg/private-keys-v1.d CACHED

29: exec gpg --import /root/.gnupg/public.key
29: [0.18s] gpg: WARNING: unsafe permissions on homedir '/root/.gnupg'
29: [0.18s] gpg: key 3CCB68B1170F9A36: "guigui <[email protected]>" not changed
29: [0.18s] gpg: Total number processed: 1
29: [0.18s] gpg:              unchanged: 1
29: exec gpg --import /root/.gnupg/public.key DONE

28: exec gpg --import /root/.gnupg/private-keys-v1.d/private.key
28: [0.16s] gpg: WARNING: unsafe permissions on homedir '/root/.gnupg'
28: [0.16s] gpg: key 3CCB68B1170F9A36: "guigui <[email protected]>" not changed
28: [0.16s] gpg: key 3CCB68B1170F9A36: secret key imported
28: [0.16s] gpg: Total number processed: 1
28: [0.16s] gpg:              unchanged: 1
28: [0.16s] gpg:       secret keys read: 1
28: [0.16s] gpg:   secret keys imported: 1
28: exec gpg --import /root/.gnupg/private-keys-v1.d/private.key DONE

27: exec gpg --detach-sign --armor /bin/ls
27: [0.16s] gpg: WARNING: unsafe permissions on homedir '/root/.gnupg'
27: [0.16s] gpg: Note: trustdb not writable
27: exec gpg --detach-sign --armor /bin/ls DONE

26: exec ls -l /bin/ls.asc
26: [0.15s] -rw-r--r--    1 root     root           228 Jul 24 14:32 /bin/ls.asc
26: exec ls -l /bin/ls.asc DONE
-rw-r--r--    1 root     root           228 Jul 24 14:32 /bin/ls.asc

The signature has been properly done ✅

Node SDK

node --loader ts-node/esm ./main.mts
(node:56632) ExperimentalWarning: Custom ESM Loaders is an experimental feature. This feature could change at any time
(Use `node --trace-warnings ...` to show where the warning was created)
-rw-r--r--    1 root     root           228 Jul 24 14:32 /bin/ls.asc

Python SDK

python3 main.py
12: resolve image config for docker.io/library/alpine:3.17
12: > in from alpine:3.17
12: resolve image config for docker.io/library/alpine:3.17 DONE

34: pull docker.io/library/alpine:3.17
34: > in from alpine:3.17
34: resolve docker.io/library/alpine:3.17@sha256:e95676db9e4a4f16f6cc01a8915368f82b018cc07aba951c1bd1db586c081388
34: resolve docker.io/library/alpine:3.17@sha256:e95676db9e4a4f16f6cc01a8915368f82b018cc07aba951c1bd1db586c081388 [0.01s]
34: pull docker.io/library/alpine:3.17 DONE

26: exec ls -l /bin/ls.asc CACHED
26: exec ls -l /bin/ls.asc CACHED

27: exec gpg --detach-sign --armor /bin/ls CACHED
27: exec gpg --detach-sign --armor /bin/ls CACHED

28: exec gpg --import /root/.gnupg/private-keys-v1.d/private.key CACHED
28: exec gpg --import /root/.gnupg/private-keys-v1.d/private.key CACHED

29: exec gpg --import /root/.gnupg/public.key CACHED
29: exec gpg --import /root/.gnupg/public.key CACHED

30: exec chmod 700 /root/.gnupg/private-keys-v1.d CACHED
30: exec chmod 700 /root/.gnupg/private-keys-v1.d CACHED

31: exec chmod 700 /root/.gnupg CACHED
31: exec chmod 700 /root/.gnupg CACHED

32: exec apk add --no-cache gnupg CACHED
32: exec apk add --no-cache gnupg CACHED
-rw-r--r--    1 root     root           228 Jul 24 14:32 /bin/ls.asc

Local docs overview

image

@grouville
grouville force-pushed the mount-dir-as-secret-docs branch 2 times, most recently from 8e1a115 to 4d0efce Compare July 24, 2023 15:51
@grouville
grouville marked this pull request as ready for review July 24, 2023 15:51
@grouville
grouville force-pushed the mount-dir-as-secret-docs branch from 4d0efce to da0fe51 Compare July 24, 2023 15:56
@grouville
grouville force-pushed the mount-dir-as-secret-docs branch from da0fe51 to 088e13a Compare July 24, 2023 16:03
Comment thread docs/current/742989-cookbook.md Resolved

@vikram-dagger vikram-dagger left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@grouville nice work. I'm approving subject to an improvement regarding a sentence where the implication was not immediately clear to me - can you please add/clarify that point before merging? Thanks.

@helderco
helderco force-pushed the mount-dir-as-secret-docs branch from 088e13a to 6da1b37 Compare July 28, 2023 00:44
Small cookbook example / wrapper with the `.with()` method showing how to mount directories securely

Signed-off-by: grouville <[email protected]>
@grouville
grouville force-pushed the mount-dir-as-secret-docs branch from 6da1b37 to f24b319 Compare July 28, 2023 13:17
@grouville
grouville merged commit 05c3d65 into dagger:main Jul 28, 2023
grouville added a commit that referenced this pull request Jul 28, 2023
grouville added a commit that referenced this pull request Jul 28, 2023
@gerhard gerhard added the area/documentation Improvements or additions to documentation label Aug 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

✨Allow directories to be mounted as secrets

4 participants