title: Angular Docker compose depending on env
body: <p>I want to a <code>docker-compose</code> command with argument which indicates which <code>npm</code> script should run. For example when I want to build a prod version it should run <code>npm run build:prod</code>, when dev <code>npm run build:dev</code>.</p>
  <p>So I have prepared a <code>docker-compose</code> file:</p>
  <pre><code>version: &quot;3&quot;
  services:
    customer-support-portal:
      image: &quot;customer-support-portal&quot;
      container_name: &quot;customer-support-portal&quot;
      build: .
      ports:
      - &quot;3000:80&quot;
      volumes:
      - &quot;/usr/src/app/node_modules&quot;
      - &quot;.:/usr/src/app&quot;
  </code></pre>
  <p>and <code>Dockerfile</code>:</p>
  <pre><code>ARG env=&quot;dev&quot;
  
  ### STAGE 1: Build ###
  FROM node:10-alpine as build-step
  WORKDIR /usr/src/app
  COPY package.json ./
  RUN npm install
  COPY . .
  RUN npm run build:${env}
  
  ### STAGE 2: Setup ###
  FROM nginx:alpine
  COPY --from=build-step /usr/src/app/dist/customer-support-portal /usr/share/nginx/html
  EXPOSE 80
  CMD [&quot;nginx&quot;, &quot;-g&quot;, &quot;daemon off;&quot;]
  </code></pre>
  <p>so as you see I tried to somehow set a variable called <code>env</code> (default <code>dev</code>) which indicates which build should be run. But I want to pass that argument when <code>docker-compose up -d</code> is called so it will start app with profile (dev/prod) I want to.</p>