-
Notifications
You must be signed in to change notification settings - Fork 710
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
install application dependencies during the image build #335
install application dependencies during the image build #335
Conversation
@@ -1,5 +1,9 @@ | |||
FROM node:8.9 AS build | |||
WORKDIR /app | |||
|
|||
COPY package.json yarn.lock /app/ | |||
RUN yarn install --frozen-lockfile |
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.
This improves docker cache hits in the development workflow
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.
what do you mean with "this"? the --frozen-lockfile
? Why not doing the yarn install
after the COPY . /app
?
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.
the --frozen-lockfile?
Apparently yarn install
could go an update the yarn.lock file and update the package versions to something completely different from what it was tested against. For this reason the --frozen-lockfile
is recommended for use in CI builds yarnpkg/yarn#749
Why not doing the yarn install after the COPY . /app?
Specifically w.r.t the developer use-case, this ensures that the docker layer cache gets reused during the builds. As a result image builds will be quicker when the dashboard sources (css/js/ts/etc) are updated. Only when there are updates to the package.json/yarn.lock file, there will be a cache miss and yarn install
will execute again.
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, true
3495367
to
237da38
Compare
@@ -1,5 +1,9 @@ | |||
FROM node:8.9 AS build | |||
WORKDIR /app | |||
|
|||
COPY package.json yarn.lock /app/ | |||
RUN yarn install --frozen-lockfile |
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, true
fixes #332