Deploying Dockerfile as GCP Cloud Service
This guide walks through building a Docker image locally and pushing it to GCP Artifact Registry — ready to be deployed as a Cloud Run service or used in any GCP pipeline.
Prerequisites
- Docker installed
gcloudCLI installed and initialized- GCP IAM access with Artifact Registry write permissions
- An existing Artifact Registry repository in your GCP project
Step 1 — Prepare your Dockerfile
Ensure your Dockerfile is in the root of your project directory. It should define the runtime environment, dependencies, and entry point for your service.
Step 2 — Build the image for linux/amd64
Use docker buildx to build a cross-platform image targeting the linux/amd64 architecture required by Cloud Run, even if you’re building on an Apple Silicon (ARM) machine.
docker buildx build -t dgd-ocr-pipeline --platform linux/amd64 .Note: The
--platform linux/amd64flag is important if you’re on an ARM-based Mac. Omitting it may cause compatibility issues on GCP infrastructure.
Step 3 — Tag the image for Artifact Registry
Tag your local image with the full Artifact Registry path. The format follows:
REGION-docker.pkg.dev/PROJECT_ID/REPO_NAME/IMAGE:TAG
docker tag dgd-ocr-pipeline \
asia-southeast1-docker.pkg.dev/one-global-dilab-sandbox-dev/gcf-artifacts/dgd-ocr-pipeline:v0.1Tip: You can copy the exact registry path from GCP Console → Artifact Registry → your repository. Update the version tag (e.g.
v0.2) with each new release.
Step 4 — Authenticate with GCP
Before pushing, make sure Docker is authorized to access your Artifact Registry. Run this once per region:
gcloud auth configure-docker asia-southeast1-docker.pkg.devStep 5 — Push the image to Artifact Registry
Push the tagged image to your GCP Artifact Registry. This uploads all image layers and makes the image available for Cloud Run or other GCP services.
docker push \
asia-southeast1-docker.pkg.dev/one-global-dilab-sandbox-dev/gcf-artifacts/dgd-ocr-pipeline:v0.1Next steps
Once the push completes, your image will be available in GCP Console → Artifact Registry. From there, you can deploy it directly to Cloud Run by selecting the image URI when creating or updating a service.