Commit d65ca162 authored by Matt Pryor's avatar Matt Pryor
Browse files

Push images to Docker Hub instead of GitLab

parent 3fd793eb
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -9,3 +9,5 @@ _site/
.project
.vscode
.python-version
.vagrant
kubeconfig
 No newline at end of file
+13 −7
Original line number Diff line number Diff line
@@ -4,6 +4,15 @@ stages:
  - build-3
  - build-4

variables:
  # By default, push to the esgfdeploy organisation on Docker Hub using the esgfci user
  # The password should be set as a CI/CD variable in the GitLab interface
  REGISTRY: docker.io
  REGISTRY_USER: esgfci
  REPOSITORY_BASE: esgfdeploy

# Base for Docker-in-Docker jobs
# Sets up authentication with the configured registry, which defaults to Docker Hub
.dind:
  services:
    - docker:19.03-dind
@@ -13,24 +22,21 @@ stages:
    DOCKER_TLS_CERTDIR: ""
  before_script:
    - docker info
    # Use the GitLab container registry by default
    - REGISTRY="${REGISTRY:-$CI_REGISTRY}"
    - REGISTRY_USER="${REGISTRY_USER:-$CI_REGISTRY_USER}"
    # Allow the password to come from a file
    - test -z "$REGISTRY_PASSWORD" && test -f "$REGISTRY_PASSWORD_FILE" && REGISTRY_PASSWORD="$(cat "$REGISTRY_PASSWORD_FILE")"
    # Also allow the password to be base64 encoded (GitLab masked variables must be base64-encoded)
    - test -z "$REGISTRY_PASSWORD" && test -n "$REGISTRY_PASSWORD_B64" && REGISTRY_PASSWORD="$(echo -n "$REGISTRY_PASSWORD_B64" | base64 -d)"
    # If not given, use the GitLab container registry password
    - REGISTRY_PASSWORD="${REGISTRY_PASSWORD:-$CI_REGISTRY_PASSWORD}"
    # If there is still no password, bail
    - test -z "$REGISTRY_PASSWORD" && echo "REGISTRY_PASSWORD is required" 1>&2 && exit 1
    - docker login -u $REGISTRY_USER -p $REGISTRY_PASSWORD $REGISTRY

# Base for Docker build jobs
# Build and push a Docker image to the primary registry, which defaults to Docker Hub
.docker-build:
  extends: .dind
  script:
    # Use the basename of the context directory as the image name
    - IMAGE_NAME="${IMAGE_NAME:-"$(basename $CONTEXT_DIR)"}"
    # By default, use the GitLab container registry for the project
    - REPOSITORY_BASE="${REPOSITORY_BASE:-$CI_REGISTRY_IMAGE}"
    - REPOSITORY="${REPOSITORY:-"$REPOSITORY_BASE/$IMAGE_NAME"}"
    # Set build args so that child images pick up the correct parents
    - export BUILD_ARG_ESGF_REPOSITORY_BASE="$REPOSITORY_BASE"
+1 −1
Original line number Diff line number Diff line
@@ -4,7 +4,7 @@ hostname:
# All image properties can be overridden on a per-service basis
image:
  # The image repository prefix
  prefix: esgfhub
  prefix: esgfdeploy
  # The tag to use
  tag: latest
  # The image pull policy