From fd44a9278293e0187a5ccd2c6816ac99a2222144 Mon Sep 17 00:00:00 2001 From: Petros Angelatos Date: Wed, 6 Jul 2016 01:47:48 -0700 Subject: [PATCH] don't install coffeescript in runtime image Signed-off-by: Petros Angelatos --- Dockerfile.build.template | 14 +++++++++----- package.json | 3 ++- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/Dockerfile.build.template b/Dockerfile.build.template index 5a656834..2425767f 100644 --- a/Dockerfile.build.template +++ b/Dockerfile.build.template @@ -14,8 +14,7 @@ RUN apt-get update \ python \ rsync \ wget \ - && rm -rf /var/lib/apt/lists/ \ - && npm install -g coffee-script + && rm -rf /var/lib/apt/lists/ ENV DOCKER_COMPOSE_VERSION 1.7.1 @@ -41,12 +40,17 @@ RUN set -x \ COPY package.json /usr/src/app/ -RUN JOBS=MAX npm install --unsafe-perm --production --no-optional \ - && npm dedupe +# First install devDependencies too in order to run the build +RUN JOBS=MAX npm install --unsafe-perm COPY src /usr/src/app/src -RUN coffee -c src +RUN npm run build + +# Re-install just production modules. This should be fast due to npm cache from previous layer +RUN rm -rf node_modules \ + && JOBS=MAX npm install --unsafe-perm --production --no-optional \ + && npm dedupe # Remove various uneeded filetypes in order to reduce space RUN find . -path '*/coverage/*' -o -path '*/test/*' -o -path '*/.nyc_output/*' \ diff --git a/package.json b/package.json index 688909cb..6b086830 100644 --- a/package.json +++ b/package.json @@ -3,6 +3,7 @@ "version": "2.1.1", "scripts": { "start": "./entry.sh", + "build": "coffee -c src", "lint": "resin-lint src/" }, "dependencies": { @@ -11,7 +12,6 @@ "bluebird": "^2.9.24", "body-parser": "^1.12.0", "buffer-equal-constant-time": "^1.0.1", - "coffee-script": "~1.10.0", "docker-delta": "0.0.11", "docker-progress": "^2.1.0", "docker-toolbelt": "^1.0.0", @@ -40,6 +40,7 @@ "node": "0.10.22" }, "devDependencies": { + "coffee-script": "~1.10.0", "resin-lint": "^1.3.1" } }