Dockerfile 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  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. # Download node version 8.11.1 that has fix included, node binary copied from Sandstorm
  45. # Description at https://releases.wekan.team/node.txt
  46. wget https://releases.wekan.team/node-${NODE_VERSION}-${ARCHITECTURE}.tar.gz && \
  47. echo "308d0caaef0a1da3e98d1a1615016aad9659b3caf31d0f09ced20cabedb8acbf node-v8.11.1-linux-x64.tar.gz" >> SHASUMS256.txt.asc && \
  48. \
  49. # Verify nodejs authenticity
  50. grep ${NODE_VERSION}-${ARCHITECTURE}.tar.gz SHASUMS256.txt.asc | shasum -a 256 -c - && \
  51. #export GNUPGHOME="$(mktemp -d)" && \
  52. #\
  53. # Try other key servers if ha.pool.sks-keyservers.net is unreachable
  54. # Code from https://github.com/chorrell/docker-node/commit/2b673e17547c34f17f24553db02beefbac98d23c
  55. # gpg keys listed at https://github.com/nodejs/node#release-team
  56. # and keys listed here from previous version of this Dockerfile
  57. #for key in \
  58. #9554F04D7259F04124DE6B476D5A82AC7E37093B \
  59. #94AE36675C464D64BAFA68DD7434390BDBE9B9C5 \
  60. #FD3A5288F042B6850C66B31F09FE44734EB7990E \
  61. #71DCFD284A79C3B38668286BC97EC7A07EDE3FC1 \
  62. #DD8F2338BAE7501E3DD5AC78C273792F7D83545D \
  63. #C4F0DFFF4E8C1A8236409D08E73BC641CC11F4C8 \
  64. #B9AE9905FFD7803F25714661B63B535A4C206CA9 \
  65. #; do \
  66. #gpg --keyserver ha.pool.sks-keyservers.net --recv-keys "$key" || \
  67. #gpg --keyserver pgp.mit.edu --recv-keys "$key" || \
  68. #gpg --keyserver keyserver.pgp.com --recv-keys "$key" ; \
  69. #done && \
  70. #gpg --verify SHASUMS256.txt.asc && \
  71. # Ignore socket files then delete files then delete directories
  72. #find "$GNUPGHOME" -type f | xargs rm -f && \
  73. #find "$GNUPGHOME" -type d | xargs rm -fR && \
  74. rm -f SHASUMS256.txt.asc && \
  75. \
  76. # Install Node
  77. tar xvzf node-${NODE_VERSION}-${ARCHITECTURE}.tar.gz && \
  78. rm node-${NODE_VERSION}-${ARCHITECTURE}.tar.gz && \
  79. mv node-${NODE_VERSION}-${ARCHITECTURE} /opt/nodejs && \
  80. ln -s /opt/nodejs/bin/node /usr/bin/node && \
  81. ln -s /opt/nodejs/bin/npm /usr/bin/npm && \
  82. \
  83. #DOES NOT WORK: paxctl fix for alpine linux: https://github.com/wekan/wekan/issues/1303
  84. #paxctl -mC `which node` && \
  85. \
  86. # Install Node dependencies
  87. npm install -g npm@${NPM_VERSION} && \
  88. npm install -g node-gyp && \
  89. npm install -g fibers@${FIBERS_VERSION} && \
  90. \
  91. # Change user to wekan and install meteor
  92. cd /home/wekan/ && \
  93. chown wekan:wekan --recursive /home/wekan && \
  94. curl https://install.meteor.com -o /home/wekan/install_meteor.sh && \
  95. sed -i "s|RELEASE=.*|RELEASE=${METEOR_RELEASE}\"\"|g" ./install_meteor.sh && \
  96. echo "Starting meteor ${METEOR_RELEASE} installation... \n" && \
  97. chown wekan:wekan /home/wekan/install_meteor.sh && \
  98. \
  99. # Check if opting for a release candidate instead of major release
  100. if [ "$USE_EDGE" = false ]; then \
  101. gosu wekan:wekan sh /home/wekan/install_meteor.sh; \
  102. else \
  103. gosu wekan:wekan git clone --recursive --depth 1 -b release/METEOR@${METEOR_EDGE} git://github.com/meteor/meteor.git /home/wekan/.meteor; \
  104. fi; \
  105. \
  106. # Get additional packages
  107. mkdir -p /home/wekan/app/packages && \
  108. chown wekan:wekan --recursive /home/wekan && \
  109. cd /home/wekan/app/packages && \
  110. gosu wekan:wekan git clone --depth 1 -b master git://github.com/wekan/flow-router.git kadira-flow-router && \
  111. gosu wekan:wekan git clone --depth 1 -b master git://github.com/meteor-useraccounts/core.git meteor-useraccounts-core && \
  112. sed -i 's/api\.versionsFrom/\/\/api.versionsFrom/' /home/wekan/app/packages/meteor-useraccounts-core/package.js && \
  113. cd /home/wekan/.meteor && \
  114. gosu wekan:wekan /home/wekan/.meteor/meteor -- help; \
  115. \
  116. # Build app
  117. cd /home/wekan/app && \
  118. gosu wekan:wekan /home/wekan/.meteor/meteor add standard-minifier-js && \
  119. gosu wekan:wekan /home/wekan/.meteor/meteor npm install && \
  120. gosu wekan:wekan /home/wekan/.meteor/meteor build --directory /home/wekan/app_build && \
  121. cp /home/wekan/app/fix-download-unicode/cfs_access-point.txt /home/wekan/app_build/bundle/programs/server/packages/cfs_access-point.js && \
  122. chown wekan:wekan /home/wekan/app_build/bundle/programs/server/packages/cfs_access-point.js && \
  123. #Removed binary version of bcrypt because of security vulnerability that is not fixed yet.
  124. #https://github.com/wekan/wekan/commit/4b2010213907c61b0e0482ab55abb06f6a668eac
  125. #https://github.com/wekan/wekan/commit/7eeabf14be3c63fae2226e561ef8a0c1390c8d3c
  126. #cd /home/wekan/app_build/bundle/programs/server/npm/node_modules/meteor/npm-bcrypt && \
  127. #gosu wekan:wekan rm -rf node_modules/bcrypt && \
  128. #gosu wekan:wekan npm install bcrypt && \
  129. cd /home/wekan/app_build/bundle/programs/server/ && \
  130. gosu wekan:wekan npm install && \
  131. #gosu wekan:wekan npm install bcrypt && \
  132. mv /home/wekan/app_build/bundle /build && \
  133. \
  134. # Cleanup
  135. apt-get remove --purge -y ${BUILD_DEPS} && \
  136. apt-get autoremove -y && \
  137. rm -R /var/lib/apt/lists/* && \
  138. rm -R /home/wekan/.meteor && \
  139. rm -R /home/wekan/app && \
  140. rm -R /home/wekan/app_build && \
  141. rm /home/wekan/install_meteor.sh
  142. ENV PORT=80
  143. EXPOSE $PORT
  144. CMD ["node", "/build/main.js"]