title: How can I export env variables to a Dockerfile?
body: <h3>Objective</h3>
  <p>I have an env variable script file that looks like:</p>
  <pre class="lang-sh prettyprint-override"><code>#!/bin/sh
  export FOO=&quot;public&quot;
  export BAR=&quot;private&quot;
  </code></pre>
  <p>I would like to source the env variables to be available when a docker image is being built. I am aware that I can use <code>ARG</code> and <code>ENV</code> with build args, but I have too many Env Variables, and I am afraid that will be a lengthy list.</p>
  <p>It's worth mentioning that I only need the env variables to install a specific step in my docker file (will highlight in the Dockerfile below), and do not necessarily want them to be available in the built image after that.</p>
  <h3>What I have tried so far</h3>
  <p>I have tried having a script (<code>envs.sh</code>) that export env vars like:</p>
  <pre class="lang-sh prettyprint-override"><code>#!/bin/sh
  export DOG=&quot;woof&quot;
  export CAT=&quot;meow&quot;
  </code></pre>
  <p>My Docker file looks like:</p>
  <pre><code>FROM fishtownanalytics/dbt:0.18.1
  # Define working directory
  # Load ENV Vars
  COPY envs.sh envs.sh
  CMD [&quot;sh&quot;, &quot;envs.sh&quot;]
  # Install packages required
  CMD [&quot;sh&quot;, &quot;-c&quot;, &quot;envs.sh&quot;]
  RUN dbt deps # I need to env variables to be available for this step
  
  # Exposing DBT Port
  EXPOSE 8081
  </code></pre>
  <p>But that did not seem to work. How can I export env variables as a script to the docker file?</p>