Dockerfile 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. FROM debian:bookworm-slim
  2. MAINTAINER FmodeInc "support@fmode.cn"
  3. ARG NODE_VERSION
  4. ARG TERM
  5. ARG CMS_DOMAIN
  6. ARG CMS_DISABLE
  7. ARG NGINX_DISABLE
  8. ######################################## ENV LIST
  9. ENV NODE_VERSION $NODE_VERSION
  10. ENV TERM $TERM
  11. ENV CMS_DOMAIN $CMS_DOMAIN
  12. ENV CMS_DISABLE $CMS_DISABLE
  13. ENV NGINX_DISABLE $NGINX_DISABLE
  14. # ENV NODE_VERSION 18.15.0
  15. # ENV NODE_VERSION 16.3.0
  16. # ENV NODE_SERVER_PATH $nova_server_path
  17. # ENV NODE_CMS_PATH $nova_cms_path
  18. ######################################## Copy Latest Nova Cloud
  19. COPY ./opt/ /opt/
  20. COPY ./var/ /var/
  21. RUN ls /opt/ && chown -R root:root /opt/*
  22. ######################################## APT Repos to 163
  23. # RUN apt-get update
  24. ADD sources.list /etc/apt/
  25. RUN apt-get update
  26. ######################################## Nginx
  27. # curl http检测
  28. # procps 进程管理
  29. RUN apt-get install -y nginx procps && apt-get install -y nginx curl --no-install-recommends \
  30. && rm -rf /etc/nginx/sites-enabled/* && cp -rf /opt/nginx/* /etc/nginx/sites-enabled && service nginx restart
  31. ######################################## NODE
  32. RUN groupadd --gid 1000 node \
  33. && useradd --uid 1000 --gid node --shell /bin/bash --create-home node
  34. RUN apt-get update --fix-missing
  35. RUN ARCH= && dpkgArch="$(dpkg --print-architecture)" \
  36. && case "${dpkgArch##*-}" in \
  37. amd64) ARCH='x64';; \
  38. ppc64el) ARCH='ppc64le';; \
  39. s390x) ARCH='s390x';; \
  40. arm64) ARCH='arm64';; \
  41. armhf) ARCH='armv7l';; \
  42. i386) ARCH='x86';; \
  43. *) echo "unsupported architecture"; exit 1 ;; \
  44. esac \
  45. && set -ex \
  46. # libatomic1 for arm
  47. && apt-get update && apt-get install -y ca-certificates apt-utils curl wget gnupg dirmngr xz-utils libatomic1 --no-install-recommends \
  48. && rm -rf /var/lib/apt/lists/* \
  49. && curl -fsSLO --compressed "https://npmmirror.com/mirrors/node/v$NODE_VERSION/node-v$NODE_VERSION-linux-$ARCH.tar.xz" \
  50. && curl -fsSLO --compressed "https://npmmirror.com/mirrors/node/v$NODE_VERSION/SHASUMS256.txt.asc" \
  51. && tar -xJf "node-v$NODE_VERSION-linux-$ARCH.tar.xz" -C /usr/local --strip-components=1 --no-same-owner \
  52. && rm "node-v$NODE_VERSION-linux-$ARCH.tar.xz" \
  53. && ln -s /usr/local/bin/node /usr/local/bin/nodejs
  54. ######################################## PM2 && bytenode
  55. RUN npm config set registry https://registry.npmmirror.com/ && npm i -g pm2@5.1.1 bytenode@1.3.6
  56. # RUN npm i -g bytenode@1.3.6
  57. ######################################## Deploy Latest Nova Cloud
  58. RUN cd /opt/edu-textbook-server && pm2 start server.js \
  59. && sleep 5s \
  60. && pm2 startup && pm2 save
  61. ######################################## Verify All Depands is OK
  62. && node --version \
  63. && pm2 ls \
  64. && node --version \
  65. && npm --version \
  66. ######################################## Clean All Resources
  67. RUN apt-mark auto '.*' > /dev/null \
  68. && find /usr/local -type f -executable -exec ldd '{}' ';' \
  69. | awk '/=>/ { print $(NF-1) }' \
  70. | sort -u \
  71. | xargs -r dpkg-query --search \
  72. | cut -d: -f1 \
  73. | sort -u \
  74. | xargs -r apt-mark manual \
  75. && apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false \
  76. && rm -rf /var/log/* \
  77. && env
  78. # && rm -r /var/log/postgresql/* \
  79. # && rm -r /var/log/apt/* \
  80. # && rm -r /var/log/nginx/* \
  81. # COPY docker-entrypoint.sh /usr/local/bin/
  82. # DEFAULT WEB
  83. EXPOSE 80
  84. EXPOSE 61337
  85. # DEFAULT SSL
  86. EXPOSE 443
  87. ENTRYPOINT [ "node","/opt/edu-textbook-server/keepalive.js" ]