-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(docker): Minimize docker image and docker build context file size (
#113)
- Loading branch information
1 parent
a1d550c
commit 77d14b3
Showing
2 changed files
with
23 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |