Skip to content

Instantly share code, notes, and snippets.

@mosesliao
Last active February 16, 2021 03:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mosesliao/8f9da98a3bca2ced4bcff4dddf6f03b1 to your computer and use it in GitHub Desktop.
Save mosesliao/8f9da98a3bca2ced4bcff4dddf6f03b1 to your computer and use it in GitHub Desktop.
FROM node:8.12-slim as BUILD_IMAGE
# install the needed libraries
RUN apt-get update \
&& apt-get install -y \
git
# install node-prune (https://github.com/tj/node-prune)
RUN curl -sfL https://install.goreleaser.com/github.com/tj/node-prune.sh | bash -s -- -b /usr/local/bin
WORKDIR /home/node/app
COPY . /home/node/app
RUN mkdir /root/.ssh/
COPY id_rsa /root/.ssh/id_rsa
RUN chmod 600 /root/.ssh/id_rsa
RUN npm install
RUN npm prune --production
RUN /usr/local/bin/node-prune
# use node has user
FROM node:8.12-slim
LABEL version="0.5.0"
COPY --from=BUILD_IMAGE /home/node/app /home/node/app
USER "node"
WORKDIR /home/node/app
# use node has user
EXPOSE 3030
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment