title: "npm run build" in Dockerfile: dist folder is generated but disappears
body: <p>I have a <code>Dockerfile</code> for a Django and Vue.js app that I use along with <code>Gitlab</code>.</p>
  
  <p>The problem that I'm about to describe only happens when deploying via <code>Gitlab CI</code> and the corresponding <code>.gitlab-ci.yml</code> file. When running the <code>docker-compose up</code> command in my local machine, this doesn happen.</p>
  
  <p>So I run <code>docker-compose up</code> and all the instructions in the Dockerfile run apparently fine. But when I check the production server, the <code>dist</code> folder (where the <code>bundle.js</code> and <code>bundle.css</code> should be stored) doesn't exist.</p>
  
  <p>The logs that are spit out while running the <code>Dockerfile</code> confirm that the <code>npm install</code> and <code>npm run build</code> commands are run, and it even confirms that the <code>dist/bundle.js</code> and <code>dist/bundle.css</code> files have been generated. But for some reason they seem to be deleted.</p>
  
  <p>This is my <strong><em>Dockerfile</em></strong>:</p>
  
  <pre><code>FROM python:3.7-alpine
  MAINTAINER My Name
  
  ENV PYTHONUNBUFFERED 1
  
  RUN mkdir /app
  
  # make the 'app' folder the current working directory
  WORKDIR /app
  
  # copy project files and folders to the current working directory (i.e. 'app' folder)
  COPY ./app .
  
  COPY ./requirements.txt /requirements.txt
  RUN apk add --update --no-cache postgresql-client
  RUN apk add --update --no-cache --virtual .tmp-build-deps \
        gcc libc-dev linux-headers postgresql-dev
  RUN pip install -r /requirements.txt
  RUN apk del .tmp-build-deps
  
  # copy both 'package.json' and 'package-lock.json' (if available)
  COPY app/frontend/package*.json ./frontend/
  
  # Install npm
  RUN  apk add --update nodejs &amp;&amp; apk add --update nodejs-npm
  
  # install project dependencies
  WORKDIR /app/frontend
  RUN npm install
  
  # build app for production with minification
  RUN npm run build
  
  RUN adduser -D user
  USER user
  
  CMD ["sh ../scripts/entrypoint.sh"]
  </code></pre>
  
  <p>This is the <strong><em>.gitlab-ci.yml</em></strong> file:</p>
  
  <pre><code>image: docker:latest
  
  services:
    - docker:dind
  
  before_script:
    - echo "Runnig before_script"
    - sudo apt-get install -y python-pip
    - sudo apt-get install -y nodejs
    - pip install docker-compose
  
  stages:
    - test
    - build
    - deploy
  
  test:
    stage: test
    script:
      - echo "Testing the app"
      - docker-compose run app sh -c "python /app/manage.py test &amp;&amp; flake8"
  
  build:
    stage: build
    only:
      - develop
      - production
      - feature/gitlab_ci
    script:
      - echo "Building the app"
      - docker-compose build
  
  deploy:
    stage: deploy
    only:
      - master
      - develop
      - feature/gitlab_ci
    script:
      - echo "Deploying the app"
      - docker-compose up --build -d
  </code></pre>
  
  <p>This is the content of the <strong><em>docker-compose.yml</em></strong> file:</p>
  
  <pre><code>version: "3"
  
  services:
    app:
      build:
        context: .
      ports:
        - "8000:8000"
      volumes:
        - ./app:/app
      command: &gt;
        sh -c "python /app/manage.py runserver 0.0.0.0:8000"
      environment:
        - DB_HOST=db
        - DB_NAME=app
        - DB_USER=postgres
        - DB_PASS=postgres
      depends_on:
        - db
    db:
      image: postgres:10-alpine
      environment:
        - POSTGRES_DB=app
        - POSTGRES_USER=postgres
        - POSTGRES_PASSWORD=postgres
  </code></pre>
  
  <p>This is the content of the <strong><em>entrypoint.sh</em></strong> file:</p>
  
  <pre><code>#!/bin/bash
  
  (cd .. &amp;&amp; ./manage.py collectstatic --noinput)
  # Migration files are commited to git. Makemigrations is not needed.
  # ./manage.py makemigrations app_name
  (cd .. &amp;&amp; ./manage.py migrate)
  </code></pre>
  
  <p>I would like to know why the <code>dist/</code> folder disappears and how to keep it.</p>