暂无描述

Dockerfile 2.3KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. # Build environment
  2. FROM node:23 AS builder
  3. ENV NODE_OPTIONS="--max-old-space-size=4096"
  4. RUN mkdir /usr/src/app
  5. WORKDIR /usr/src/app
  6. ENV PATH="/usr/src/app/node_modules/.bin:$PATH"
  7. COPY package.json /usr/src/app/package.json
  8. COPY package-lock.json /usr/src/app/package-lock.json
  9. RUN npm config set fetch-retries 3 # Number of retry attempts (default is 2)
  10. RUN npm config set fetch-retry-mintimeout 5000 # Minimum wait time before retrying (in ms, default is 10000)
  11. RUN npm config set fetch-retry-maxtimeout 60000 # Maximum wait time before retrying (in ms, default is 60000)
  12. RUN npm config set fetch-timeout 60000 # Overall fetch timeout (in ms, default is 300000)
  13. RUN npm install --legacy-peer-deps
  14. # copy only required files to not trigger rebuilding every time
  15. COPY ./certs /usr/src/app/certs/
  16. COPY ./public /usr/src/app/public/
  17. COPY ./src /usr/src/app/src/
  18. COPY ./*.sh /usr/src/app/
  19. COPY ./*.json /usr/src/app/
  20. COPY ./index.html /usr/src/app/index.html
  21. COPY ./vite.config.js /usr/src/app/vite.config.js
  22. RUN npm run build
  23. # Production environment
  24. FROM nginx:1.29.3
  25. RUN mkdir -p /usr/share/nginx/html/build
  26. RUN mkdir -p /usr/share/nginx/html/css
  27. RUN mkdir -p /usr/share/nginx/html/js
  28. RUN mkdir -p /usr/share/nginx/html/img
  29. # Localhost certificate challenge: Y#XwrJ#DoZGz2w6x
  30. # Cert challenge doesn't matter to be here or not, as ALL production setups should be using their own certificates + reverse proxy: https://shuffler.io/docs/configuration#using-the-nginx-reverse-proxy-for-tls/ssl
  31. COPY --from=builder /usr/src/app/build /usr/share/nginx/html
  32. COPY --from=builder /usr/src/app/certs/fullchain.pem /etc/nginx/fullchain.cert.pem
  33. COPY --from=builder /usr/src/app/certs/privkey.pem /etc/nginx/privkey.pem
  34. # install CONFD
  35. RUN apt-get update && apt-get install -y curl && apt-get clean
  36. COPY ./confd/templates/nginx.conf /etc/nginx/nginx.conf.tmpl
  37. ## OLD CONFD THINGS (not compatible with arm)
  38. #ENV CONFD_VERSION 0.16.0
  39. #RUN curl -sSL https://github.com/kelseyhightower/confd/releases/download/v${CONFD_VERSION}/confd-${CONFD_VERSION}-linux-amd64 -o /usr/local/bin/confd && \
  40. # chmod +x /usr/local/bin/confd
  41. #COPY ./confd /etc/confd
  42. # rewrite command & entrypoint with ours
  43. COPY ./entrypoint.sh /
  44. ENV BACKEND_HOSTNAME="shuffle-backend"
  45. ENTRYPOINT [ "/entrypoint.sh" ]
  46. CMD ["nginx", "-g", "daemon off;"]
  47. EXPOSE 80
  48. EXPOSE 443