Skip to content

Commit

Permalink
feat(docker): Minimize docker image and docker build context file size (
Browse files Browse the repository at this point in the history
  • Loading branch information
nuth authored and vivekratnavel committed Jul 19, 2019
1 parent a1d550c commit 77d14b3
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 13 deletions.
10 changes: 6 additions & 4 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
# Dependency directories
node_modules/
dist/
coverage/
build/
**/node_modules/
**/dist/
**/coverage/
**/build/
.dockerignore
.gitignore
.git
README.md
Dockerfile
26 changes: 17 additions & 9 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 77d14b3

Please sign in to comment.