Advertisement
Guest User

Untitled

a guest
Dec 10th, 2019
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.55 KB | None | 0 0
  1. # A debian-base image is used for cloning the repository and installing the
  2. # dependencies.
  3. FROM node:dubnium AS build
  4.  
  5. WORKDIR /var/node
  6.  
  7. ARG TAG
  8. ARG SSH_PRIVATE_KEY
  9.  
  10. # 1) An SSH key is needed to clone the repoository, and github needs to be a
  11. # known host so that ssh doesn't prompt for key verification.
  12.  
  13. # 2) The repo is cloned, then the TAG is checked out.
  14.  
  15. # 3) Install the dependencies and build.
  16.  
  17. # 4) Remove dev dependencies and install prod.
  18. RUN mkdir /root/.ssh/ \
  19. && echo "${SSH_PRIVATE_KEY}" > /root/.ssh/id_rsa \
  20. && chmod 600 /root/.ssh/id_rsa \
  21. && touch /root/.ssh/known_hosts \
  22. && ssh-keyscan github.com >> /root/.ssh/known_hosts \
  23. && git clone git@github.com:<MY_PRIVATE_REPO_HERE>.git . \
  24. && git checkout ${TAG} \
  25. && npm install \
  26. && npm run build \
  27. && rm -rf node_modules \
  28. && npm install --only=production
  29.  
  30. # An alpine image is used for the resulting image. It has the built
  31. # application and dependencies needed to run it, but not much else. It does
  32. # not contain the SSH key in the image's history.
  33. FROM node:dubnium-alpine
  34.  
  35. WORKDIR /var/node
  36.  
  37. # Copy the production assets.
  38. COPY --from=build ["/var/node/package.json", "./package.json"]
  39. COPY --from=build ["/var/node/connections.json", "./connections.json"]
  40. COPY --from=build ["/var/node/dist/", "./"]
  41. COPY --from=build ["/var/node/node_modules", "./node_modules"]
  42.  
  43. RUN npm install -g forever
  44.  
  45. # The application runs under the node user.
  46. USER node
  47. EXPOSE 3000
  48.  
  49. ENTRYPOINT ["forever", "--minUptime", "1000", "--spinSleepTime", "1000"]
  50. CMD ["main.js"]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement