Dockerfile 1.1 KB

12345678910111213141516171819202122232425262728293031
  1. # if you're doing anything beyond your local machine, please pin this to a specific version at https://hub.docker.com/_/node/
  2. FROM node:lts
  3. # set our node environment, either development or production
  4. # defaults to production, compose overrides this to development on build and run
  5. ARG NODE_ENV=production
  6. ENV NODE_ENV $NODE_ENV
  7. WORKDIR /code
  8. # default to port 80 for node, and 9229 and 9230 (tests) for debug
  9. ARG PORT=80
  10. ENV PORT $PORT
  11. EXPOSE $PORT 9229 9230
  12. COPY package.json /code/package.json
  13. COPY package-lock.json /code/package-lock.json
  14. RUN npm ci && npm cache clean --force
  15. # check every 30s to ensure this service returns HTTP 200
  16. HEALTHCHECK --interval=30s \
  17. CMD node healthcheck.js
  18. # copy in our source code last, as it changes the most
  19. COPY . /code
  20. # if you want to use npm start instead, then use `docker run --init in production`
  21. # so that signals are passed properly. Note the code in index.js is needed to catch Docker signals
  22. # using node here is still more graceful stopping then npm with --init afaik
  23. # I still can't come up with a good production way to run with npm and graceful shutdown
  24. CMD [ "node", "src/index.js" ]