From 77d14b387b85435b65177e6ac4be2094c3c3b49d Mon Sep 17 00:00:00 2001 From: Test Date: Fri, 19 Jul 2019 10:29:26 +0200 Subject: [PATCH] feat(docker): Minimize docker image and docker build context file size (#113) --- .dockerignore | 10 ++++++---- Dockerfile | 26 +++++++++++++++++--------- 2 files changed, 23 insertions(+), 13 deletions(-) diff --git a/.dockerignore b/.dockerignore index a9138e2..15032db 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,8 +1,10 @@ # Dependency directories -node_modules/ -dist/ -coverage/ -build/ +**/node_modules/ +**/dist/ +**/coverage/ +**/build/ .dockerignore .gitignore +.git README.md +Dockerfile \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index ff66242..c1354a9 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,22 +1,30 @@ # build environment FROM node:10.8.0 as builder + RUN mkdir -p /usr/omniboard WORKDIR /usr/omniboard -ENV PATH /usr/omniboard/node_modules/.bin:$PATH - -# grab tini for signal processing and zombie killing -ENV TINI_VERSION v0.18.0 -ADD https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini /tini -RUN chmod +x /tini -# Having "--" at the end will enable passing command line args to npm script -ENTRYPOINT ["/tini", "--", "yarn", "run", "prod"] +ENV PATH=/usr/omniboard/node_modules/.bin:$PATH GENERATE_SOURCEMAP=false # install yarn RUN npm install -g yarn COPY . /usr/omniboard -WORKDIR /usr/omniboard RUN yarn install EXPOSE 9000 + +FROM node:10-alpine + +WORKDIR /usr/omniboard +RUN apk add --no-cache tini + +# Having "--" at the end will enable passing command line args to npm script +ENTRYPOINT ["/sbin/tini", "--", "yarn", "run", "prod"] + +ENV PATH /usr/omniboard/node_modules/.bin:$PATH + +COPY --from=builder /usr/omniboard/package.json /usr/omniboard/package.json +COPY --from=builder /usr/omniboard/dist /usr/omniboard/dist +COPY --from=builder /usr/omniboard/web/build /usr/omniboard/web/build +RUN yarn install --production && yarn cache clean --force