Deploy a new service to app engine project
Here are the steps to deploy a new service to an App Engine project:
Prerequisites:
- You have a Google Cloud account and a project created.
- You have the
gcloud
command-line tool installed and configured. - You have a directory containing your application code.
Step 1: Create a new service
In your terminal, navigate to the directory containing your application code and run the following command:
gcloud app services create <service-name> --platform standard --region <region>
Replace <service-name>
with a unique name for your service (e.g., "my-service") and <region>
with the region where you want to deploy your service (e.g., "us-central1").
Step 2: Configure your app.yaml
file
Create a new file named app.yaml
in the root of your project directory. This file contains configuration settings for your App Engine service.
Here's an example app.yaml
file:
runtime: python
env: flex
handlers:
- url: /.*
script: auto
env_variables:
FLEXIBLE_ENV_VAR: "hello"
This example app.yaml
file specifies a Python runtime, a flexible environment, and sets an environment variable FLEXIBLE_ENV_VAR
to "hello".
Step 3: Deploy your service
Run the following command to deploy your service:
gcloud app deploy app.yaml --promote
This command deploys your service to the App Engine platform and promotes it to the production environment.
Step 4: Verify your service
Once the deployment is complete, you can verify that your service is running by visiting the URL https://<service-name>.<region>.r.appspot.com
in your web browser. Replace <service-name>
with the name of your service and <region>
with the region where you deployed your service.
That's it! You have successfully deployed a new service to your App Engine project.
Additional tips:
- You can also deploy your service using the
gcloud app deploy
command with the--service
flag, like this:gcloud app deploy app.yaml --service <service-name> --promote
. - You can configure additional settings for your service, such as scaling, instance class, and network settings, by modifying the
app.yaml
file or using thegcloud app services update
command. - You can also use the App Engine console to deploy and manage your services.