Skip to content

Instantly share code, notes, and snippets.

@ValentaTomas
Last active June 15, 2021 14:57
Show Gist options
  • Save ValentaTomas/182065fc84f8ddb3d4cf4d2c4808519a to your computer and use it in GitHub Desktop.
Save ValentaTomas/182065fc84f8ddb3d4cf4d2c4808519a to your computer and use it in GitHub Desktop.
Node.js 16 two stage build setup
# 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