Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
E
eic_container
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
containers
eic_container
Merge requests
!706
feat: use official docker image
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
feat: use official docker image
use-official-docker-image
into
master
Overview
1
Commits
29
Pipelines
0
Changes
1
Merged
Wouter Deconinck
requested to merge
use-official-docker-image
into
master
1 year ago
Overview
1
Commits
29
Pipelines
0
Changes
1
Expand
0
0
Merge request reports
Viewing commit
7c591689
Show latest version
1 file
+
0
−
110
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
7c591689
Delete docker_login.sh
· 7c591689
Wouter Deconinck
authored
1 year ago
gitlab-ci/docker_login.sh deleted
100755 → 0
+
0
−
110
Options
#!/bin/bash
## Resilient docker login with multiple progressive retries in case of TLS issues
function
print_the_help
{
echo
"USAGE: -u user -p -password [...] [registry]"
echo
"ARGUMENTS:"
echo
" -u,--user Registry user"
echo
" -p,--password Registry password"
echo
" --ci Login to internal CI registry; -u, -p and positional are ignored"
echo
" -t,--time Time interval (in seconds) between attempts"
echo
" (doubled each time), default: 5"
echo
" -n,--n-attempts Number of attempts, default: 5"
echo
" -h,--help Print this message"
echo
" positional Registry name (will use dockerhub if none given)"
echo
""
echo
" Login to registry."
echo
""
echo
"EXAMPLE: ./docker_login.sh -u
\$
CI_REGISTRY_USER -p
\$
CI_REGISTRY_PASSWORD
\$
CI_REGISTRY"
exit
}
REGISTRY
=
REG_USER
=
REG_PASSWORD
=
NTRIES
=
5
TIME
=
5
CI
=
while
[
$#
-gt
0
]
;
do
key
=
$1
case
$key
in
-u
|
--user
)
REG_USER
=
$2
shift
shift
;;
-p
|
--password
)
REG_PASSWORD
=
$2
shift
shift
;;
--ci
)
CI
=
1
shift
;;
-t
|
--time
)
TIME
=
$2
shift
shift
;;
-n
|
--n-attempts
)
NTRIES
=
$2
shift
shift
;;
-h
|
--help
)
print_the_help
exit
0
;;
-
*
)
echo
"ERROR: unknown flag:
$key
"
echo
"use --help for more info"
exit
1
;;
*
)
REGISTRY+
=
"
$1
"
shift
;;
esac
done
## only sanizize input if not in CI registry mode
if
[
-z
$CI
]
;
then
if
[
-z
$REG_USER
]
;
then
echo
"ERROR: no username given, please use -u <USER>"
print_the_help
exit
1
fi
if
[
-z
$REG_PASSWORD
]
;
then
echo
"ERROR: no password given, please use -p <PASSWORD>"
print_the_help
exit
1
fi
else
REGISTRY
=
$CI_REGISTRY
REG_USER
=
$CI_REGISTRY_USER
fi
while
[
$NTRIES
!=
0
]
;
do
if
[
-z
$CI
]
;
then
echo
$REG_PASSWORD
| docker login
-u
$REG_USER
\
--password-stdin
$REGISTRY
\
&&
break
\
||
echo
"Login failed, retrying in
$TIME
seconds..."
else
echo
$CI_REGISTRY_PASSWORD
| docker login
-u
$REG_USER
\
--password-stdin
$REGISTRY
\
&&
break
\
||
echo
"Login failed, retrying in
$TIME
seconds..."
fi
sleep
${
TIME
}
s
TIME
=
$((
TIME
*
2
))
NTRIES
=
$((
NTRIES
-
1
))
done
if
[
$NTRIES
=
0
]
;
then
echo
"Failed to login to registry
$REGISTRY
"
exit
1
fi
echo
"Docker login to
$REGISTRY
successful"
Loading