Last active
June 15, 2021 14:57
-
-
Save ValentaTomas/182065fc84f8ddb3d4cf4d2c4808519a to your computer and use it in GitHub Desktop.
Node.js 16 two stage build setup
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
# This stage installs modules | |
FROM node:16.2.0 as modules | |
WORKDIR /app | |
COPY package.json package-lock.json ./ | |
RUN npm ci --production | |
# This stage builds TypeScript | |
FROM node:16.2.0 as build | |
WORKDIR /app | |
COPY package.json package-lock.json ./ | |
RUN npm ci | |
COPY scripts/build.js ./scripts/build.js | |
COPY tsconfig.json ./ | |
COPY ./src ./src | |
RUN ./scripts/build.js | |
# This stage copies modules and built TypeScript | |
FROM mhart/alpine-node:slim-16.2.0 | |
RUN apk add --no-cache tini | |
WORKDIR /app | |
COPY --from=modules ./app ./ | |
COPY --from=build ./app/lib ./lib | |
ENTRYPOINT ["/sbin/tini", "--"] | |
CMD ["node", "lib/index.js"] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment