Dockerfile 3.7 KB

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