Dockerfile 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. FROM debian:buster-slim
  2. MAINTAINER wekan
  3. # Declare Arguments
  4. ARG NODE_VERSION
  5. ARG METEOR_RELEASE
  6. ARG METEOR_EDGE
  7. ARG USE_EDGE
  8. ARG NPM_VERSION
  9. ARG FIBERS_VERSION
  10. ARG ARCHITECTURE
  11. ARG SRC_PATH
  12. # Set the environment variables (defaults where required)
  13. # paxctl fix for alpine linux: https://github.com/wekan/wekan/issues/1303
  14. ENV BUILD_DEPS="apt-utils gnupg gosu wget curl bzip2 build-essential python git ca-certificates gcc-7 paxctl"
  15. ENV NODE_VERSION ${NODE_VERSION:-v8.11.1}
  16. ENV METEOR_RELEASE ${METEOR_RELEASE:-1.6.0.1}
  17. ENV USE_EDGE ${USE_EDGE:-false}
  18. ENV METEOR_EDGE ${METEOR_EDGE:-1.5-beta.17}
  19. ENV NPM_VERSION ${NPM_VERSION:-5.5.1}
  20. ENV FIBERS_VERSION ${FIBERS_VERSION:-2.0.0}
  21. ENV ARCHITECTURE ${ARCHITECTURE:-linux-x64}
  22. ENV SRC_PATH ${SRC_PATH:-./}
  23. # Copy the app to the image
  24. COPY ${SRC_PATH} /home/wekan/app
  25. RUN \
  26. # Add non-root user wekan
  27. useradd --user-group --system --home-dir /home/wekan wekan && \
  28. \
  29. # OS dependencies
  30. apt-get update -y && apt-get install -y --no-install-recommends ${BUILD_DEPS} && \
  31. \
  32. # Download nodejs
  33. wget https://nodejs.org/dist/${NODE_VERSION}/node-${NODE_VERSION}-${ARCHITECTURE}.tar.gz && \
  34. wget https://nodejs.org/dist/${NODE_VERSION}/SHASUMS256.txt.asc && \
  35. \
  36. # Verify nodejs authenticity
  37. grep ${NODE_VERSION}-${ARCHITECTURE}.tar.gz SHASUMS256.txt.asc | shasum -a 256 -c - && \
  38. export GNUPGHOME="$(mktemp -d)" && \
  39. \
  40. # Try other key servers if ha.pool.sks-keyservers.net is unreachable
  41. # Code from https://github.com/chorrell/docker-node/commit/2b673e17547c34f17f24553db02beefbac98d23c
  42. # gpg keys listed at https://github.com/nodejs/node#release-team
  43. # and keys listed here from previous version of this Dockerfile
  44. for key in \
  45. 9554F04D7259F04124DE6B476D5A82AC7E37093B \
  46. 94AE36675C464D64BAFA68DD7434390BDBE9B9C5 \
  47. FD3A5288F042B6850C66B31F09FE44734EB7990E \
  48. 71DCFD284A79C3B38668286BC97EC7A07EDE3FC1 \
  49. DD8F2338BAE7501E3DD5AC78C273792F7D83545D \
  50. C4F0DFFF4E8C1A8236409D08E73BC641CC11F4C8 \
  51. B9AE9905FFD7803F25714661B63B535A4C206CA9 \
  52. ; do \
  53. gpg --keyserver ha.pool.sks-keyservers.net --recv-keys "$key" || \
  54. gpg --keyserver pgp.mit.edu --recv-keys "$key" || \
  55. gpg --keyserver keyserver.pgp.com --recv-keys "$key" ; \
  56. done && \
  57. gpg --verify SHASUMS256.txt.asc && \
  58. # Ignore socket files then delete files then delete directories
  59. find "$GNUPGHOME" -type f | xargs rm -f && \
  60. find "$GNUPGHOME" -type d | xargs rm -fR && \
  61. rm -f SHASUMS256.txt.asc && \
  62. \
  63. # Install Node
  64. tar xvzf node-${NODE_VERSION}-${ARCHITECTURE}.tar.gz && \
  65. rm node-${NODE_VERSION}-${ARCHITECTURE}.tar.gz && \
  66. mv node-${NODE_VERSION}-${ARCHITECTURE} /opt/nodejs && \
  67. \
  68. # Remove original node, use Fibers 100% CPU usage issue patched node
  69. rm /opt/nodejs/bin/node && \
  70. # Node Fibers 100% CPU usage issue:
  71. # https://github.com/wekan/wekan-mongodb/issues/2#issuecomment-381453161
  72. # https://github.com/meteor/meteor/issues/9796#issuecomment-381676326
  73. # https://github.com/sandstorm-io/sandstorm/blob/0f1fec013fe7208ed0fd97eb88b31b77e3c61f42/shell/server/00-startup.js#L99-L129
  74. # Also see beginning of wekan/server/authentication.js
  75. # import Fiber from "fibers";
  76. # Fiber.poolSize = 1e9;
  77. # Download node version 8.11.1 that has fix included, node binary copied from Sandstorm
  78. # Description at https://releases.wekan.team/node.txt
  79. # SHA256SUM: 18c99d5e79e2fe91e75157a31be30e5420787213684d4048eb91e602e092725d
  80. echo "18c99d5e79e2fe91e75157a31be30e5420787213684d4048eb91e602e092725d node" >> node-SHASUMS256.txt.asc && \
  81. wget https://releases.wekan.team/node && \
  82. # Verify Fibers patched node authenticity
  83. echo "Fibers patched node authenticity:" && \
  84. grep node node-SHASUMS256.txt.asc | shasum -a 256 -c - && \
  85. rm -f node-SHASUMS256.txt.asc && \
  86. chmod +x node && \
  87. mv node /opt/nodejs/bin/ && \
  88. \
  89. # Create symlinks
  90. ln -s /opt/nodejs/bin/node /usr/bin/node && \
  91. ln -s /opt/nodejs/bin/npm /usr/bin/npm && \
  92. \
  93. # paxctl fix for alpine linux: https://github.com/wekan/wekan/issues/1303
  94. paxctl -mC `which node` && \
  95. \
  96. # Install Node dependencies
  97. npm install -g npm@${NPM_VERSION} && \
  98. npm install -g node-gyp && \
  99. npm install -g fibers@${FIBERS_VERSION} && \
  100. \
  101. # Change user to wekan and install meteor
  102. cd /home/wekan/ && \
  103. chown wekan:wekan --recursive /home/wekan && \
  104. curl https://install.meteor.com -o /home/wekan/install_meteor.sh && \
  105. sed -i "s|RELEASE=.*|RELEASE=${METEOR_RELEASE}\"\"|g" ./install_meteor.sh && \
  106. echo "Starting meteor ${METEOR_RELEASE} installation... \n" && \
  107. chown wekan:wekan /home/wekan/install_meteor.sh && \
  108. \
  109. # Check if opting for a release candidate instead of major release
  110. if [ "$USE_EDGE" = false ]; then \
  111. gosu wekan:wekan sh /home/wekan/install_meteor.sh; \
  112. else \
  113. gosu wekan:wekan git clone --recursive --depth 1 -b release/METEOR@${METEOR_EDGE} git://github.com/meteor/meteor.git /home/wekan/.meteor; \
  114. fi; \
  115. \
  116. # Get additional packages
  117. mkdir -p /home/wekan/app/packages && \
  118. chown wekan:wekan --recursive /home/wekan && \
  119. cd /home/wekan/app/packages && \
  120. gosu wekan:wekan git clone --depth 1 -b master git://github.com/wekan/flow-router.git kadira-flow-router && \
  121. gosu wekan:wekan git clone --depth 1 -b master git://github.com/meteor-useraccounts/core.git meteor-useraccounts-core && \
  122. sed -i 's/api\.versionsFrom/\/\/api.versionsFrom/' /home/wekan/app/packages/meteor-useraccounts-core/package.js && \
  123. cd /home/wekan/.meteor && \
  124. gosu wekan:wekan /home/wekan/.meteor/meteor -- help; \
  125. \
  126. # Build app
  127. cd /home/wekan/app && \
  128. gosu wekan:wekan /home/wekan/.meteor/meteor add standard-minifier-js && \
  129. gosu wekan:wekan /home/wekan/.meteor/meteor npm install && \
  130. gosu wekan:wekan /home/wekan/.meteor/meteor build --directory /home/wekan/app_build && \
  131. cp /home/wekan/app/fix-download-unicode/cfs_access-point.txt /home/wekan/app_build/bundle/programs/server/packages/cfs_access-point.js && \
  132. chown wekan:wekan /home/wekan/app_build/bundle/programs/server/packages/cfs_access-point.js && \
  133. cd /home/wekan/app_build/bundle/programs/server/npm/node_modules/meteor/npm-bcrypt && \
  134. gosu wekan:wekan rm -rf node_modules/bcrypt && \
  135. gosu wekan:wekan npm install bcrypt && \
  136. cd /home/wekan/app_build/bundle/programs/server/ && \
  137. gosu wekan:wekan npm install && \
  138. gosu wekan:wekan npm install bcrypt && \
  139. mv /home/wekan/app_build/bundle /build && \
  140. \
  141. # Cleanup
  142. apt-get remove --purge -y ${BUILD_DEPS} && \
  143. apt-get autoremove -y && \
  144. rm -R /var/lib/apt/lists/* && \
  145. rm -R /home/wekan/.meteor && \
  146. rm -R /home/wekan/app && \
  147. rm -R /home/wekan/app_build && \
  148. rm /home/wekan/install_meteor.sh
  149. ENV PORT=80
  150. EXPOSE $PORT
  151. CMD ["node", "/build/main.js"]