title: Dockerfile to deploy Vue.js application in several environments?
body: <p>I'm trying to create a Dockerfile to deploy a Vue.js app as a docker in Cloud Run (GCP). From the Vue official documentation and get a Dockerfile to deploy the app in a "production mode":</p>
  
  <pre><code>FROM node:lts-alpine
  RUN npm install -g http-server
  WORKDIR /app
  COPY package*.json ./
  RUN npm install
  COPY . .
  RUN npm run build
  EXPOSE 8080
  CMD [ "http-server", "dist" ]
  </code></pre>
  
  <p>It works properly but I want to modify the Dockerfile to make it dynamic. I mean, I want that this file is able to deploy either to production or to DEV using a kind of input parameter</p>
  
  <p>I've tried several attempts, one of those was to add these new lines</p>
  
  <pre><code>ENV ENT=production
  RUN NODE_ENV=${ENT} npm run build
  </code></pre>
  
  <p>With the intension to define a default value for the environment variable as "production", and in the Cloud Run service define the same environment variable as "dev". I thought the variable defined on the cloud run service will overwrite the local variable (Dockerfile) at the moment of running the docker. It was not overwritten and again the app is running in production</p>
  
  <p>Do you know if there is a way to overwrite a Dockerfile environment variable or if It is possible to create something as</p>
  
  <pre><code>npm run build:dev
  npm run build:prod
  </code></pre>
  
  <p>dynamically depending on the environment I want to deploy?</p>
  
  <p>This is my <strong>package.json</strong></p>
  
  <pre><code>{
    /// ...
    "scripts": {
      "dev": "vue-cli-service serve --mode development",
      "test": "cross-env NODE_ENV=testing vue-cli-service serve --mode testing",
      "prod": "vue-cli-service serve --mode production",
      "build:dev": "vue-cli-service build --mode development",
      "build": "vue-cli-service build --mode production",
      "lint": "vue-cli-service lint"
    },
    /// ...
  }
  </code></pre>