Skip to content

Private registry support - #3943

Closed
RonanQuigley wants to merge 1 commit into
dagger:mainfrom
findmypast:dagger-private-registry-support
Closed

RonanQuigley wants to merge 1 commit into
dagger:mainfrom
findmypast:dagger-private-registry-support

Conversation

@RonanQuigley

Copy link
Copy Markdown

Problem

Dagger used to support private registries via a custom buildkit instance. This made use of docker bind mounts. Here's an example:

docker run --net=host -d --restart always -v  /private/registry/cert.crt:/etc/ssl/certs/ca.crt --name dagger-buildkitd --privileged moby/buildkit:v0.10.5 --debug

However, from speaking to some of the maintainers on Discord, for various reasons it was removed. I'd like to get this brought back, even at the very least as an "official" escape hatch in the short term.

To give some background as to why I need this: the company that I work for, Findmypast, uses a private registry for hosting all of our images. With no viable way for the engine to publish an image to a private registry, we would not be able to migrate from Usher, our in house task runner, to Dagger.

Options

[Please note that these implementations are a total fudge, only somewhat tested, and is just a draft. I'm happy to change the approach if need be or have it dumped in favour of something else. I'd just like to get something usable in the short-term that can unblock us]

I've put together two options: neither should require the user to start up their own instance of the engine.

Option 1 - Engine reads an env var

The engine will read an env var that passes in one or more bind mounts like so:

DAGGER_ENGINE_BIND_MOUNTS=/foo/bar.txt:/foo/bar.txt,/fiz/buzz.txt

When the engine is started by an SDK, it checks for this var and adds as many mounts as required via -v to the docker run command that's ran under the hood to start the engine.

To test this locally I ran:

DAGGER_ENGINE_BIND_MOUNTS=/whatever/cert.crt:/etc/ssl/certs/ca.crt,/var/run/docker.sock:/var/run/docker.sock go run ./cmd/engine-session/main.go 
apk add docker curl 
curl <registry>
docker login <registry>

You should see no more complaints about the certificate being signed by an unknown authority or that there was no such host.

Option 2 - SDK

This adds another parameter to the dagger engine: --engine-bind-mount so that under the hood the SDK would use this flag. It would be set at the connect call:

    client, err := dagger.Connect(ctx, 
        dagger.WithBindMounts([]string{"/private/registry/cert.crt:/etc/ssl/certs/ca.crt"}),
    )

For both options I used --net host so that the hosts file from the host was added to the engine container. I ran out of time to make that configurable.

I didn't manage to e2e test this as I could not figure out how to spin up a local instance of the engine. It looks like the Go SDK is set to pull a specific image down from the GitHub container registry or use the DAGGER_HOST env.

There's pros/cons to each, but if possible I'd like to focus on getting something usable in the short term.

Related issues

#2142
#3829

As a side, could this pull request also fix the issue 👀 ? #3913

@sipsma

sipsma commented Nov 22, 2022

Copy link
Copy Markdown
Contributor

@RonanQuigley thank you for the PR! We are figuring out exactly how we want to approach supporting use cases for custom deployments like this, but we will have an answer for you soon.

In the meantime, I'm curious if something like the following would work for you:

  1. We provide a base image (e.g. ghcr.io/dagger/engine)
  2. You pull that image and customize it by adding CAs
  3. You can then deploy that image yourself and tell dagger to SDKs to use it via an env var like _DAGGER_RUNNER_HOST=docker-container://<container name>

Nothing is fully decided yet but that's one direction we are considering.

@RonanQuigley

RonanQuigley commented Nov 22, 2022 •

Copy link
Copy Markdown
Author

@sipsma That could work, but won't you still need --net=host to be set to ensure that the /etc/hosts file is picked up? I can try implementing your suggestion this afternoon if I have the chance to try it out, or would you prefer to do it?

@RonanQuigley

Copy link
Copy Markdown
Author

@sipsma Hi, just wondering if there's been any movement on this?

@sipsma

sipsma commented Dec 1, 2022

Copy link
Copy Markdown
Contributor

@RonanQuigley Sorry about the delay, there was holiday in the US end of last week and we have been working on a launch of our graphql API beginning of this week. We are still finalizing some details around the first part of the solution to this problem, then there will be a few more things to figure out, but it's a top priority for us. I'll reach out to you when we have something ready and/or have questions for you.

@aluzzardi

aluzzardi commented Dec 14, 2022 •

Copy link
Copy Markdown
Contributor

Hey @RonanQuigley 👋

Just wanted to keep you in the loop -- we're actively looking into this:

@RonanQuigley

Copy link
Copy Markdown
Author

@aluzzardi Just wondering if there's been any movement on getting an official solution implemented? I'd like to stop using the fork I've made. 🙏

@sipsma

sipsma commented Dec 16, 2022

Copy link
Copy Markdown
Contributor

@RonanQuigley We're almost done with the changes in #3830, once those are released there will be an experimental way of pointing dagger at your own engine container you have custom provisioned. That will open the door to setting up an engine image yourself w/ the CAs configured ahead of time.

I realize that's pretty far from ideal+seamless though. As part of the larger discussions I realized there's a path to making some upstream changes to buildkit that would enable clients to provide CAs needed for registry pushes at runtime: moby/buildkit#3366

Buildkit is currently busy focusing on their upcoming release, so haven't heard back yet, but if I had to guess I'd think that change is likely to be the best path for making this easy.

@github-actions

Copy link
Copy Markdown
Contributor

This PR is stale because it has been open 14 days with no activity. Remove stale label or comment or this will be closed in 7 days.

@github-actions

github-actions Bot commented Jan 7, 2023

Copy link
Copy Markdown
Contributor

This PR was closed because it has been stalled for 7 days with no activity.

@github-actions github-actions Bot closed this Jan 7, 2023
@RonanQuigley

Copy link
Copy Markdown
Author

@sipsma 👋 Hey hey, just checking in to see where this is at?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants