Dockerfile 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271
  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. ARG WEBHOOKS_ATTRIBUTES
  20. ARG OAUTH2_ENABLED
  21. ARG OAUTH2_CLIENT_ID
  22. ARG OAUTH2_SECRET
  23. ARG OAUTH2_SERVER_URL
  24. ARG OAUTH2_AUTH_ENDPOINT
  25. ARG OAUTH2_USERINFO_ENDPOINT
  26. ARG OAUTH2_TOKEN_ENDPOINT
  27. ARG LDAP_ENABLE
  28. ARG LDAP_PORT
  29. ARG LDAP_HOST
  30. ARG LDAP_BASEDN
  31. ARG LDAP_LOGIN_FALLBACK
  32. ARG LDAP_RECONNECT
  33. ARG LDAP_TIMEOUT
  34. ARG LDAP_IDLE_TIMEOUT
  35. ARG LDAP_CONNECT_TIMEOUT
  36. ARG LDAP_AUTHENTIFICATION
  37. ARG LDAP_AUTHENTIFICATION_USERDN
  38. ARG LDAP_AUTHENTIFICATION_PASSWORD
  39. ARG LDAP_LOG_ENABLED
  40. ARG LDAP_BACKGROUND_SYNC
  41. ARG LDAP_BACKGROUND_SYNC_INTERVAL
  42. ARG LDAP_BACKGROUND_SYNC_KEEP_EXISTANT_USERS_UPDATED
  43. ARG LDAP_BACKGROUND_SYNC_IMPORT_NEW_USERS
  44. ARG LDAP_ENCRYPTION
  45. ARG LDAP_CA_CERT
  46. ARG LDAP_REJECT_UNAUTHORIZED
  47. ARG LDAP_USER_SEARCH_FILTER
  48. ARG LDAP_USER_SEARCH_SCOPE
  49. ARG LDAP_USER_SEARCH_FIELD
  50. ARG LDAP_SEARCH_PAGE_SIZE
  51. ARG LDAP_SEARCH_SIZE_LIMIT
  52. ARG LDAP_GROUP_FILTER_ENABLE
  53. ARG LDAP_GROUP_FILTER_OBJECTCLASS
  54. ARG LDAP_GROUP_FILTER_GROUP_ID_ATTRIBUTE
  55. ARG LDAP_GROUP_FILTER_GROUP_MEMBER_ATTRIBUTE
  56. ARG LDAP_GROUP_FILTER_GROUP_MEMBER_FORMAT
  57. ARG LDAP_GROUP_FILTER_GROUP_NAME
  58. ARG LDAP_UNIQUE_IDENTIFIER_FIELD
  59. ARG LDAP_UTF8_NAMES_SLUGIFY
  60. ARG LDAP_USERNAME_FIELD
  61. ARG LDAP_MERGE_EXISTING_USERS
  62. ARG LDAP_SYNC_USER_DATA
  63. ARG LDAP_SYNC_USER_DATA_FIELDMAP
  64. ARG LDAP_SYNC_GROUP_ROLES
  65. ARG LDAP_DEFAULT_DOMAIN
  66. # Set the environment variables (defaults where required)
  67. # DOES NOT WORK: paxctl fix for alpine linux: https://github.com/wekan/wekan/issues/1303
  68. # ENV BUILD_DEPS="paxctl"
  69. ENV BUILD_DEPS="apt-utils bsdtar gnupg gosu wget curl bzip2 build-essential python git ca-certificates gcc-7" \
  70. NODE_VERSION=v8.12.0 \
  71. METEOR_RELEASE=1.8.1-beta.0 \
  72. USE_EDGE=false \
  73. METEOR_EDGE=1.5-beta.17 \
  74. NPM_VERSION=latest \
  75. FIBERS_VERSION=2.0.0 \
  76. ARCHITECTURE=linux-x64 \
  77. SRC_PATH=./ \
  78. WITH_API=true \
  79. MATOMO_ADDRESS="" \
  80. MATOMO_SITE_ID="" \
  81. MATOMO_DO_NOT_TRACK=true \
  82. MATOMO_WITH_USERNAME=false \
  83. BROWSER_POLICY_ENABLED=true \
  84. TRUSTED_URL="" \
  85. WEBHOOKS_ATTRIBUTES="" \
  86. OAUTH2_ENABLED=false \
  87. OAUTH2_CLIENT_ID="" \
  88. OAUTH2_SECRET="" \
  89. OAUTH2_SERVER_URL="" \
  90. OAUTH2_AUTH_ENDPOINT="" \
  91. OAUTH2_USERINFO_ENDPOINT="" \
  92. OAUTH2_TOKEN_ENDPOINT="" \
  93. LDAP_ENABLE=false \
  94. LDAP_PORT=389 \
  95. LDAP_HOST="" \
  96. LDAP_BASEDN="" \
  97. LDAP_LOGIN_FALLBACK=false \
  98. LDAP_RECONNECT=true \
  99. LDAP_TIMEOUT=10000 \
  100. LDAP_IDLE_TIMEOUT=10000 \
  101. LDAP_CONNECT_TIMEOUT=10000 \
  102. LDAP_AUTHENTIFICATION=false \
  103. LDAP_AUTHENTIFICATION_USERDN="" \
  104. LDAP_AUTHENTIFICATION_PASSWORD="" \
  105. LDAP_LOG_ENABLED=false \
  106. LDAP_BACKGROUND_SYNC=false \
  107. LDAP_BACKGROUND_SYNC_INTERVAL=100 \
  108. LDAP_BACKGROUND_SYNC_KEEP_EXISTANT_USERS_UPDATED=false \
  109. LDAP_BACKGROUND_SYNC_IMPORT_NEW_USERS=false \
  110. LDAP_ENCRYPTION=false \
  111. LDAP_CA_CERT="" \
  112. LDAP_REJECT_UNAUTHORIZED=false \
  113. LDAP_USER_SEARCH_FILTER="" \
  114. LDAP_USER_SEARCH_SCOPE="" \
  115. LDAP_USER_SEARCH_FIELD="" \
  116. LDAP_SEARCH_PAGE_SIZE=0 \
  117. LDAP_SEARCH_SIZE_LIMIT=0 \
  118. LDAP_GROUP_FILTER_ENABLE=false \
  119. LDAP_GROUP_FILTER_OBJECTCLASS="" \
  120. LDAP_GROUP_FILTER_GROUP_ID_ATTRIBUTE="" \
  121. LDAP_GROUP_FILTER_GROUP_MEMBER_ATTRIBUTE="" \
  122. LDAP_GROUP_FILTER_GROUP_MEMBER_FORMAT="" \
  123. LDAP_GROUP_FILTER_GROUP_NAME="" \
  124. LDAP_UNIQUE_IDENTIFIER_FIELD="" \
  125. LDAP_UTF8_NAMES_SLUGIFY=true \
  126. LDAP_USERNAME_FIELD="" \
  127. LDAP_MERGE_EXISTING_USERS=false \
  128. LDAP_SYNC_USER_DATA=false \
  129. LDAP_SYNC_USER_DATA_FIELDMAP="" \
  130. LDAP_SYNC_GROUP_ROLES="" \
  131. LDAP_DEFAULT_DOMAIN="" \
  132. # Copy the app to the image
  133. COPY ${SRC_PATH} /home/wekan/app
  134. RUN \
  135. # Add non-root user wekan
  136. useradd --user-group --system --home-dir /home/wekan wekan && \
  137. \
  138. # OS dependencies
  139. apt-get update -y && apt-get install -y --no-install-recommends ${BUILD_DEPS} && \
  140. \
  141. # Meteor installer doesn't work with the default tar binary, so using bsdtar while installing.
  142. # https://github.com/coreos/bugs/issues/1095#issuecomment-350574389
  143. cp $(which tar) $(which tar)~ && \
  144. ln -sf $(which bsdtar) $(which tar) && \
  145. \
  146. # Download nodejs
  147. wget https://nodejs.org/dist/${NODE_VERSION}/node-${NODE_VERSION}-${ARCHITECTURE}.tar.gz && \
  148. wget https://nodejs.org/dist/${NODE_VERSION}/SHASUMS256.txt.asc && \
  149. #---------------------------------------------------------------------------------------------
  150. # Node Fibers 100% CPU usage issue:
  151. # https://github.com/wekan/wekan-mongodb/issues/2#issuecomment-381453161
  152. # https://github.com/meteor/meteor/issues/9796#issuecomment-381676326
  153. # https://github.com/sandstorm-io/sandstorm/blob/0f1fec013fe7208ed0fd97eb88b31b77e3c61f42/shell/server/00-startup.js#L99-L129
  154. # Also see beginning of wekan/server/authentication.js
  155. # import Fiber from "fibers";
  156. # Fiber.poolSize = 1e9;
  157. # OLD: Download node version 8.12.0 prerelease that has fix included, => Official 8.12.0 has been released
  158. # Description at https://releases.wekan.team/node.txt
  159. #wget https://releases.wekan.team/node-${NODE_VERSION}-${ARCHITECTURE}.tar.gz && \
  160. #echo "1ed54adb8497ad8967075a0b5d03dd5d0a502be43d4a4d84e5af489c613d7795 node-v8.12.0-linux-x64.tar.gz" >> SHASUMS256.txt.asc && \
  161. \
  162. # Verify nodejs authenticity
  163. grep ${NODE_VERSION}-${ARCHITECTURE}.tar.gz SHASUMS256.txt.asc | shasum -a 256 -c - && \
  164. #export GNUPGHOME="$(mktemp -d)" && \
  165. #\
  166. # Try other key servers if ha.pool.sks-keyservers.net is unreachable
  167. # Code from https://github.com/chorrell/docker-node/commit/2b673e17547c34f17f24553db02beefbac98d23c
  168. # gpg keys listed at https://github.com/nodejs/node#release-team
  169. # and keys listed here from previous version of this Dockerfile
  170. #for key in \
  171. #9554F04D7259F04124DE6B476D5A82AC7E37093B \
  172. #94AE36675C464D64BAFA68DD7434390BDBE9B9C5 \
  173. #FD3A5288F042B6850C66B31F09FE44734EB7990E \
  174. #71DCFD284A79C3B38668286BC97EC7A07EDE3FC1 \
  175. #DD8F2338BAE7501E3DD5AC78C273792F7D83545D \
  176. #C4F0DFFF4E8C1A8236409D08E73BC641CC11F4C8 \
  177. #B9AE9905FFD7803F25714661B63B535A4C206CA9 \
  178. #; do \
  179. #gpg --keyserver ha.pool.sks-keyservers.net --recv-keys "$key" || \
  180. #gpg --keyserver pgp.mit.edu --recv-keys "$key" || \
  181. #gpg --keyserver keyserver.pgp.com --recv-keys "$key" ; \
  182. #done && \
  183. #gpg --verify SHASUMS256.txt.asc && \
  184. # Ignore socket files then delete files then delete directories
  185. #find "$GNUPGHOME" -type f | xargs rm -f && \
  186. #find "$GNUPGHOME" -type d | xargs rm -fR && \
  187. rm -f SHASUMS256.txt.asc && \
  188. \
  189. # Install Node
  190. tar xvzf node-${NODE_VERSION}-${ARCHITECTURE}.tar.gz && \
  191. rm node-${NODE_VERSION}-${ARCHITECTURE}.tar.gz && \
  192. mv node-${NODE_VERSION}-${ARCHITECTURE} /opt/nodejs && \
  193. ln -s /opt/nodejs/bin/node /usr/bin/node && \
  194. ln -s /opt/nodejs/bin/npm /usr/bin/npm && \
  195. \
  196. #DOES NOT WORK: paxctl fix for alpine linux: https://github.com/wekan/wekan/issues/1303
  197. #paxctl -mC `which node` && \
  198. \
  199. # Install Node dependencies
  200. npm install -g npm@${NPM_VERSION} && \
  201. npm install -g node-gyp && \
  202. npm install -g fibers@${FIBERS_VERSION} && \
  203. \
  204. # Change user to wekan and install meteor
  205. cd /home/wekan/ && \
  206. chown wekan:wekan --recursive /home/wekan && \
  207. curl "https://install.meteor.com/?release=${METEOR_RELEASE}" -o /home/wekan/install_meteor.sh && \
  208. # OLD: sed -i "s|RELEASE=.*|RELEASE=${METEOR_RELEASE}\"\"|g" ./install_meteor.sh && \
  209. # Install Meteor forcing its progress
  210. sed -i 's/VERBOSITY="--silent"/VERBOSITY="--progress-bar"/' ./install_meteor.sh && \
  211. echo "Starting meteor ${METEOR_RELEASE} installation... \n" && \
  212. chown wekan:wekan /home/wekan/install_meteor.sh && \
  213. \
  214. # Check if opting for a release candidate instead of major release
  215. if [ "$USE_EDGE" = false ]; then \
  216. gosu wekan:wekan sh /home/wekan/install_meteor.sh; \
  217. else \
  218. gosu wekan:wekan git clone --recursive --depth 1 -b release/METEOR@${METEOR_EDGE} git://github.com/meteor/meteor.git /home/wekan/.meteor; \
  219. fi; \
  220. \
  221. # Get additional packages
  222. mkdir -p /home/wekan/app/packages && \
  223. chown wekan:wekan --recursive /home/wekan && \
  224. cd /home/wekan/app/packages && \
  225. gosu wekan:wekan git clone --depth 1 -b master git://github.com/wekan/flow-router.git kadira-flow-router && \
  226. gosu wekan:wekan git clone --depth 1 -b master git://github.com/meteor-useraccounts/core.git meteor-useraccounts-core && \
  227. gosu wekan:wekan git clone --depth 1 -b master git://github.com/wekan/meteor-accounts-cas.git && \
  228. gosu wekan:wekan git clone --depth 1 -b master git://github.com/wekan/wekan-ldap.git && \
  229. sed -i 's/api\.versionsFrom/\/\/api.versionsFrom/' /home/wekan/app/packages/meteor-useraccounts-core/package.js && \
  230. cd /home/wekan/.meteor && \
  231. gosu wekan:wekan /home/wekan/.meteor/meteor -- help; \
  232. \
  233. # Build app
  234. cd /home/wekan/app && \
  235. gosu wekan:wekan /home/wekan/.meteor/meteor add standard-minifier-js && \
  236. gosu wekan:wekan /home/wekan/.meteor/meteor npm install && \
  237. gosu wekan:wekan /home/wekan/.meteor/meteor build --directory /home/wekan/app_build && \
  238. cp /home/wekan/app/fix-download-unicode/cfs_access-point.txt /home/wekan/app_build/bundle/programs/server/packages/cfs_access-point.js && \
  239. chown wekan:wekan /home/wekan/app_build/bundle/programs/server/packages/cfs_access-point.js && \
  240. #Removed binary version of bcrypt because of security vulnerability that is not fixed yet.
  241. #https://github.com/wekan/wekan/commit/4b2010213907c61b0e0482ab55abb06f6a668eac
  242. #https://github.com/wekan/wekan/commit/7eeabf14be3c63fae2226e561ef8a0c1390c8d3c
  243. #cd /home/wekan/app_build/bundle/programs/server/npm/node_modules/meteor/npm-bcrypt && \
  244. #gosu wekan:wekan rm -rf node_modules/bcrypt && \
  245. #gosu wekan:wekan npm install bcrypt && \
  246. cd /home/wekan/app_build/bundle/programs/server/ && \
  247. gosu wekan:wekan npm install && \
  248. #gosu wekan:wekan npm install bcrypt && \
  249. mv /home/wekan/app_build/bundle /build && \
  250. \
  251. # Put back the original tar
  252. mv $(which tar)~ $(which tar) && \
  253. \
  254. # Cleanup
  255. apt-get remove --purge -y ${BUILD_DEPS} && \
  256. apt-get autoremove -y && \
  257. rm -R /var/lib/apt/lists/* && \
  258. rm -R /home/wekan/.meteor && \
  259. rm -R /home/wekan/app && \
  260. rm -R /home/wekan/app_build && \
  261. rm /home/wekan/install_meteor.sh
  262. ENV PORT=8080
  263. EXPOSE $PORT
  264. USER wekan
  265. CMD ["node", "/build/main.js"]