Dockerfile 7.0 KB

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