Skip to content

Instantly share code, notes, and snippets.

@Firnael
Last active August 8, 2024 07:51
Show Gist options
  • Save Firnael/b38dcdb794a11f2892e9722e4e1fa3ce to your computer and use it in GitHub Desktop.
Save Firnael/b38dcdb794a11f2892e9722e4e1fa3ce to your computer and use it in GitHub Desktop.
Distroless NodeJS + Typescript
## NodeJS Typescript multi-stage docker image ##
# build project with typescript
FROM node:16.15.1-stretch as ts-compiler
WORKDIR /app
COPY package*.json ./
COPY tsconfig*.json ./
RUN npm install
COPY . ./
RUN npm run build
# retrieve only build artifact (no need typescript toolchain) and install prod dependencies
FROM node:16.15.1-stretch as ts-remover
WORKDIR /app
COPY --from=ts-compiler /app/package*.json ./
COPY --from=ts-compiler /app/dist/src ./dist
RUN npm install --omit=dev
# run the app in distroless container to reduce size
FROM gcr.io/distroless/nodejs:16
WORKDIR /app
COPY --from=ts-remover /app ./
USER 1000
EXPOSE 3000
CMD ["dist/app.js"]
@alexey-sh
Copy link

COPY scripts/entrypoint.sh ./entrypoint.sh

What is the purpose of copying entrypoint.sh?

@Firnael
Copy link
Author

Firnael commented Aug 8, 2024

COPY scripts/entrypoint.sh ./entrypoint.sh

What is the purpose of copying entrypoint.sh?

This is a project specific thing with wrong-named scripts, fixing it :p

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment