2020-03-05 17:40:44 +00:00
|
|
|
# if you're doing anything beyond your local machine, please pin this to a specific version at https://hub.docker.com/_/node/
|
2022-02-19 21:34:23 +00:00
|
|
|
FROM node:current-slim
|
2020-03-05 17:40:44 +00:00
|
|
|
|
|
|
|
# set our node environment, either development or production
|
|
|
|
# defaults to production, compose overrides this to development on build and run
|
|
|
|
ARG NODE_ENV=production
|
|
|
|
ENV NODE_ENV $NODE_ENV
|
|
|
|
|
2020-03-23 13:18:50 +00:00
|
|
|
WORKDIR /code
|
|
|
|
|
2020-03-05 17:40:44 +00:00
|
|
|
# default to port 80 for node, and 9229 and 9230 (tests) for debug
|
|
|
|
ARG PORT=80
|
|
|
|
ENV PORT $PORT
|
|
|
|
EXPOSE $PORT 9229 9230
|
|
|
|
|
2020-03-23 13:18:50 +00:00
|
|
|
COPY package.json /code/package.json
|
|
|
|
COPY package-lock.json /code/package-lock.json
|
2020-03-24 09:48:45 +00:00
|
|
|
RUN npm ci
|
2020-03-05 17:40:44 +00:00
|
|
|
|
|
|
|
# check every 30s to ensure this service returns HTTP 200
|
2020-03-23 13:18:50 +00:00
|
|
|
HEALTHCHECK --interval=30s \
|
|
|
|
CMD node healthcheck.js
|
2020-03-05 17:40:44 +00:00
|
|
|
|
|
|
|
# copy in our source code last, as it changes the most
|
2020-03-23 13:18:50 +00:00
|
|
|
COPY . /code
|
2020-03-05 17:40:44 +00:00
|
|
|
|
|
|
|
# if you want to use npm start instead, then use `docker run --init in production`
|
|
|
|
# so that signals are passed properly. Note the code in index.js is needed to catch Docker signals
|
|
|
|
# using node here is still more graceful stopping then npm with --init afaik
|
|
|
|
# I still can't come up with a good production way to run with npm and graceful shutdown
|
2020-03-23 13:18:50 +00:00
|
|
|
CMD [ "node", "src/index.js" ]
|