-
Notifications
You must be signed in to change notification settings - Fork 32
Expand file tree
/
Copy pathbuildContainer.sh
More file actions
22 lines (18 loc) · 913 Bytes
/
buildContainer.sh
File metadata and controls
22 lines (18 loc) · 913 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
PROJECT_ID=$GOOGLE_CLOUD_PROJECT # Replace with your actual project ID
LOCATION="us" # Replace with your desired region (e.g., "us-central1")
REPOSITORY="demos" # Replace with your desired repository name
FULL_REPO="${LOCATION}-docker.pkg.dev/${PROJECT_ID}/${REPOSITORY}"
IMAGE_NAME="hello-operations-demo"
# Check if the repository exists
if ! gcloud artifacts repositories describe "${REPOSITORY}" --location="${LOCATION}" --project="${PROJECT_ID}" &>/dev/null; then
echo "Repository '$REPOSITORY' does not exist. Creating..."
# Create the repository
gcloud artifacts repositories create "${REPOSITORY}" \
--repository-format=docker \
--location="${LOCATION}" \
--project="${PROJECT_ID}"
echo "Repository '$FULL_REPO' created successfully."
else
echo "Repository '$FULL_REPO' already exists."
fi
gcloud builds submit --tag $FULL_REPO/$IMAGE_NAME:latest .