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

Pass file secrets to "podman build" via parameter "--secret" #777

Merged
merged 1 commit into from
Mar 27, 2024
Merged

Pass file secrets to "podman build" via parameter "--secret" #777

merged 1 commit into from
Mar 27, 2024

Conversation

wiehe
Copy link
Contributor

@wiehe wiehe commented Sep 20, 2023

Dear maintainers!

At the moment podman-compose always passes file secrets to podman as a --volume option, both when starting containers and when building images.
I propose that file secrets for building are instead passed as a --secret option. This would make them available for
RUN --mount=type=secret… instructions and would improve compatibility with docker-compose.

Example

# Dockerfile
FROM busybox
RUN --mount=type=secret,required=true,id=my_secret,target=/root/my_secret \
		echo "The secret is: "; cat /root/my_secret

To build directly from this Dockerfile one has to supply the secret like this:
podman build --secret=id=my_secret,src=./my_secret .

# docker-compose.yaml
services:
  my-service:
    build:
      context: .
      secrets:
        - my_secret

secrets:
  my_secret:
    file: ./my_secret

Building from the docker-compose.yaml with podman-compose build my-service should produce the same results as the podman build … command above.

Yours sincerely
wiehe

Copy link
Collaborator

@p12tic p12tic left a comment

Choose a reason for hiding this comment

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

Thanks for the PR. It looks good.

Please rebase on top of latest main branch and add unit tests (see pytest/ directory for examples).

to make them available for "RUN --mount=type=secret" statements inside the
Dockerfile.

Keep using --volume to pass file secrets to "podman run".

Signed-off-by: wiehe <[email protected]>
@wiehe
Copy link
Contributor Author

wiehe commented Mar 12, 2024

Hi, thanks for considering my pull request! I have rebased it onto main and ported the test script from pytest to unittest.

@p12tic p12tic merged commit 6103df7 into containers:main Mar 27, 2024
8 checks passed
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.

2 participants