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

Remove unnecessary code #1

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

benjdewan
Copy link

1\ The top level Dockerfile is for building the Rails app image which has no dependencies on JavaScript. As such all the code to pull down and install node, npm and yarn is unnecessary.
2\ yarn is already installed in the base node image so there is no reason to install it a second time

1\ The top level Dockerfile is for building the Rails
   app image which has no dependencies on JavaScript.
   As such all the code to pull down and install node,
   npm and yarn is unnecessary.
2\ yarn is already installed in the base `node` image
   so there is no reason to install it a second time
Containers are supposed to be as small as possible,
so excluding build and log data is a good thing
Due to the immutability of Docker images every
Dockerfile directive creates an intermediate layer
which in turn increases the final images size. As
such directives should be removed or combined where
possible.

* The 'COPY' directive will create a directory inside
  the container if it does not exist, so
  MKDIR /foo
  COPY . /foo
  can be reduced to
  COPY . /foo
* There is no value to copying a specific file, and then
  copying the entire directory the file is in instead of
  copying the entire directory to begin with
@benjdewan
Copy link
Author

I've added a few more commits to this PR. The main purpose of all of them is unchanged: remove unnecessary code to get this repo to work.

I'm happy to explain any of my changes if they are confusing.

As with the Ruby Dockerfile, the fewer Dockerfile
directives the better. Additionally:
- Combining N-many RUN directives into 1 with '&&'
  turns N-many layers into 1. A huge win
- Mixing npm and yarn to install packages is confusing.
  Using a single package manager is preferred when
  possible.
- For clarity the ENDPOINT or CMD directive that is
  run by `docker run` or `docker-compose up` should
  be at the end of the file. This is not a
  requirement, but it greatly improves readability.
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.

1 participant