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: reduce image size in sample Dockerfile #24108

Merged
merged 9 commits into from
Apr 20, 2021
Merged

Conversation

wodCZ
Copy link
Contributor

@wodCZ wodCZ commented Apr 15, 2021

Running chown after COPYing the files in the runner phase creates a new image layer, that has basically same size as the .next directory.

CleanShot 2021-04-15 at 16 18 07

We can achieve the same result using the --chown argument of COPY instruction. This time we don't create a duplicate layer.

CleanShot 2021-04-15 at 16 22 55

Additionally, we can save some space (approx. 1.5 MB) on the telemetry disable row by using the opt out env variable.

I believe this change will be most notable for sites generating a lot of pages statically (in my case, I have around 19k pages and this change saved me ~430 MB).

Copy link
Member

@leerob leerob left a comment

Choose a reason for hiding this comment

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

Thank you! Could you also update the corresponding with-docker example?

@ijjk ijjk added the examples Issue/PR related to examples label Apr 19, 2021
@wodCZ
Copy link
Contributor Author

wodCZ commented Apr 19, 2021

Ah, great catch, didn't realise it'd be in example too. Thanks!

I've updated the example to match updated documentation ✅

Edit: I've also updated the start script in the docker example, since the container was crashing if the PORT env variable wasn't specified (which the README didn't mention).

@leerob leerob merged commit 1f54ba6 into vercel:canary Apr 20, 2021
SokratisVidros pushed a commit to SokratisVidros/next.js that referenced this pull request Apr 20, 2021
@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
examples Issue/PR related to examples
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants