Skip to content

mtopps/cloudrun_test

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 

Repository files navigation

Two-tier Cloud Run App Deployment

Docker build

Create Docker network

docker network create app-network

backend

cd backend
docker build -t backend .
docker run --network app-network --name backend -d -p 5000:5000 backend

frontend

cd frontend
docker build -t frontend .
docker run --network app-network --name frontend -d -p 3000:3000 frontend

Test

Repeated runs will see the counter increment.

$ curl http://localhost:3000/

                <!DOCTYPE html>
                <html>
                <body>
                    <h1>Welcome</h1>
                    <p>You have visited: 2</p>
                </body>
                </html>

Cloud Run

  1. Authenticate to your Google Cloud account and set the project:

    gcloud auth login
    PROJECT_ID=myproject-123456
  2. Configure Docker to use gcloud as a credential helper:

    gcloud auth configure-docker
  3. Tag your Docker images with the path to your Container Registry:

    docker tag backend gcr.io/$PROJECT_ID/backend
    docker tag frontend gcr.io/$PROJECT_ID/frontend
  4. Push the Docker images to the Container Registry:

    docker push gcr.io/$PROJECT_ID/backend
    docker push gcr.io/$PROJECT_ID/frontend
  5. Deploy the images to Cloud Run:

    gcloud run deploy backend --image gcr.io/$PROJECT_ID/backend --platform managed
    gcloud run deploy frontend --image gcr.io/$PROJECT_ID/frontend --platform managed

This will create two Cloud Run services, one for the backend and one for the frontend. After running these commands, you will get URLs for your services. You can use these URLs to access your applications.

Please note that you need to have the Google Cloud SDK installed on your machine to run these commands. If you don't have it installed, you can download it from the Google Cloud SDK webpage.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published