GCP: Nuxt3 Cloud Run Deployment

How to deploy Turboship, a Nuxt3 app, on GCP infrastructure

Dependencies

Steps

Dockerize your app

I suggest you expose your app on port 8080 as it's the default GCP Cloud Run uses.

Build Image

docker build -t primetimetran/turboship . --platform linux/amd64

I've added --platform linux/amd64 because of this bug/post I ran into.

The repo will hold your images.

Tag image you created following GCP conventions

Tag your local image following GCP docs/conventions.

docker tag primetimetran/turboship us-central1-docker.pkg.dev/turboship-dev/anotsosecretproject/turboship

It's important to have the region-datacenter-docker.pkg/project-id/repo-name/image-name

In other words the tag's mapping is as follows:

  • region-datacenter: us-central1
  • project-id: turboship-dev
  • repo-name: repo-name
  • image-name: image-name

Authenticate Region

To build on your local you'll need to be authenticated(as opposed to building in GCP console).

gcloud auth configure-docker us-central1-docker.pkg.dev

Push image to GCP registry/repo.

GCP needs a copy of the image. Artifact registry holds it while Cloud Run deploys/hosts it.

docker push us-central1-docker.pkg.dev/turboship-dev/anotsosecretproject/turboship

A success means something like this back:

us-central1-docker.pkg.dev/v2/turboship-dev/anotsosecretproject/turboship/blobs/sha256:4f44545e39b2d39866515e7aadec82100f6a7164b24d721f5e5fdbd170868689

Create a new service selecting from the right drawer menu(because it'll have the image hash)

Resources

https://dev.to/sakko/deploying-nuxtjs-on-google-cloud-run-1fic

gcloud builds submit --project "project-name" --config=./cloud-build.yaml

Cheatsheet

gcloud logging read "resource.type="cloud_run_revision" AND resource.labels.service_name="turboship"" --project=turboship-dev --limit=1000