-
-
Save ghoullier/cf683dae4da25acdb40fb2708cef4131 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
## Kodo 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 | |
COPY --from=ts-compiler /app/src/config ./dist/config | |
COPY scripts/entrypoint.sh ./entrypoint.sh | |
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 | |
# default env, overriden by CI variables or manual build | |
ARG env=dev | |
ARG redis_alert_cn | |
ARG redis_push_cn | |
ENV NODE_ENV=$env | |
ENV REDIS_ALERT_CN=$redis_alert_cn | |
ENV REDIS_PUSH_CN=$redis_push_cn | |
ENV DEBUG=kodo:* | |
CMD ["dist/app.js"] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment