Skip to content

Commit 52098dd

Browse files
authored
chore(evergreen): authenticate with docker so that we don't make unauthenticated pulls (#6498)
* docker login * rather log in when starting the envs * also login before starting atlas cloud cluster * also login for start-atlas-local * conditionally log into docker * invert the docker env var checks * also log out of docker * credsStore from-env * no need to login * unshift.. * print docker config
1 parent 3073719 commit 52098dd

File tree

5 files changed

+46
-0
lines changed

5 files changed

+46
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#!/bin/bash
2+
3+
set -euo pipefail
4+
5+
DOCKER_HUB_URL="https://index.docker.io/v1/"
6+
7+
STDIN=$(cat)
8+
9+
ACTION="$1"
10+
11+
case "$ACTION" in
12+
get)
13+
SERVER_URL="$STDIN"
14+
15+
if [[ "$SERVER_URL" == "$DOCKER_HUB_URL" ]]; then
16+
if [[ -z "${DOCKERHUB_USERNAME:-}" || -z "${DOCKERHUB_PASSWORD:-}" ]]; then
17+
echo "Error: DOCKERHUB_USERNAME or DOCKERHUB_PASSWORD environment variables are not set." >&2
18+
exit 1
19+
fi
20+
21+
echo "{\"Username\": \"$DOCKERHUB_USERNAME\", \"Secret\": \"$DOCKERHUB_PASSWORD\"}"
22+
else
23+
echo "Error: No credentials available for $SERVER_URL" >&2
24+
exit 1
25+
fi
26+
;;
27+
28+
*)
29+
echo "Unsupported action: $ACTION" >&2
30+
exit 1
31+
;;
32+
esac

.evergreen/docker-config/config.json

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"auths": {
3+
"https://index.docker.io/v1/": {}
4+
},
5+
"credsStore": "from-env"
6+
}

.evergreen/functions.yml

+2
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,8 @@ variables:
7878
GARASIGN_PASSWORD: ${garasign_password}
7979
ARTIFACTORY_USERNAME: ${artifactory_username}
8080
ARTIFACTORY_PASSWORD: ${artifactory_password}
81+
DOCKERHUB_USERNAME: ${dockerhub_username}
82+
DOCKERHUB_PASSWORD: ${dockerhub_password}
8183

8284
# This is here with the variables because anchors aren't supported across includes
8385
post:

.evergreen/preinstall.sh

+2
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ echo "IS_WINDOWS: $IS_WINDOWS"
1818
echo "IS_RHEL: $IS_RHEL"
1919
echo "IS_UBUNTU: $IS_UBUNTU"
2020

21+
echo "DOCKER_CONFIG: $DOCKER_CONFIG"
22+
2123
SCRIPTDIR="$(cd $(dirname "$0"); pwd)"
2224

2325
if [ -n "$IS_WINDOWS" ]; then

.evergreen/print-compass-env.js

+4
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,8 @@ function printCompassEnv() {
7474
pathsToPrepend.unshift('/opt/mongodbtoolchain/v4/bin');
7575
}
7676

77+
pathsToPrepend.unshift(`${originalPWD}/.evergreen/docker-config/bin`);
78+
7779
PATH = maybePrependPaths(PATH, pathsToPrepend);
7880
printVar('PATH', PATH);
7981

@@ -113,6 +115,8 @@ function printCompassEnv() {
113115

114116
// https://jira.mongodb.org/browse/NODE-6320
115117
printVar('GYP_DEFINES', `kerberos_use_rtld=${process.platform === 'linux'}`);
118+
119+
printVar('DOCKER_CONFIG', `${originalPWD}/.evergreen/docker-config`);
116120
}
117121

118122
printCompassEnv();

0 commit comments

Comments
 (0)