Skip to content
This repository has been archived by the owner on Aug 5, 2022. It is now read-only.

docs: add gcp deployment guide #72

Merged
merged 13 commits into from
Dec 13, 2021
Merged

Conversation

PatrickHeneise
Copy link
Contributor

Closes #55

Tested this with a simple Hummingbird server (https://github.com/zentered/swift-hummingbird-demo), everything works as described. Screenshots attached as well.

Copy link
Member

@fabianfett fabianfett left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small nits regarding static linking :)

docs/gcp.md Outdated Show resolved Hide resolved
docs/gcp.md Outdated Show resolved Hide resolved
PatrickHeneise and others added 2 commits November 23, 2021 17:08
Co-authored-by: Fabian Fett <fabianfett@apple.com>
@PatrickHeneise
Copy link
Contributor Author

@fabianfett Thanks for the review. Addressed all the issues.

Copy link
Member

@0xTim 0xTim left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@PatrickHeneise thanks for this, it's great! I'm doing a full run through at the moment and have never used GCP before so make a great guinea pig! I've added some small tweaks to make it easier to follow but am currently stuck. I can successfully compile the app and have pushed the container but then get the following error

Starting Step #3
Step #3: Already have image (with digest): gcr.io/cloud-builders/gcloud
Step #3: ERROR: (gcloud.run.deploy) PERMISSION_DENIED: Permission 'run.services.get' denied on resource 'namespaces/banded-pager-334823/services/swift-service' (or resource may not exist).
Finished Step #3
ERROR
ERROR: build step 3 "gcr.io/cloud-builders/gcloud" failed: step exited with non-zero status: 1

Any idea?

docs/gcp.md Outdated Show resolved Hide resolved
docs/gcp.md Outdated Show resolved Hide resolved
docs/gcp.md Outdated Show resolved Hide resolved
docs/gcp.md Outdated Show resolved Hide resolved
docs/gcp.md Show resolved Hide resolved
docs/gcp.md Outdated Show resolved Hide resolved
docs/gcp.md Outdated Show resolved Hide resolved
docs/gcp.md Outdated Show resolved Hide resolved
docs/gcp.md Outdated Show resolved Hide resolved
docs/packaging.md Outdated Show resolved Hide resolved
Co-authored-by: Tim Condon <0xTim@users.noreply.github.com>
@PatrickHeneise
Copy link
Contributor Author

Wow, thanks a lot for the review! Sorry you got stuck, I tried this several times and it worked :/ I'll check about the error.

As for , etc. I hardcoded the values for simplicity; I'll replace those with build substitution variables, that'll be easier.

@PatrickHeneise
Copy link
Contributor Author

@0xTim I forgot the Cloud Build settings. Added a screenshot and description in the article. Go to "Settings" in the Cloud Build overview, then Enable the permissions for "Cloud Run". This should give Cloud Build the necessary permission to deploy your service.

Copy link
Member

@0xTim 0xTim left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great that fixed it! Couple of last things then good to go

docs/gcp.md Outdated Show resolved Hide resolved
Vapor takes about 25 minutes on the standard/small build machines, which are
fairly slow. "Jordane" from the Vapor Discord community
[recommends using `machineType: E2_HIGHCPU_8`](https://discord.com/channels/431917998102675485/447893851374616576/915819735738888222)
in the `cloudbuild.yaml` to speed up deployments:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we know if the slowness is about dependency resolution or build / CPU? Is there a way to configure dependencies cache location?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That was on my todo list to figure out. Caching is definitely supported on both GCP and AWS, should be possible with a multi-stage build to separate the dependencies.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The majority of the time is build time. Both the default build machine and high CPU build machine were about a couple of minutes for resolution (high CPU was about 30s faster) but actual build time for default was 20 mins and about 5 mins on the high CPU machine

Copy link
Member

@0xTim 0xTim left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, LGTM!

@0xTim 0xTim merged commit 35f12b7 into swift-server:main Dec 13, 2021
@PatrickHeneise PatrickHeneise deleted the docs/gcp-deployment branch December 13, 2021 20:10
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

document deployment to GCP
5 participants