Docker: build using git push instead of ADD . /myapp
Basically my Dockerfile looks like so:
FROM ruby:2.1.4 RUN apt-get update -qq && apt-get install -y build-essential libpq-dev RUN mkdir /myapp WORKDIR /myapp ADD Gemfile /myapp/Gemfile RUN bundle install ADD . /myapp
It is fine, but the last line
ADD . /myapp is not very smart: it duplicates every local files, including
<APP_ROOT>/log which contains 8GB of useless data.
On the other hand, git is perfectly configured to store only usefull data (thanks to
.gitignore among other).
Ain’t there a simple solution to make a
git pull <local_files> master from the Docker to the host or something?
Otherwise I could also pull from github but it adds external dependency.
2 Solutions collect form web for “Docker: build using git push instead of ADD . /myapp”
It sounds like you might be looking for the .dockerignore file. Doing a
git pull inside the image at build time doesn’t seem like a very deterministic solution.
You could add git inside the docker image with
apt-get install -y git
RUN git clone ....
But, IMHO, I think it’s best to clean your app folder and then add it via the ADD docker command