Reasoning behind tmp folder usage
Closed this issue · 1 comments
JamesChevalier commented
I'm still fairly new to Docker, and I'm wondering if there's a bit I can learn from your process. I'm referring to these lines in the Dockerfile:
WORKDIR /tmp
ADD Gemfile /tmp/
ADD Gemfile.lock /tmp/
RUN bundle install --jobs 4 --retry 3
# Copy the application into the container
COPY . /usr/src/app
WORKDIR /usr/src/app
Whereas my approach is usually:
WORKDIR /app
COPY Gemfile /app/
COPY Gemfile.lock /app/
RUN bundle install --jobs 4 --retry 3
COPY . /app
Is there a benefit of your approach over my approach?
Is my approach more/less efficient?
Does my approach have issues that I haven't uncovered yet?
pacuna commented
Hi,
It should be exactly the same result I think.
It's just a habit of mine from the first time that I learn about Docker and Rails and read posts like these:
- https://ilikestuffblog.com/2014/01/06/how-to-skip-bundle-install-when-deploying-a-rails-app-to-docker/
- https://medium.com/magnetis-backstage/how-to-cache-bundle-install-with-docker-7bed453a5800
But they also don't mention if using a tmp directory has some benefit.
Anyway, I did some refactoring for the path app and use the same path for simplicity. Thanks!