Dockerfile 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. # This is to build a container that demos the Mol* canvas app
  2. # Source material: https://nodejs.org/en/docs/guides/nodejs-docker-webapp/
  3. # Source material: https://derickbailey.com/2017/05/31/how-a-650mb-node-js-image-for-docker-uses-less-space-than-a-50mb-image/
  4. # Source material: https://hub.docker.com/_/node/
  5. ### Builder Stage (Multi-Stage Docker Build)
  6. # Use the slimed NodeJS source, yielding a space savings of 600MB (~66% of total)
  7. FROM node:alpine as builder
  8. ENV NODEROOT /usr/src/app/
  9. # Create app directory
  10. WORKDIR $NODEROOT
  11. # Install app dependencies
  12. # A wildcard is used to ensure the following are copied
  13. # package.json AND package-lock.json AND tslint.json AND tsconfig.json are copied where available (npm@5+)
  14. COPY *.json ./
  15. # Install all dependencies and copy results
  16. RUN npm install
  17. COPY . .
  18. # Build library and canvas application then copy results
  19. RUN npm run build
  20. RUN npm run build-canvas
  21. COPY . .
  22. ### Runtime Stage (Multi-Stage Docker Build)
  23. FROM httpd:2.4 as runtime
  24. ENV NODEROOT /usr/src/app
  25. ENV HTTPDROOT /usr/local/apache2/htdocs/
  26. ## Code must be placed into /usr/local/apache2/htdocs/
  27. WORKDIR $HTTPDROOT
  28. COPY --from=builder $NODEROOT/build/canvas/ .
  29. # Open ports for HTTP
  30. EXPOSE 80