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

improve docker example in release guide #3796

Merged
merged 1 commit into from
Apr 26, 2020
Merged

improve docker example in release guide #3796

merged 1 commit into from
Apr 26, 2020

Conversation

otijhuis
Copy link
Contributor

  • add python (needed for nodegyp rebuild, will display error otherwise)
  • mkdir isn't needed, WORKDIR will create the directory if it doesn't
    exist
  • combine commands where possible to reduce the amount of docker layers
  • copy package*.json and install packages before doing the deploy so the
    install won't happen every time you modify a js/css file or other
    asset
  • use npm ci instead of npm install
  • bash not needed, sh/ash is available
  • install ncurses-libs, the app wouldn't start otherwise
  • do the chown when /app is still empty and add chown to the copy
    command, this saves docker from creating a large layer (about 10Mb)
    just for the permission changes
  • add a default cmd
  • use apk --no-cache so the cache doesn't get added to the image

I'd actually recommend using docker buildkit to improve performance/caching even more and use more explicit node versions and such but I didn't want to make the example too complicated.

Image size went down almost 20Mb with the changes implemented. You can also change assets now without it needing to reinstall npm packages every time.

- add python (needed for nodegyp rebuild, will display error otherwise)
- mkdir isn't needed, WORKDIR will create the directory if it doesn't
  exist
- combine commands where possible to reduce the amount of docker layers
- copy package*.json and install packages before doing the deploy so the
  install won't happen every time you modify a js/css file or other
  asset
- bash not needed, sh/ash is available
- install ncurses-libs, the app wouldn't start otherwise
- do the chown when /app is still empty and add chown to the copy
  command, this saves docker from creating a large layer (about 10Mb)
  just for the permission changes
- add a default cmd
- use apk --no-cache so the cache doesn't get added to the image
@Gazler Gazler requested a review from josevalim April 26, 2020 06:11
@josevalim josevalim merged commit 7f63101 into phoenixframework:master Apr 26, 2020
@josevalim
Copy link
Member

💚 💙 💜 💛 ❤️

Gazler pushed a commit that referenced this pull request Apr 26, 2020
- add python (needed for nodegyp rebuild, will display error otherwise)
- mkdir isn't needed, WORKDIR will create the directory if it doesn't
  exist
- combine commands where possible to reduce the amount of docker layers
- copy package*.json and install packages before doing the deploy so the
  install won't happen every time you modify a js/css file or other
  asset
- bash not needed, sh/ash is available
- install ncurses-libs, the app wouldn't start otherwise
- do the chown when /app is still empty and add chown to the copy
  command, this saves docker from creating a large layer (about 10Mb)
  just for the permission changes
- add a default cmd
- use apk --no-cache so the cache doesn't get added to the image
@otijhuis otijhuis deleted the improve-docker-example branch April 26, 2020 07: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

3 participants