From 2eb74c000b0b1f1957ec9097205d2d7d7a5a515b Mon Sep 17 00:00:00 2001 From: Jannis R Date: Fri, 1 May 2020 20:17:07 +0200 Subject: [PATCH] improve Docker layer caching --- Dockerfile | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/Dockerfile b/Dockerfile index d55be7b..75b31c2 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,18 +1,22 @@ -FROM node:alpine - +FROM node:alpine as builder WORKDIR /app -ADD . /app -RUN apk add --update git bash && \ - npm install --production && \ - apk del git && \ - rm -rf /tmp/* /var/cache/apk/* +RUN apk add --update git bash + +ADD package.json /app +RUN npm install --production + +FROM node:alpine +WORKDIR /app EXPOSE 3000 ENV HOSTNAME v5.db.transport.rest ENV PORT 3000 +COPY --from=builder /app/node_modules ./node_modules +ADD . /app + RUN npm run build CMD ["node", "index.js"]