-
Notifications
You must be signed in to change notification settings - Fork 67
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
chore(ci): login to docker #2277
Merged
Merged
Changes from 12 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
c852139
login to docker
lerouxb 9a5a916
incorrect env var..
lerouxb 0a7a842
typo
lerouxb c16a1b0
the folder, not the file
lerouxb a8b40a0
missed some
lerouxb 9b20358
remember to update evergreen
lerouxb 3ace817
switch to using a credential helper rather than a credential store
lerouxb b96be95
no idea what to use as the default
lerouxb 128d1a5
Revert "no idea what to use as the default"
lerouxb ad052e8
Revert "switch to using a credential helper rather than a credential …
lerouxb 6c0fb2e
just remove the env var
lerouxb 19ab06d
Merge branch 'main' into login-docker-hub
lerouxb aaa77b0
bash syntax
lerouxb File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#!/bin/bash | ||
|
||
set -euo pipefail | ||
|
||
DOCKER_HUB_URL="https://index.docker.io/v1/" | ||
|
||
STDIN=$(cat) | ||
|
||
ACTION="$1" | ||
|
||
case "$ACTION" in | ||
get) | ||
SERVER_URL="$STDIN" | ||
|
||
if [[ "$SERVER_URL" == "$DOCKER_HUB_URL" ]]; then | ||
if [[ -z "${DOCKERHUB_USERNAME:-}" || -z "${DOCKERHUB_PASSWORD:-}" ]]; then | ||
echo "Error: DOCKERHUB_USERNAME or DOCKERHUB_PASSWORD environment variables are not set." >&2 | ||
exit 1 | ||
fi | ||
|
||
echo "{\"Username\": \"$DOCKERHUB_USERNAME\", \"Secret\": \"$DOCKERHUB_PASSWORD\"}" | ||
else | ||
echo "Error: No credentials available for $SERVER_URL" >&2 | ||
exit 1 | ||
fi | ||
;; | ||
|
||
*) | ||
echo "Unsupported action: $ACTION" >&2 | ||
exit 1 | ||
;; | ||
esac |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"auths": { | ||
"https://index.docker.io/v1/": {} | ||
}, | ||
"credsStore": "from-env" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
A problem is that by specifying credsStore, the docker-credential-from-env script gets used for all stores. And at that point I can't tell if there's a way for the script to signal that a specific registry should be used without authentication.
What then happens is that we don't have credentials for registry.suse.com and then our script errors.
There is an alternative to credsStore which is credHelpers where you can specify a credential helper per registry domain. I tried it, but no matter what I used as the registry domain for docker hub I couldn't get it to use our script, so everything just worked unauthenticated. I looked online and can't find any examples where people specify the default docker hub registry domain in there so I'm beginning to think that it doesn't work for that case.
Unless I misread the docs or had some silly typo throughout all my tests? Not sure.
So what I'm doing now is to just specify credsStore which at least works in that it executes our script and then I just remove the DOCKER_CONFIG var for the suse cases. Which is an ugly hack and will probably stop working if we mix suse and regular docker images together in one script.