title: Can you have a non top-level Dockerfile when invoking COPY?
body: <p>Have a Dockerfile to build releases for an Elixir/Phoenix application...The tree directory structure is as follows, where the Dockerfile (which has a dependency on this <a href="https://github.com/bitwalker/alpine-elixir/blob/master/Dockerfile" rel="nofollow noreferrer">other Dockerfile</a>) is in the &quot;infra&quot; subfolder and needs access to all the files one level above &quot;infra&quot;.</p>
  <pre><code>.
  ├── README.md
  ├── assets
  │   ├── css
  │   ├── js
  │   ├── node_modules
  │   ├── package-lock.json
  │   ├── package.json
  ├── lib
  ├── infra
  │   ├── Dockerfile
  │   ├── config.yaml
  │   ├── deployment.yaml
  </code></pre>
  <p>The Dockerfile looks like:</p>
  <pre><code># https://github.com/bitwalker/alpine-elixir
  FROM bitwalker/alpine-elixir:latest
  
  # Set exposed ports
  EXPOSE 4000
  ENV PORT=4000
  
  ENV MIX_ENV=prod
  ENV APP_HOME /app
  ENV APP_VERSION=0.0.1
  COPY ./ ${HOME}
  WORKDIR ${HOME}
  RUN mix deps.get
  RUN mix compile
  RUN MIX_ENV=${MIX_ENV} mix distillery.release
  RUN echo $HOME
  COPY ${HOME}/_build/${MIX_ENV}/rel/my_app/releases/${APP_VERSION}/my_app.tar.gz .
  RUN tar -xzvf my_app.tar.gz
  
  USER default
  
  CMD ./bin/my_app foreground
  </code></pre>
  <p>The command &quot;mix distillery.release&quot; is what builds the my_app.tar.gz file in the path indicated by the COPY command.</p>
  <p>I invoke the <code>docker build</code> as follows in the top-level directory (the parent directory of &quot;infra&quot;):</p>
  <pre><code>docker build -t my_app:local -f infra/Dockerfile .
  </code></pre>
  <p>I basically then get an error with COPY:</p>
  <pre><code>Step 13/16 : COPY ${HOME}/_build/${MIX_ENV}/rel/my_app/releases/${APP_VERSION}/my_app.tar.gz .
  COPY failed: stat /var/lib/docker/tmp/docker-builder246562111/opt/app/_build/prod/rel/my_app/releases/0.0.1/my_app.tar.gz: no such file or directory
  </code></pre>
  <p>I understand that the COPY command depends on the &quot;build context&quot; but I thought that by issuing the &quot;docker build&quot; in the parent directory of infra meant I had the appropriate context set for the COPY, but clearly that doesn't seem to be the case. Is there a way to have a Dockerfile one level below the parent directory that contains all the files needed to build an Elixir/Phoenix &quot;release&quot; (the my_app.tar.gz and associated files created via the command <code>mix distillery.release</code>)? What bits am I missing?</p>