I am trying to push a docker image from .gitlab-ci.yml to container registry of google cloud platfor
Tried accessing the token of gcp so that it allows me to push
image: docker:latest
services:
- docker:dind
variables:
WORK_DIR: ${CI_PROJECT_NAME}
BRANCH: ${CI_COMMIT_REF_NAME}
REGISTRY: registry.gitlab.com/prakashkumar3117/cicd-tutorial:$CI_COMMIT_SHA
IMAGE_NAME: image_id
stages:
- build
- test
- deploy
build_project:
stage: build
script:
// Login to gitlab registry
- docker login -u ******* -p ******* registry.gitlab.com
// Build the docker
- docker build -t $REGISTRY .
// 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|base64 -d > ${HOME}/gcloud-service key.json
// Download and install Google Cloud SDK
tar zxvf google-cloud-sdk.tar.gz && ./google-cloud-sdk/install.sh -сообщения об использовании = false --path-update = true
google-cloud-sdk / bin / gcloud --quiet обновление компонентов
// подключиться к контейнеру gcloud -
google-cloud-sdk / bin / gcould docker login -u -p https://eu.gcr.io
// Create our image. Expected to create an image 'image_id'
- make-my-image
// Tag our image for container registry
- docker tag $IMAGE_NAME gcr.io/atomic-matrix-242810/$IMAGE_NAME
// Optionally tag the image with the commit short-sha
- docker tag $IMAGE_NAME gcr.io/$GCP_PROJECT_ID/$IMAGE_NAME:$(echo $CI_COMMIT_SHA | cut -c1-8)
- google-cloud-sdk/bin/gcloud docker -- push gcr.io/$GCP_PROJECT_ID/$IMAGE_NAME:latest
- google-cloud-sdk/bin/gcloud docker -- push gcr.io/$GCP_PROJECT_ID/$IMAGE_NAME:$(echo $CI_COMMIT_SHA | cut -c1-8)