Home > Enterprise >  How to deploy just the code in Google Cloud Platform
How to deploy just the code in Google Cloud Platform

Time:05-13

In my work, i've to update a certain part of a project, that's its made in Next.js and deployed in Google Cloud Platform, i have done my work successfully but now i don't now how to trigger a re-deploy on GCP because the code doesn't have a app.yaml or a CI/CD implementation, and I don't know how the code was uploaded to GCP without either of these two ways

So I was wondering if there is a way to update the code, without deploying the GCP client with the app.yaml file and CI/CD. To upload the code, since I will not have to make any more changes

CodePudding user response:

I think you are just running the script using npm run start / node index.js / python3 main.py etc. If you are really using Google Cloud Platform and its servers, you would need a configuration file - app.yaml file/Dockerfile/ cloudbuild.yaml

For App Engine, you must first create the app.yaml file for the default service of your app before you can create and deploy app.yaml files for additional services. To deploy your application's service, run the following command from the directory where the app.yaml file of your service is located:

gcloud app deploy

By default, the gcloud app deploy command deploys only the app.yaml file in your current directory. Whenever you run this command, App Engine generates a unique ID for the version that you deploy, deploys the version to the Cloud project you configured the gcloud CLI to use, and routes all traffic to the new version. The new version becomes the default version.

If you are using Cloud Build for the deployment, build your Docker image using a build config file: use a Cloudbuild.yaml file/cloudbuild.json file

For a pre-built Docker image:

  1. In the same directory that contains your application source code, create a file named cloudbuild.yaml or cloudbuild.json.
  2. In the build config file:

Add a name field and specify the pre-built Docker image. The pre-built image is stored in the Container Registry at gcr.io/cloud-builders/docker. In the example config file below, the name field specifies that the pre-build Docker image is used by Cloud Build to execute the task indicated by the args field.

  1. Start the build using the build config file:

gcloud builds submit --region=REGION --config CONFIG_FILE_PATH
SOURCE_DIRECTORY

To build Docker image:

Cloud Build allows you to build a Docker image using just a Dockerfile. You don't require a separate build config file. To build using a Dockerfile, run the following command from the directory containing your source code and the Dockerfile:

gcloud builds submit --region=REGION --tag gcr.io/PROJECT_ID/IMAGE_NAME

So if you are not doing the above, I would like to know how you are deploying the app without config files. And coming to your question, yes you can redeploy the app, by :

  1. Just running the same command you used to originally deploy the app: $ gcloud app deploy This will replace the currently running instances with the new app. Add --no-promote if you want to deploy without routing service to the latest version deployed.
  2. enter image description here

  • Related