Skip to content

Commit

Permalink
feat(@whook/example): add Google Cloud Functions build
Browse files Browse the repository at this point in the history
  • Loading branch information
nfroidure committed Jun 18, 2022
1 parent 8070ed5 commit 149add9
Show file tree
Hide file tree
Showing 19 changed files with 1,109 additions and 95 deletions.
1 change: 1 addition & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions packages/whook-create/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Large diffs are not rendered by default.

6 changes: 6 additions & 0 deletions packages/whook-create/src/services/createWhook.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,13 +144,15 @@ Mr Bean
"@whook/authorization": "<current_version>",
"@whook/cli": "<current_version>",
"@whook/cors": "<current_version>",
"@whook/gcp-functions": "^9.0.1",
"@whook/http-router": "<current_version>",
"@whook/http-server": "^9.0.1",
"@whook/http-transaction": "<current_version>",
"@whook/swagger-ui": "<current_version>",
"@whook/whook": "<current_version>",
"common-services": "^11.0.1",
"http-auth-utils": "^3.0.3",
"js-yaml": "^3.13.1",
"jwt-service": "^9.0.1",
"knifecycle": "^14.0.0",
"openapi-schema-validator": "^11.0.1",
Expand Down Expand Up @@ -364,13 +366,15 @@ Mr Bean
"@whook/authorization": "<current_version>",
"@whook/cli": "<current_version>",
"@whook/cors": "<current_version>",
"@whook/gcp-functions": "^9.0.1",
"@whook/http-router": "<current_version>",
"@whook/http-server": "^9.0.1",
"@whook/http-transaction": "<current_version>",
"@whook/swagger-ui": "<current_version>",
"@whook/whook": "<current_version>",
"common-services": "^11.0.1",
"http-auth-utils": "^3.0.3",
"js-yaml": "^3.13.1",
"jwt-service": "^9.0.1",
"knifecycle": "^14.0.0",
"openapi-schema-validator": "^11.0.1",
Expand Down Expand Up @@ -569,13 +573,15 @@ Mr Bean
"@whook/authorization": "<current_version>",
"@whook/cli": "<current_version>",
"@whook/cors": "<current_version>",
"@whook/gcp-functions": "^9.0.1",
"@whook/http-router": "<current_version>",
"@whook/http-server": "^9.0.1",
"@whook/http-transaction": "<current_version>",
"@whook/swagger-ui": "<current_version>",
"@whook/whook": "<current_version>",
"common-services": "^11.0.1",
"http-auth-utils": "^3.0.3",
"js-yaml": "^3.13.1",
"jwt-service": "^9.0.1",
"knifecycle": "^14.0.0",
"openapi-schema-validator": "^11.0.1",
Expand Down
51 changes: 51 additions & 0 deletions packages/whook-example/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,57 @@ Debug `knifecycle` internals (dependency injection issues):
DEBUG=knifecycle npm run dev
```

## Deploying with Google Cloud Functions

Create a project and save its credentials to `.credentials.json`.

Then install Terraform:
```sh
wget https://releases.hashicorp.com/terraform/0.12.24/terraform_0.12.24_linux_amd64.zip
mkdir .bin
unzip -d .bin terraform_0.12.24_linux_amd64.zip
rm terraform_0.12.24_linux_amd64.zip
```

Then initialize the Terraform configuration:
```sh
.bin/terraform init ./terraform;
```

Create a new workspace:
```sh
.bin/terraform workspace new staging
```

Build the functions:
```sh
NODE_ENV=staging npm run build
```

Build the Whook commands Terraform depends on:
```sh
npm run compile
```

Plan the deployment:
```sh
.bin/terraform plan -var="project_id=my-project-1664" \
-out=terraform.plan terraform
```

Apply changes:
```sh
# parallelism may be necessary to avoid hitting
# timeouts with a slow connection
.bin/terraform apply -parallelism=1 terraform.plan
```

Finally retrieve the API URL and enjoy!
```sh
.bin/terraform -var="project_id=my-project-1664" \
output api_url
```

[//]: # (::contents:end)

# Authors
Expand Down
Loading

0 comments on commit 149add9

Please sign in to comment.