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

Docker size reduction #2

Merged
merged 9 commits into from Apr 15, 2022
Merged

Docker size reduction #2

merged 9 commits into from Apr 15, 2022

Conversation

pi0neerpat
Copy link
Owner

@pi0neerpat pi0neerpat commented Apr 14, 2022

This PR is focused on reducing the /api image size. It has been reduced from ~3GB to 1.17GB

Changes

  • Using --production flag to skip dev dependencies saved a ton of space! (THIS IS A MUST)
  • yarn cache clean saved a ton of space! (THIS IS A MUST)
  • Added lerna, which is required to use the local /packages dependencies. This is working great now.
  • yarn global add @redwoodjs/api-server @redwoodjs/internal to serve the api from bin

Discussion

If you do a multi-stage dockerfile, you can build everything, run migrations, then just grab the dist directories. At that point all you need is the api-server package. You can run the server as a bin via:
yarn rw-server [side]
-David's super optimistic suggestion

  • I was not able to just grab the dist directories, due to missing deps for graphql-server at runtime. I ran out of time to continue down this rabbit hole.
  • I could not use node-alpine because I am using packages like canvas (in my production app, not here) to render images in /api. This causes node-gyp and python errors. From a DevX point of view I believe recommending alpine is not the right path, or it should be heavily documented that both options be suggested.

@pi0neerpat pi0neerpat merged commit 0977f00 into dev Apr 15, 2022
@pi0neerpat pi0neerpat deleted the docker-size-reduction branch April 15, 2022 19:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant