I want to run node application with pm2 in distroless image. As it do not have any shell inside it.
Asked
Active
Viewed 327 times
1 Answers
0
Use this docker file for reference, for pm2 shell /bin/sh
is required so we are manually copying all the required package from above image.
After passing the absolute path in CMD or ENTRYPOINT it will work fine.
FROM node AS build-env
ADD . /app
RUN apt-get update
WORKDIR /app
RUN npm install --omit=dev
RUN npm --loglevel info install pm2 -g
RUN ls -a
RUN pm2 --version
FROM gcr.io/distroless/nodejs:12
COPY --from=build-env /usr/local/ /usr/local
COPY --from=build-env /usr/local/ /usr/local
COPY --from=build-env /usr/sbin/ /usr/sbin
COPY --from=build-env /usr/share/ /usr/share/
COPY --from=build-env /usr/src/ /usr/src/
COPY --from=build-env /usr/bin/ /usr/bin/
COPY --from=build-env /bin/ /bin/
COPY --from=build-env /app /app
WORKDIR /app
EXPOSE 3000
CMD ["/usr/local/lib/node_modules/pm2/lib/binaries/Runtime4Docker.js","hello_express.js"]

Max Cascone
- 648
- 9
- 25