4
0

Dockerfile 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. # syntax=docker/dockerfile:1.4
  2. # if you're doing anything beyond your local machine, please pin this to a specific version at https://hub.docker.com/_/node/
  3. FROM node:lts AS development
  4. # set our node environment, either development or production
  5. # defaults to production, compose overrides this to development on build and run
  6. ARG NODE_ENV=production
  7. ENV NODE_ENV $NODE_ENV
  8. WORKDIR /code
  9. # default to port 80 for node, and 9229 and 9230 (tests) for debug
  10. ARG PORT=80
  11. ENV PORT $PORT
  12. EXPOSE $PORT 9229 9230
  13. COPY package.json /code/package.json
  14. COPY package-lock.json /code/package-lock.json
  15. RUN npm ci
  16. # check every 30s to ensure this service returns HTTP 200
  17. HEALTHCHECK --interval=30s \
  18. CMD node healthcheck.js
  19. # copy in our source code last, as it changes the most
  20. COPY . /code
  21. # if you want to use npm start instead, then use `docker run --init in production`
  22. # so that signals are passed properly. Note the code in index.js is needed to catch Docker signals
  23. # using node here is still more graceful stopping then npm with --init afaik
  24. # I still can't come up with a good production way to run with npm and graceful shutdown
  25. CMD [ "node", "src/index.js" ]
  26. FROM development as dev-envs
  27. RUN <<EOF
  28. apt-get update
  29. apt-get install -y --no-install-recommends git
  30. EOF
  31. RUN <<EOF
  32. useradd -s /bin/bash -m vscode
  33. groupadd docker
  34. usermod -aG docker vscode
  35. EOF
  36. # install Docker tools (cli, buildx, compose)
  37. COPY --from=gloursdocker/docker / /