forked from Nanouna/recettes-et-sentiments
-
Notifications
You must be signed in to change notification settings - Fork 0
/
docker-build-for-cloud-run.sh
executable file
·24 lines (19 loc) · 1.1 KB
/
docker-build-for-cloud-run.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#!/bin/sh
# prerequisite :
# * Cloud Run API is enabled
# * Artifact Registry is enabled
# * install yq (snap install yq for linux, brew install yq) ==> yq (https://github.com/mikefarah/yq/) version v4.44.1
# * create a Docker/.env.yaml file and fill it wit correct values
# * execute this setup script once : setup-gcloud-artifcat-registry.sh
# Lire les variables d'environnement depuis le fichier YAML
ENV_FILE="Docker/.env.yaml"
GCP_REGION=$(yq e '.GCP_REGION' $ENV_FILE)
GCP_PROJECT_ID=$(yq e '.GCP_PROJECT_ID' $ENV_FILE)
DOCKER_REPO_NAME=$(yq e '.DOCKER_REPO_NAME' $ENV_FILE)
GAR_IMAGE=$(yq e '.GAR_IMAGE' $ENV_FILE)
GAR_IMAGE_VERSION=$(yq e '.GAR_IMAGE_VERSION' $ENV_FILE)
# build the image for Google Cloud Run
echo docker build -t $GCP_REGION-docker.pkg.dev/$GCP_PROJECT_ID/$DOCKER_REPO_NAME/$GAR_IMAGE:$GAR_IMAGE_VERSION -f Docker/Dockerfile .
docker build -t $GCP_REGION-docker.pkg.dev/$GCP_PROJECT_ID/$DOCKER_REPO_NAME/$GAR_IMAGE:$GAR_IMAGE_VERSION -f Docker/Dockerfile .
# push it to Google Artifact registry
docker push $GCP_REGION-docker.pkg.dev/$GCP_PROJECT_ID/$DOCKER_REPO_NAME/$GAR_IMAGE:$GAR_IMAGE_VERSION