-
-
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
site: use gcloud CLI to build Docker image #2479
Conversation
Codecov Report
@@ Coverage Diff @@
## master #2479 +/- ##
=======================================
Coverage 91.83% 91.83%
=======================================
Files 1 1
Lines 49 49
=======================================
Hits 45 45
Misses 4 4 Continue to review full report at Codecov.
|
The upshot of all of this is:
|
/__sapper__/* | ||
!/__sapper__/build | ||
!/static | ||
!/content |
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.
Could we make it this instead? I think it has same result
**
!/Dockerfile
!/package.json
!/package-lock.json
!/__sapper__/build/**
!/content
!/static
Ignore absolutely everything except these...
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.
Built locally and it was the same
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.
That doesn't work
Creating temporary tarball archive of 3 file(s) totalling 235.3 KiB before compression.
- only package.json, package-lock.json, and Dockerfile are included.
It's got something to do with not being able to include __sapper__/build/...
if all of __sapper__
was already excluded.
When I was playing with GCR for the first time a couple of weeks ago, I spent a while wading through SO answers about gitignore trying to get this to work. I'm pretty sure there's not a tidier way to specifically include these files.
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.
Ah, right! It works for docker alone, but gcloudignore is a bit different.
this is wonderful and i just about understand it |
A few changes here:
gcloud builds submit
to build the image (remotely) rather than locally with Docker and then pushing it.dockerignore
which whitelists only the files needed by the Sapper app.gcloudignore
that just points to that.dockerignore
(the reason for having both is so that the olddocker build
will continue to work nicely if so desired)Dockerfile
now only copies thepackage[-lock].json
files to the first container before installing deps, and then copies the installed packages and every (non-ignored) file in the directory to the second and final container (this is to avoid a little bit of extra copying of the app itself to the first container, which isn't really necessary)npm ci