Dockerfile 7.2 KB

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