Skip to content

Commit c90120f

Browse files
authored
chore(ci): login to docker (#2277)
* login to docker * incorrect env var.. * typo * the folder, not the file * missed some * remember to update evergreen * switch to using a credential helper rather than a credential store * no idea what to use as the default * Revert "no idea what to use as the default" This reverts commit b96be95. * Revert "switch to using a credential helper rather than a credential store" This reverts commit 3ace817. * just remove the env var * bash syntax
1 parent 0886abf commit c90120f

File tree

6 files changed

+66
-0
lines changed

6 files changed

+66
-0
lines changed

.evergreen.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6907,6 +6907,8 @@ functions:
69076907
shell: bash
69086908
env:
69096909
NODE_JS_VERSION: ${node_js_version}
6910+
DOCKERHUB_USERNAME: ${dockerhub_username}
6911+
DOCKERHUB_PASSWORD: ${dockerhub_password}
69106912
script: |
69116913
set -e
69126914
{
@@ -6930,6 +6932,8 @@ functions:
69306932
NODE_JS_VERSION: ${node_js_version}
69316933
TEST_MONGOSH_EXECUTABLE: ${test_mongosh_executable|}
69326934
KERBEROS_JUMPHOST_DOCKERFILE: ${kerberos_jumphost_dockerfile|}
6935+
DOCKERHUB_USERNAME: ${dockerhub_username}
6936+
DOCKERHUB_PASSWORD: ${dockerhub_password}
69336937
script: |
69346938
set -e
69356939
{
@@ -7223,6 +7227,8 @@ functions:
72237227
DISTRO_ID_OVERRIDE: ${distro_id}
72247228
PACKAGE_VARIANT: ${package_variant}
72257229
ARTIFACT_URL_EXTRA_TAG: unsigned
7230+
DOCKERHUB_USERNAME: ${dockerhub_username}
7231+
DOCKERHUB_PASSWORD: ${dockerhub_password}
72267232
sign_artifact:
72277233
- command: expansions.write
72287234
type: setup
@@ -7329,6 +7335,8 @@ functions:
73297335
shell: bash
73307336
env:
73317337
NODE_JS_VERSION: ${node_js_version}
7338+
DOCKERHUB_USERNAME: ${dockerhub_username}
7339+
DOCKERHUB_PASSWORD: ${dockerhub_password}
73327340
script: |
73337341
set -e
73347342
set -x
@@ -7343,6 +7351,8 @@ functions:
73437351
shell: bash
73447352
env:
73457353
NODE_JS_VERSION: ${node_js_version}
7354+
DOCKERHUB_USERNAME: ${dockerhub_username}
7355+
DOCKERHUB_PASSWORD: ${dockerhub_password}
73467356
script: |
73477357
set -e
73487358
set -x
Lines changed: 32 additions & 0 deletions
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
Lines changed: 6 additions & 0 deletions
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/evergreen.yml.in

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -383,6 +383,8 @@ functions:
383383
shell: bash
384384
env:
385385
NODE_JS_VERSION: ${node_js_version}
386+
DOCKERHUB_USERNAME: ${dockerhub_username}
387+
DOCKERHUB_PASSWORD: ${dockerhub_password}
386388
script: |
387389
set -e
388390
{
@@ -406,6 +408,8 @@ functions:
406408
NODE_JS_VERSION: ${node_js_version}
407409
TEST_MONGOSH_EXECUTABLE: ${test_mongosh_executable|}
408410
KERBEROS_JUMPHOST_DOCKERFILE: ${kerberos_jumphost_dockerfile|}
411+
DOCKERHUB_USERNAME: ${dockerhub_username}
412+
DOCKERHUB_PASSWORD: ${dockerhub_password}
409413
script: |
410414
set -e
411415
{
@@ -635,6 +639,8 @@ functions:
635639
DISTRO_ID_OVERRIDE: ${distro_id}
636640
PACKAGE_VARIANT: ${package_variant}
637641
ARTIFACT_URL_EXTRA_TAG: unsigned
642+
DOCKERHUB_USERNAME: ${dockerhub_username}
643+
DOCKERHUB_PASSWORD: ${dockerhub_password}
638644
sign_artifact:
639645
- command: expansions.write
640646
type: setup
@@ -741,6 +747,8 @@ functions:
741747
shell: bash
742748
env:
743749
NODE_JS_VERSION: ${node_js_version}
750+
DOCKERHUB_USERNAME: ${dockerhub_username}
751+
DOCKERHUB_PASSWORD: ${dockerhub_password}
744752
script: |
745753
set -e
746754
set -x
@@ -755,6 +763,8 @@ functions:
755763
shell: bash
756764
env:
757765
NODE_JS_VERSION: ${node_js_version}
766+
DOCKERHUB_USERNAME: ${dockerhub_username}
767+
DOCKERHUB_PASSWORD: ${dockerhub_password}
758768
script: |
759769
set -e
760770
set -x

.evergreen/setup-env.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,9 @@ if [ "$OS" == "Windows_NT" ]; then
7575
export npm_config_logs_dir="$(cygpath -w "$npm_config_logs_dir")"
7676
fi
7777

78+
export DOCKER_CONFIG="$BASEDIR/docker-config"
79+
export PATH="$BASEDIR/docker-config/bin:$PATH"
80+
7881
echo "Running on:"
7982
uname -a
8083

scripts/docker/build.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@ cd "$(dirname "$0")"
66
# Used for verifying that we actually have a working csfle shared library
77
[ -x node_modules/mongodb-crypt-library-version ] || ((cd ../.. && npm ci) && cp -r ../../node_modules node_modules)
88
9+
# we don't have credentials for registry.suse.com and docker now requires them due to our config
10+
if [[ "$1" == suse* ]]; then
11+
unset DOCKER_CONFIG
12+
fi
13+
914
if [ x"$ARTIFACT_URL" = x"" ]; then
1015
SHA=`git rev-parse origin/main`
1116
VERSION=`git show ${SHA}:../../lerna.json | grep version | cut -d ":" -f 2 | cut -d '"' -f 2`

0 commit comments

Comments
 (0)