Skip to content

Instantly share code, notes, and snippets.

@gkarugi
Last active January 31, 2019 20:53
Show Gist options
  • Save gkarugi/f80bdd09a77489a9d61d8472fa228142 to your computer and use it in GitHub Desktop.
Save gkarugi/f80bdd09a77489a9d61d8472fa228142 to your computer and use it in GitHub Desktop.
Logging in to docker registries

Login to Docker registries Gitlab CI

Login to GCR

before_script:
  # Install CA certs, openssl to https downloads, python for gcloud sdk
  - apk add --update make ca-certificates openssl python
  - update-ca-certificates
  # Write our GCP service account private key into a file
  - echo "$GCLOUD_SERVICE_KEY" > gcloud-service-key.json
  # Download and install Google Cloud SDK
  - wget https://dl.google.com/dl/cloudsdk/release/google-cloud-sdk.tar.gz
  - tar zxvf google-cloud-sdk.tar.gz && ./google-cloud-sdk/install.sh --usage-reporting=false --path-update=true
  - google-cloud-sdk/bin/gcloud --quiet components update
  - google-cloud-sdk/bin/gcloud auth activate-service-account --key-file gcloud-service-key.json
  - docker login -u _json_key --password-stdin https://eu.gcr.io < gcloud-service-key.json

Login to azure CR

before_script:
  # Install CA certs, openssl to https downloads, python for gcloud sdk
  - apk add --update make ca-certificates openssl python
  - update-ca-certificates
  #login to azure container registry
  - docker login ${AZURE_CR_NAME}.azurecr.io -u $AZURE_CR_USERNAME -p $AZURE_CR_PASSWORD
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment