Dockerfile 3.5 KB

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