title: Adding project folder except for Dockerfile
body: <p>I am trying to run a small Rails app in a docker container. I am getting close, however I am struggling with my Dockerfile.</p>
  
  <p>I have added the following command to my Dockerfile to recursively add all files in my project folder.</p>
  
  <pre><code>ADD .
  </code></pre>
  
  <p>After this, I run</p>
  
  <pre><code>RUN bundle install --deployment
  </code></pre>
  
  <p>However, because my <code>ADD</code> command also adds the Dockerfile, it means that my image cache breaks every time I edit my Dockerfile forcing me to rebundle.</p>
  
  <p>According to <a href="https://docs.docker.com/reference/builder/#the-dockerignore-file">https://docs.docker.com/reference/builder/#the-dockerignore-file</a>, I can use a <code>.dockerignore</code> file to ignore Dockerfile, but this causes the <code>docker build</code> command to fail with</p>
  
  <pre><code>2014/09/17 22:12:46 Dockerfile was excluded by .dockerignore pattern 'Dockerfile'
  </code></pre>
  
  <p>How can I easily add my project to my image, but exclude the Dockerfile, so I don't break the docker image cache?</p>