2021-07-01 10:14:06 +02:00
|
|
|
---
|
2021-07-16 18:37:29 +02:00
|
|
|
slug: /1006/google-cloud-run/
|
2021-07-01 10:14:06 +02:00
|
|
|
---
|
|
|
|
|
2021-07-16 18:37:29 +02:00
|
|
|
# Deploy to Google Cloud Run with Dagger
|
2021-07-01 10:14:06 +02:00
|
|
|
|
2021-07-05 12:40:45 +02:00
|
|
|
This tutorial illustrates how to use Dagger to build, push and deploy Docker images to Cloud Run.
|
2021-07-01 10:14:06 +02:00
|
|
|
|
|
|
|
import Tabs from '@theme/Tabs';
|
|
|
|
import TabItem from '@theme/TabItem';
|
|
|
|
|
2021-09-21 22:36:51 +02:00
|
|
|
## Initialize a Dagger Project and Environment
|
2021-06-09 12:01:27 +02:00
|
|
|
|
2021-07-05 12:40:45 +02:00
|
|
|
### (optional) Setup example app
|
2021-06-09 12:01:27 +02:00
|
|
|
|
2021-07-05 12:40:45 +02:00
|
|
|
You will need the local copy of the [Dagger examples repository](https://github.com/dagger/examples) used in previous guides
|
2021-06-09 12:01:27 +02:00
|
|
|
|
2021-07-05 12:40:45 +02:00
|
|
|
```shell
|
|
|
|
git clone https://github.com/dagger/examples
|
|
|
|
```
|
2021-06-09 12:01:27 +02:00
|
|
|
|
2021-07-02 03:57:43 +02:00
|
|
|
Make sure that all commands are being run from the todoapp directory:
|
2021-06-09 12:01:27 +02:00
|
|
|
|
2021-07-05 12:40:45 +02:00
|
|
|
```shell
|
|
|
|
cd examples/todoapp
|
|
|
|
```
|
2021-06-09 12:01:27 +02:00
|
|
|
|
2021-07-05 12:40:45 +02:00
|
|
|
### Organize your package
|
2021-06-09 12:01:27 +02:00
|
|
|
|
2021-07-05 12:40:45 +02:00
|
|
|
Let's create a new directory for our Cue package:
|
2021-06-09 12:01:27 +02:00
|
|
|
|
2021-07-05 12:40:45 +02:00
|
|
|
```shell
|
2021-07-02 03:57:43 +02:00
|
|
|
mkdir gcpcloudrun
|
2021-07-05 12:40:45 +02:00
|
|
|
```
|
2021-06-09 12:01:27 +02:00
|
|
|
|
2021-07-05 12:40:45 +02:00
|
|
|
### Create a basic plan
|
2021-06-09 12:01:27 +02:00
|
|
|
|
2021-11-07 19:50:32 +01:00
|
|
|
```cue file=./tests/gcpcloudrun/source.cue title="todoapp/gcpcloudrun/source.cue"
|
2021-10-06 03:59:34 +02:00
|
|
|
|
2021-07-05 12:40:45 +02:00
|
|
|
```
|
|
|
|
|
|
|
|
## Set up the environment
|
|
|
|
|
|
|
|
### Create a new environment
|
|
|
|
|
2021-10-06 03:59:34 +02:00
|
|
|
Let's create a project:
|
|
|
|
|
|
|
|
```shell
|
|
|
|
dagger init
|
|
|
|
```
|
|
|
|
|
|
|
|
Let's create an environment to run it:
|
2021-07-05 12:40:45 +02:00
|
|
|
|
|
|
|
```shell
|
2021-07-10 17:03:25 +02:00
|
|
|
dagger new 'gcpcloudrun' -p ./gcpcloudrun
|
2021-07-05 12:40:45 +02:00
|
|
|
```
|
|
|
|
|
|
|
|
### Configure user inputs
|
|
|
|
|
|
|
|
```shell
|
|
|
|
dagger input dir src . -e gcpcloudrun
|
|
|
|
dagger input text deploy.name todoapp -e gcpcloudrun
|
|
|
|
dagger input text imageRef gcr.io/<your-project>/todoapp -e gcpcloudrun
|
|
|
|
dagger input text gcpConfig.region us-west2 -e gcpcloudrun
|
|
|
|
dagger input text gcpConfig.project <your-project> -e gcpcloudrun
|
|
|
|
dagger input secret gcpConfig.serviceKey -f ./gcp-sa-key.json -e gcpcloudrun
|
|
|
|
```
|
|
|
|
|
|
|
|
## Deploy
|
|
|
|
|
2021-07-02 03:57:43 +02:00
|
|
|
Now that everything is set correctly, let's deploy on Cloud Run:
|
2021-07-05 12:40:45 +02:00
|
|
|
|
|
|
|
```shell
|
|
|
|
dagger up -e gcpcloudrun
|
|
|
|
```
|