Last active
August 8, 2024 07:51
-
-
Save Firnael/b38dcdb794a11f2892e9722e4e1fa3ce to your computer and use it in GitHub Desktop.
Distroless NodeJS + Typescript
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
## 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"] |
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
What is the purpose of copying entrypoint.sh?