Deploy to Google Cloud Platform (GCP)
This tutorial will show you how to deploy your services to your own GCP project using Defang.
Prerequisites
- The Defang CLI
- A Defang Account
- gcloud CLI
- GCP Application Default Credentials
- A
compose.yamlfile in your project - A Dockerfile in your project or use Railpack
Step 1 - Navigate to your project directory
Head to the folder where your project is located.
$ cd path/to/your/project
Step 2 - Configure your GCP credentials
After signing in to your GCP account, select an existing project or create a new project. Make sure billing is enabled. Keep a note of the project ID, you will need it in the next step.
Run the following gcloud command to authenticate with GCP:
$ gcloud auth application-default login
Step 3 - Create a stack
Before you deploy, you should create a stack. In this
case, we will create a stack called dev:
$ defang stack create dev
Defang will ask us which region we want to deploy to, and which GCP Project ID we should use.
Step 4 - Deploy
Invoke the following CLI command. Defang will ask you which stack you want to deploy to.
$ defang compose up
Step 5 - Inspect your deployment
Defang will provision resources in your GCP account and deploy your services. You can inspect the resources created in your GCP Dashboard.
For a deeper discussion of the Defang GCP Architecture, see our GCP docs.