diff --git a/.evergreen.yml b/.evergreen.yml index 2fc826de8..ce4fc3ef8 100644 --- a/.evergreen.yml +++ b/.evergreen.yml @@ -6907,6 +6907,8 @@ functions: shell: bash env: NODE_JS_VERSION: ${node_js_version} + DOCKERHUB_USERNAME: ${dockerhub_username} + DOCKERHUB_PASSWORD: ${dockerhub_password} script: | set -e { @@ -6930,6 +6932,8 @@ functions: NODE_JS_VERSION: ${node_js_version} TEST_MONGOSH_EXECUTABLE: ${test_mongosh_executable|} KERBEROS_JUMPHOST_DOCKERFILE: ${kerberos_jumphost_dockerfile|} + DOCKERHUB_USERNAME: ${dockerhub_username} + DOCKERHUB_PASSWORD: ${dockerhub_password} script: | set -e { @@ -7329,6 +7333,8 @@ functions: shell: bash env: NODE_JS_VERSION: ${node_js_version} + DOCKERHUB_USERNAME: ${dockerhub_username} + DOCKERHUB_PASSWORD: ${dockerhub_password} script: | set -e set -x @@ -7343,6 +7349,8 @@ functions: shell: bash env: NODE_JS_VERSION: ${node_js_version} + DOCKERHUB_USERNAME: ${dockerhub_username} + DOCKERHUB_PASSWORD: ${dockerhub_password} script: | set -e set -x diff --git a/.evergreen/docker-config/bin/docker-credential-from-env b/.evergreen/docker-config/bin/docker-credential-from-env new file mode 100755 index 000000000..7af2b9a47 --- /dev/null +++ b/.evergreen/docker-config/bin/docker-credential-from-env @@ -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 \ No newline at end of file diff --git a/.evergreen/docker-config/config.json b/.evergreen/docker-config/config.json new file mode 100644 index 000000000..353cd057b --- /dev/null +++ b/.evergreen/docker-config/config.json @@ -0,0 +1,6 @@ +{ + "auths": { + "https://index.docker.io/v1/": {} + }, + "credsStore": "from-env" +} diff --git a/.evergreen/evergreen.yml.in b/.evergreen/evergreen.yml.in index a3c4138a9..4c757c9e7 100644 --- a/.evergreen/evergreen.yml.in +++ b/.evergreen/evergreen.yml.in @@ -383,6 +383,8 @@ functions: shell: bash env: NODE_JS_VERSION: ${node_js_version} + DOCKERHUB_USERNAME: ${dockerhub_username} + DOCKERHUB_PASSWORD: ${dockerhub_password} script: | set -e { @@ -406,6 +408,8 @@ functions: NODE_JS_VERSION: ${node_js_version} TEST_MONGOSH_EXECUTABLE: ${test_mongosh_executable|} KERBEROS_JUMPHOST_DOCKERFILE: ${kerberos_jumphost_dockerfile|} + DOCKERHUB_USERNAME: ${dockerhub_username} + DOCKERHUB_PASSWORD: ${dockerhub_password} script: | set -e { @@ -741,6 +745,8 @@ functions: shell: bash env: NODE_JS_VERSION: ${node_js_version} + DOCKERHUB_USERNAME: ${dockerhub_username} + DOCKERHUB_PASSWORD: ${dockerhub_password} script: | set -e set -x @@ -755,6 +761,8 @@ functions: shell: bash env: NODE_JS_VERSION: ${node_js_version} + DOCKERHUB_USERNAME: ${dockerhub_username} + DOCKERHUB_PASSWORD: ${dockerhub_password} script: | set -e set -x diff --git a/.evergreen/setup-env.sh b/.evergreen/setup-env.sh index 8b9a38ad9..37311eb25 100755 --- a/.evergreen/setup-env.sh +++ b/.evergreen/setup-env.sh @@ -75,6 +75,9 @@ if [ "$OS" == "Windows_NT" ]; then export npm_config_logs_dir="$(cygpath -w "$npm_config_logs_dir")" fi +export DOCKER_FILE="$BASEDIR/docker-config/config.json" +export PATH="BASEDIR/docker-config/bin:$PATH" + echo "Running on:" uname -a