-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Support private registries #8550
Conversation
Codecov Report
@@ Coverage Diff @@
## main #8550 +/- ##
==========================================
+ Coverage 12.31% 15.37% +3.05%
==========================================
Files 20 35 +15
Lines 1161 3122 +1961
==========================================
+ Hits 143 480 +337
- Misses 1014 2608 +1594
- Partials 4 34 +30
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Many thanks for implementing this super valuable feature! 🙏 💯
Briefly reviewed the environment variable code, and left a few suggestions in-line. TL;DR -- please only "hydrate" values just when they're actually needed, in order to not pass them around clear-text too much.
@jankeromnes Thank you for your feedback. I've reverted the early "hydration" of the project-level environment variables and pushed it back to the actual point of use. PTAL. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome, many thanks for the quick fix!
I've reviewed the environment variables handling code, and it looks good to me. 👍
I haven't looked too closely at the Go code or the image-source-provider.ts
changes.
Please let me know if you'd like me to test this PR.
To use it, add an environment variable named
GITPOD_IMAGE_AUTH
to your project. The content of that environment variable looks like:
domain.com:<base64(username:password)> anotherdomain.com:...
Two minor thoughts:
- The code seems to split on
,
instead of Why base64-encode theEDIT: Nevermind, I just noticed that the response is literally the next sentence 😅username:password
part? (As a user, I'd find it more convenient to specifydomain.com:username:password
directly)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
reviewed go related changes. only one minor comment.
is that a local cluster level registry? or registry at eu.gcr.io? |
# give the old pod time to disappear | ||
sleep 20 | ||
gpctl debug logs image-builder-mk3 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
gpctl debug logs image-builder-mk3 | |
gpctl debug logs image-builder-mk3 | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure I understand the comment :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the fix that the github warns about because there is no new line. There is no specific problem, so it is a minor nits.
https://thoughtbot.com/blog/no-newline-at-end-of-file
I just used |
/werft run 👍 started the job as gitpod-build-cw-fix-1699.7 |
build is green again. @geropl this needs your approval due to API changes. |
Does this suppose to work with Gitlab Registry? Might be related with #8938 and #8795.
Due to issue #8536 I could not setup variable per project, so I added the variable to global settings. |
I believe this doesn't work for self-hosted (yet?) because it makes use of Project vars, and the global Variables are ignored? In order to get this working in the FROM line of a Dockerfile for a workspace, I believe the BOB_WSLAYER_AUTH env var needs to be set up by Image Builder MK3 when it starts a Image Build. This is the whole of the "auths" var from a standard Docker config.json with auth/creds for private registries. Not sure how that will get passed over to the Image Builder MK3 -- use ImagePullSecrets somewhere? |
I am unable to use a private image from hub.docker.com even after I added GITPOD_IMAGE_AUTH accordingly. Any help? |
What do you see when you open the workspace? |
you need to add the repo to a gitpod project , then add the variable to the project, not personal |
I just tried create a project at https://gitpod.io/projects, and added the variable GITPOD_IMAGE_AUTH to the project's Settings and then create a new workspace from that project still no luck... |
double and triple check the value of the token - I know this works because we're using this for every single one of our repos across dozens of developers every day Getting the value of the token right was our biggest hurdle ;) |
The value is domain:<base64 encoded value> echo -n "<domain>:"; echo <username>:<password> | base64 -w0 are you sure the domain is index.docker.io ? |
@jmls I am not sure if the domain is index.docker.io. But that's what I get from the docker login command. I found that the token is not the same with "echo : | base64 -w0" and the one from .json. |
Do you use the private image directly, or as part of a Dockerfile? |
oh, I forgot that a custom image on the dockerfile is not supported atm You have to specify a custom image in the gitpod.yml |
dockerhub-user/imagename:latest |
Please try using
Reasoning: $ oci-tool resolve --familiar name csweichel/werft:latest
docker.io/csweichel/werft:latest@sha256:332fd69ac3784ac57580eb61f48176e95da0f1183b826c3d732b51508c1436d2 |
@csweichel, @jmls it's working now. Thanks a lot! However, this line of command didn't work
I succeeded by using the token obtained from
and added GITPOD_IMAGE_AUTH to the project's Variables by docker.io:TOKEN_OBTAINED |
Btw, it is a bit confusing that "Projects" tab resides inside user's Setting. I didn't notice there was a "project" specific scope setting and environment variables.... |
I tried again with this approach today. It only works if
It doesn't work if the docker image was never public @csweichel |
@Keith-Hon @jmls Thanks for your report! Can I ask you to create a new issue to prioritize to address? |
Ok created
|
@Keith-Hon Thanks! |
As a note here until docs are live - this snippet needs the second echo to have -n also, it's throwing a carriage return onto the string. Using the below example you don't need to extract the credential from config.json.
|
Description
This PR adds rudimentary support for images from private registries. It does that by virtue of project-level environment variables.
To use it, add an environment variable named
GITPOD_IMAGE_AUTH
to your project. The content of that environment variable looks like:domain.com:<base64(username:password)>, anotherdomain.com:...
This format is akin to dockerconfig.json files, where the
auth
section contains the same base64 encoded string. For example, logging into to the GitHub registry (ghcr.io) using:produces an entry akin to:
That very base64 encoded string can be used. It would turn into:
Once this variable is present, private images can be used directly, e.g.
Caveats
FROM my-private-repo.com/secret-sauce:latest
)right now the project level environment variable must NOT be "hidden". I'm looking to change that..gitpod.yml
refers to a "moving tag" (thinkdocker.io/somthing:latest
), and we need to rebuild the "gitpod workspace image", we'd re-resolve that tag, which might lead to changing workspace images across restarts for the very same workspace.Related Issue(s)
Fixes #1699
How to test
See PR description. I tested with ghcr.io
Release Notes
Documentation
https://github.com/gitpod-io/website/issues/1704