Dockerfile 3.6 KB

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