-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathbuildContainer.sh
More file actions
31 lines (25 loc) · 1.16 KB
/
buildContainer.sh
File metadata and controls
31 lines (25 loc) · 1.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
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}"
# 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
IMAGE_NAME="${FULL_REPO}/hello-world-demo:latest"
# To use Cloud Build and the Dockerfile:
gcloud builds submit --tag $IMAGE_NAME .
# To use the Google Cloud buildpack:
# gcloud auth configure-docker ${LOCATION}-docker.pkg.dev
# pack build "${IMAGE_NAME}" \
# --builder gcr.io/buildpacks/builder \
# --env GOOGLE_NODEJS_VERSION=24.x.x
# docker push "${IMAGE_NAME}"