From d6263a6849be6041a1b3f78b3cb4008c4a2a27f9 Mon Sep 17 00:00:00 2001 From: Kei Son Date: Thu, 30 Aug 2018 10:03:03 +0900 Subject: [PATCH] fix: docker build fail --- .travis.yml | 3 ++- Dockerfile | 24 ++++++++++++++++-------- package.json | 5 +++-- 3 files changed, 21 insertions(+), 11 deletions(-) diff --git a/.travis.yml b/.travis.yml index b135295a..67578a0e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,7 +8,8 @@ node_js: install: - npm install + - npm run build script: - - npm test + - npm t diff --git a/Dockerfile b/Dockerfile index 5812f758..b16e3469 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,16 +1,24 @@ -FROM node:8-alpine +FROM node:10-alpine as build WORKDIR /app COPY README.md package.json package-lock.json /app/ -RUN npm i --production +RUN npm i -COPY lib /app/lib +# Rarely edited +COPY bin /app/bin +COPY public /app/public +COPY tsconfig.json /app/ -COPY bin /app/bin -COPY public /app/public -COPY views /app/views -COPY * /app/ +# Frequently edited +COPY views /app/views +COPY src /app/src -EXPOSE 3000 +RUN npm run build + +RUN npm ci --only=production +FROM node:10-alpine as release +COPY --from=build /app/ /app/ + +EXPOSE 3000 CMD npm start diff --git a/package.json b/package.json index e6a99c3d..cad908db 100644 --- a/package.json +++ b/package.json @@ -3,8 +3,9 @@ "version": "1.6.0", "private": true, "scripts": { - "start": "tsc && node ./bin/www", - "test": "tsc && jasmine lib/spec/**/*.js", + "start": "node ./bin/www", + "build": "tsc", + "test": "jasmine lib/spec/**/*.js", "commitmsg": "validate-commit-msg", "changelog": "conventional-changelog -p angular -i CHANGELOG.md -s -r 0", "release": "conventional-github-releaser -p angular"