Skip to content
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

docs(deployment): prune non-production deps #23056

Merged
merged 3 commits into from Apr 20, 2021
Merged

Conversation

portenez
Copy link
Contributor

added the following line, to remove the size of the runner (production) image. This will remove the devDependencies from the container after next build completes.

yarn install --production --ignore-scripts --prefer-offline

For the typescript starter, this is the change in size

before
proposed change
size in bytes
after
proposed change
size in bytes
347MB 176MB

added the following line, to remove the size of the `runner` (production) image. This will remove the `devDependencies` from the container after `next build` completes.

```
yarn install --production --ignore-scripts --prefer-offline
```

For the typescript starter, this is the change in size

| before <br/>proposed change<br/>size in bytes | after <br/> proposed change <br/> size in bytes|
|----|---|
|  347MB    | 176MB |
@@ -98,7 +98,8 @@ FROM node:alpine AS builder
WORKDIR /app
COPY . .
COPY --from=deps /app/node_modules ./node_modules
RUN yarn build
RUN yarn build \
yarn install --production --ignore-scripts --prefer-offline
Copy link
Member

Choose a reason for hiding this comment

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

Don't we really just need --production here? Why the others? Can we also keep on one line?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I added the additional flags because I followed the recommendation in this GitHub issue:
yarnpkg/yarn#696 (comment)

Here's the comment for convenience:

yarn install --production is close, but it does a few things prune doesn't. It's a little annoying to have to build native modules twice in a CI pipeline just to prune. You can prevent rebuilding packages that already exist in cache with the --ignore-scripts flag. Additionally, prune doesn't check npm registry, so add --prefer-offline.

So, yarn install --production --ignore-scripts --prefer-offline == npm prune --productio

@portenez portenez requested a review from shuding as a code owner April 20, 2021 08:58
@kodiakhq kodiakhq bot merged commit efb2b8b into vercel:canary Apr 20, 2021
SokratisVidros pushed a commit to SokratisVidros/next.js that referenced this pull request Apr 21, 2021
added the following line, to remove the size of the `runner` (production) image. This will remove the `devDependencies` from the container after `next build` completes.

```
yarn install --production --ignore-scripts --prefer-offline
```

For the typescript starter, this is the change in size

| before <br/>proposed change<br/>size in bytes | after <br/> proposed change <br/> size in bytes|
|----|---|
|  347MB    | 176MB |
@vercel vercel locked as resolved and limited conversation to collaborators Jan 28, 2022
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.

None yet

3 participants