jenkins-pipelines/scripts/lib
Davlet Panech 8078abccbc Login to docker hub + better docker configuration
This patch contains improvements that avoid hitting DockerHub download
rate limits. Add logic to login to DockerHub at various stages in the
build.

* New config option DOCKER_CONFIG specifies a directory with docker CLI
  configuration files and defaults to $HOME/.docker. This env var is
  recognized by docker CLI and is used whenever Jenkins scripts in this
  repo access docker on the host, eg when running rsync within a
  container.

* Old config option DOCKER_CONFIG_FILE is now deprecated in favor of
  $DOCKER_CONFIG/config.json ; but still supported with a warning. If
  specified, it will be used only to authenticate app container builds.

* New sub-job: docker-host-login: execute "docker login" before doing
  anything else. This makes sure host docker daemon and subsequent
  "docker build" etc are authenticated. This step, and all subsequent
  docket operations, used configuration specified by $DOCKER_CONFIG.
  Builds using different credentials will not interfere with each
  other.

* Rename  DOCKER_REGISTRY_PUSH_LOGIN_LIST => DOCKER_REGISTRY_LOGIN_LIST
  Old name is still supported with a warning. Always login to these
  registries within the builder container, rather than only before
  pushing app containers. The intent is for this parameter to contain
  "docker.io" in most situations; otherwise we will use anonymous access
  to DockerHub, which may hit the download rate limit more frequently.

* If DOCKER_REGISTRY_LOGIN_LIST contains "docker.io", add
  "--dockerhub-login" when calling "stx-init-env". This makes sure we
  additionally authenticate minikube's embedded docker daemon used
  to build/pull builder images in that environment.

LIMITATIONS
=================

K8s itself may pull images anonymously from docker hub. This can happen
only with the images that we don't build ourselves, used for running
some of the builder containers, ie "nginx" and "docker" images, and only
if they are not already in the local docker's cache.

TESTING
=================
Set DOCKER_CONFIG to a custom directory with a config.json file.
Set DOCKER_REGISTRY_LOGIN_LIST="docker.io SOME_OTHER_REPO". Run a build
and make sure docker credentials are copied and applied inside the build
container.

Story: 2010055
Task: 48436

Change-Id: I23bf9817cce3ed833fa605d6448f9ef600e056b0
Signed-off-by: Davlet Panech <davlet.panech@windriver.com>
2023-07-31 10:25:36 -04:00
..
changelog_utils.sh Add license and copyright 2022-08-15 14:16:07 -04:00
glob_utils.sh Add license and copyright 2022-08-15 14:16:07 -04:00
job_utils.sh Login to docker hub + better docker configuration 2023-07-31 10:25:36 -04:00
log_utils.sh Better formatting for log messages 2022-09-21 11:30:53 -04:00
publish_utils.sh build.conf: new parameter ARCHIVE_BIG_DIRS 2023-04-24 14:24:45 -04:00
retries.sh Restore function "with_default_retries" 2023-05-25 17:21:13 -04:00
utils.sh New build step: build-export-dir 2022-08-30 21:29:32 -04:00