title: Put args from Jenkins to dockerfile
body: <p>we have dockerfile in our angular2 project and we build/push/pull it on server with jenkins</p>
  
  <p>here is content of dockerfile</p>
  
  <pre><code># Stage 0, based on Node.js, to build and compile Angular
  FROM node:latest as node
  WORKDIR /app
  COPY package.json /app/
  RUN npm install
  COPY ./ /app/
  ARG env=prod
  RUN npm run build -- --prod --environment $env 
  
  # Stage 1, based on Nginx, to have only the compiled app, ready for production with Nginx
  FROM nginx:1.13
  COPY --from=node /app/dist/ /usr/share/nginx/html
  COPY ./nginx-custom.conf /etc/nginx/conf.d/default.conf
  </code></pre>
  
  <p>when I build and push it with this args (from powershell or cmd) it works great 
  but need to put this arg from jenkins slave when deploying, is this possible? </p>
  
  <blockquote>
    <p>--build-arg env=dev .</p>
  </blockquote>
  
  <pre><code>docker build -t admione-front-test:latest --build-arg env=test .
  </code></pre>
  
  <p>here is jenkins build and deploy script</p>
  
  <pre><code>node {
  
     stage ('build') {
        build job: 'pathToProject' //path to workspace (project files)
     }
  
     stage ('deploy') {
  
        sshagent(credentials: ['jenkins-credential']) {
           String commandToRun = 'docker stop project || true &amp;&amp; docker rm project || true ';
           commandToRun = commandToRun + ' &amp;&amp; docker pull registry/project:latest ';
           commandToRun = commandToRun + ' &amp;&amp; docker run -d -p 81:80 --restart unless-stopped  --name project registry/project:latest '
                   sh "ssh -o StrictHostKeyChecking=no root /bin/bash -c '\"${commandToRun}\"'"
              }
          }
   }
  </code></pre>