Skip to content

Latest commit

 

History

History
55 lines (36 loc) · 1.78 KB

File metadata and controls

55 lines (36 loc) · 1.78 KB

Docker Build & Push Guide

This guide explains how to build Docker images from the directories in this folder and push them to Google Cloud Artifact Registry using the gcloud CLI.

Prerequisites

  • Docker installed
  • gcloud CLI installed and authenticated
  • Access to a Google Cloud project with Artifact Registry enabled

Steps

1. Gcloud environment setup

gcloud init
gcloud auth login
gcloud auth application-default login
gcloud config set project <gcp-project-id>

2. Create the artifact repository

Skip this step if you already have an artifact repository in Google Cloud Artifact Registry that you can use.

gcloud artifacts repositories create <repository-name> --repository-format=docker --location=<location> --description="Docker repository"

Example:

gcloud artifacts repositories create vector-bootcamp --repository-format=docker --location=us-central1 --description="Docker repository for docker images used in the Vector Bootcamp"

3. Build and push the docker images to the repository

Navigate to the directory containing the Dockerfile you want to and run the following

gcloud builds submit --region=<location> --tag <location>-docker.pkg.dev/<project-id>/<repository-name>/<image-name>:<tag-name>

Example:

gcloud builds submit --region=us-central1 --tag us-central1-docker.pkg.dev/axial-iris-462715-e6/vbootcamp/bootcamp-image:test

After the build is complete, you can find the docker imgae in the repository in Google Cloud Artifact Registry.

References