-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Chore: Deploy via CloudRun #2465
Conversation
Codecov Report
@@ Coverage Diff @@
## master #2465 +/- ##
=======================================
Coverage 91.83% 91.83%
=======================================
Files 1 1
Lines 49 49
=======================================
Hits 45 45
Misses 4 4 Continue to review full report at Codecov.
|
A couple of things - Is there a reason to have a two-step build process in the I also think it might be nicer to not assume Docker is installed locally, and to instead just use What I arrived at when I was fiddling with this stuff a week or so ago was to have a The
which specifically whitelists certain files and directories. This would also need to be updated to include the Lastly, is there a reason you're not using one of the official Node Alpine images? Do those include extra stuff you're trying to avoid? |
Oh, is the answer to my first and last questions that the latter image only includes Node itself and not npm/Yarn? |
The first pass is a full box, with npm/yarn. We use this one to build The second pass is Alpine + In both phases, we're manually copying over the files/directories we need. No need for endless list of ignores. Here's what the final image contains:
This is all that we need to actually run the website. |
I think that specifying Yeah I realized that was probably the reason for the two-phase build right after I asked it. Having a |
Correct. GCR requires I didn't set up It also gives a massive free tier. |
Okay never mind about that stuff about Since we need to have No strong opinions about whether |
I have no strong opinions (or even weak opinions tbh) about Aside from some caching headers, webpagetest.org now thinks we're doing a pretty good job: |
More often than not, something like this project will wanna use Cloud Build. Again, I didn't here (initially) because I didn't want it to seem/feel like it was an all-or-nothing in order to use GCR. This is the bare bones approach to getting it working, which was also the fastest way since the old way was getting pricey, fast. But yes, using Cloud Build will 100% require an ignore-file so that we're not sending up a million files to be built. |
@@ -0,0 +1,24 @@ | |||
HASH := `git rev-parse --short HEAD` | |||
|
|||
SERVICE := svelte-website |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe document how to create the service in GC somewhere?
Added custom Dockerfile and a simple Makefile (for speed/simplicity). The Makefile can be transformed into a
scripts/*
file...whatever you want.To build the container, you run
make docker
from inside thesite
directory. This assume that you've already built the Sapper app!Once the image has been built, you can enter it with the following:
From here, you can
ls -alh
and whatnot to explore the contents.Port
3000
gets forwarded for testing, since that's set as the defaultprocess.env.PORT
value.TODOs
@Rich-Harris You need to setup a GCP project, if you haven't already. Then you will enter that project's name inside the Makefile. I don't think this is particularly sensitive, but you can inject it thru your CD pipeline, whatever it is.
You'll also need to update the DNS for
svelte.dev
via Cloudflare and setup the CloudRun "domain mapping".Finally, this does nothing with ENV values. I haven't followed the trail much, but personally I have them live on the platform itself. CloudRun (as with many other services) allow you to configure ENV values on the service itself, which makes them available to the running container. This basically means that you can configure them once (inside GCP's GUI if you want) and then never have to touch them again, even between deployments.
I can help you with any of these steps if you want. Happy to help.
I didn't remove the
now.json
file in case it was still needed for reference?