title: How to implement Dockerfile inheritance?
body: <p>I have a Dockerfile which installs production &amp; test dependencies. I want to have separate image for tests, so production image is smaller, without to much code duplication. Maybe there is something like <code>FROM</code> statement for referencing other Dockerfiles?</p>
  
  <p>Dockerfile has following lines:</p>
  
  <pre><code>ADD requirements.txt ${PROJECT_DIR}/requirements.txt
  RUN pip install --no-cache --process-dependency-links --trusted-host github.com -r requirements.txt
  ADD requirements-test.txt ${PROJECT_DIR}/requirements-test.txt
  RUN pip install --no-cache --process-dependency-links --trusted-host github.com -r requirements-test.txt
  </code></pre>
  
  <p>First two install depencencies for project, second two - install dependencies for testing (pytest, pylint, etc.). </p>
  
  <p>I also have docker-compose that starts database, redis cache, etc. This is how I run service and run tests:</p>
  
  <pre><code>run:
      docker-compose -f docker-compose.yaml run
  test:
      docker-compose -f docker-compose-dev.yaml run py.test tests/
  </code></pre>
  
  <p>Inside both <code>docker-compose.yaml</code> has this build config for my container:</p>
  
  <pre><code>build:
    context: .
    dockerfile: ./Dockerfile
  </code></pre>
  
  <p>So, I could reference different Dockerfiles from my <code>docker-compose.yaml</code>, but I don't want them to be complete copies that have only two lines difference.</p>