title: How to properly build the Docker with nodejs/ts?
body: <p>Been struggling for a couple days to run the project in prod and it just keeps showing different errors. The last one(hopefully) is:</p>
  
  <pre><code>&gt; rimraf dist &amp;&amp; tsc -p tsconfig.build.json
  tsc-watch/test/fixtures/failing.ts(2,1): error TS1005: '}' expected.
  </code></pre>
  
  <p>But <code>tsconfig.build.json</code> is fine:</p>
  
  <pre><code>{
    "extends": "./tsconfig.json",
    "exclude": ["node_modules", "dist", "test", "**/*spec.ts"]
  }
  </code></pre>
  
  <p>It happens after I try to build/run the docker container with: 
  <code>docker-compose up --force-recreate --build</code></p>
  
  <p>Here's what I have in the Dockerfile:</p>
  
  <pre><code>FROM node:11-stretch
  ADD ./* $HOME/
  RUN npm install
  RUN npm run build
  CMD npm run start:prod
  </code></pre>
  
  <p>And the package.json</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>{
    "name": "mvp-api",
    "private": true,
    "version": "0.0.1",
    "description": "MVP API",
    "license": "MIT",
    "scripts": {
      "build": "rimraf dist &amp;&amp; tsc -p tsconfig.build.json",
      "format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"",
      "start": "ts-node -r tsconfig-paths/register src/main.ts",
      "start:dev": "tsc-watch -p tsconfig.build.json --onSuccess \"node dist/main.js\"",
      "start:debug": "tsc-watch -p tsconfig.build.json --onSuccess \"node --inspect-brk dist/main.js\"",
      "start:prod": "node dist/main.js",
      "lint": "tslint -p tsconfig.json -c tslint.json",
      "test": "jest",
      "test:watch": "jest --watch",
      "test:cov": "jest --coverage",
      "test:debug": "node --inspect-brk -r tsconfig-paths/register -r ts-node/register node_modules/.bin/jest --runInBand",
      "test:e2e": "jest --config ./test/jest-e2e.json"
    },
    "dependencies": {
      "@nestjs/common": "^6.5.3",
      "@nestjs/core": "^6.5.3",
      "@nestjs/jwt": "^6.1.1",
      "@nestjs/microservices": "^6.0.4",
      "@nestjs/passport": "^6.1.0",
      "@nestjs/platform-express": "^6.0.4",
      "@nestjs/swagger": "^3.1.0",
      "@nestjs/typeorm": "^6.1.3",
      "@nestjs/websockets": "^6.0.4",
      "@nestrx/twilio": "0.0.2",
      "@types/mailgun-js": "^0.22.3",
      "@types/qrcode": "^1.3.4",
      "aws-sdk": "^2.513.0",
      "cache-manager": "^2.10.0",
      "cache-manager-mongodb": "^0.2.1",
      "cache-manager-redis-store": "^1.5.0",
      "class-transformer": "^0.2.3",
      "class-validator": "^0.10.0",
      "dotenv": "^8.0.0",
      "hbs": "^4.0.4",
      "is-base64": "^0.1.0",
      "libphonenumber-js": "^1.7.22",
      "mailgun-js": "^0.22.0",
      "mysql": "^2.17.1",
      "nestjs-config": "^1.4.3",
      "onesignal-node": "^2.1.1",
      "passport": "^0.4.0",
      "passport-jwt": "^4.0.0",
      "qrcode": "^1.4.1",
      "randomstring": "^1.1.5",
      "reflect-metadata": "0.1.13",
      "rimraf": "2.6.3",
      "rxjs": "6.4.0",
      "swagger-ui-express": "^4.0.7",
      "twilio": "^3.33.4",
      "typeorm": "^0.2.18",
      "vcard-generator": "0.0.7"
    },
    "devDependencies": {
      "@nestjs/testing": "6.1.1",
      "@types/cache-manager": "^2.10.0",
      "@types/express": "4.16.1",
      "@types/jest": "24.0.11",
      "@types/node": "11.13.4",
      "@types/randomstring": "^1.1.6",
      "@types/supertest": "2.0.7",
      "jest": "24.7.1",
      "prettier": "1.17.0",
      "supertest": "4.0.2",
      "ts-jest": "24.0.2",
      "ts-loader": "^6.0.4",
      "ts-node": "8.1.0",
      "tsc-watch": "2.2.1",
      "tsconfig-paths": "3.8.0",
      "tslint": "5.16.0",
      "typescript": "3.4.3",
      "webpack": "^4.39.2",
      "webpack-cli": "^3.3.6",
      "webpack-node-externals": "^1.7.2"
    },
    "jest": {
      "moduleFileExtensions": [
        "js",
        "json",
        "ts"
      ],
      "rootDir": "src",
      "testRegex": ".spec.ts$",
      "transform": {
        "^.+\\.(t|j)s$": "ts-jest"
      },
      "collectCoverageFrom": [
        "**/*.(t|j)s"
      ],
      "coverageDirectory": "../coverage",
      "testEnvironment": "node"
    }
  }</code></pre>
  </div>
  </div>
  </p>
  
  <p>It used to build fine with these configurations but after purging all containers/images and trying to recreate everything it just doesn't work. </p>
  
  <p>Does anyone know how to get it to run properly in prod? </p>