Skip to main content

Deploying to Cloud Run

Deploying a container to Cloud Run depends upon authenticating the gcloud CLI.

1. Prepare your Dockerfile

Ensure your source code possesses a correctly structured standard Dockerfile.

FROM node:18-slim
WORKDIR /usr/src/app
COPY package*.json ./
RUN npm install
COPY . .
EXPOSE 8080
CMD [ "npm", "start" ]

2. Deploy exclusively via Source

Cloud Run bypasses building Docker manually. It extracts the code and builds it in the background using Cloud Build.

gcloud run deploy my-service \
--source . \
--region us-central1 \
--allow-unauthenticated

3. Deployment Parameters Explained

  • --source .: Instructs Cloud Build to grab the local directory.
  • --region: Determines the geographical region.
  • --allow-unauthenticated: Safely opens the web service to the public internet for public HTTP traffic.