Created
March 18, 2018 12:24
-
-
Save omerxx/fd6a308e6a31f3fa79a7d9edae05bfb8 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
# uses Docker Multi-Stage Build | |
# https://docs.docker.com/v17.09/engine/userguide/eng-image/multistage-build/ | |
# -- builder container | |
FROM node:9-alpine as builder | |
# download Yelp/dumb-init | |
RUN apk add --no-cache curl | |
RUN curl -sL https://github.com/Yelp/dumb-init/releases/download/v1.2.1/dumb-init_1.2.1_amd64 -o /sbin/dumb-init \ | |
&& chmod +x /sbin/dumb-init | |
WORKDIR /opt/app | |
# only run `yarn install` when package.json changed, otherwise use cache | |
COPY package.json /opt/app/ | |
# install all dependencies in packages.json, including devDependencies | |
RUN yarn install | |
# copy the code before a babel build | |
COPY . /opt/app/ | |
RUN yarn run -s build | |
# -- runtime container | |
FROM node:9-alpine | |
WORKDIR /opt/app | |
COPY --from=builder /sbin/dumb-init /sbin/dumb-init | |
# only run `yarn install` when package.json changed, otherwise use cache | |
COPY --from=builder /opt/app/package.json . | |
# do not install devDependencies, only "dependencies" from package.json | |
RUN yarn install --production | |
# copy the compiled code from builder | |
COPY --from=builder /opt/app/dist dist/ | |
CMD [""] | |
ENTRYPOINT [ "/sbin/dumb-init", "/usr/local/bin/node", "dist/index.js" ] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment