Dockerfile 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300
  1. FROM ubuntu:rolling
  2. LABEL maintainer="wekan"
  3. # Set the environment variables (defaults where required)
  4. # DOES NOT WORK: paxctl fix for alpine linux: https://github.com/wekan/wekan/issues/1303
  5. # ENV BUILD_DEPS="paxctl"
  6. ARG DEBIAN_FRONTEND=noninteractive
  7. ENV BUILD_DEPS="apt-utils libarchive-tools gnupg gosu wget curl bzip2 g++ build-essential git ca-certificates python3" \
  8. DEBUG=false \
  9. NODE_VERSION=v12.18.3 \
  10. METEOR_RELEASE=1.10.2 \
  11. USE_EDGE=false \
  12. METEOR_EDGE=1.5-beta.17 \
  13. NPM_VERSION=latest \
  14. FIBERS_VERSION=4.0.1 \
  15. ARCHITECTURE=linux-x64 \
  16. SRC_PATH=./ \
  17. WITH_API=true \
  18. ACCOUNTS_LOCKOUT_KNOWN_USERS_FAILURES_BEFORE=3 \
  19. ACCOUNTS_LOCKOUT_KNOWN_USERS_PERIOD=60 \
  20. ACCOUNTS_LOCKOUT_KNOWN_USERS_FAILURE_WINDOW=15 \
  21. ACCOUNTS_LOCKOUT_UNKNOWN_USERS_FAILURES_BERORE=3 \
  22. ACCOUNTS_LOCKOUT_UNKNOWN_USERS_LOCKOUT_PERIOD=60 \
  23. ACCOUNTS_LOCKOUT_UNKNOWN_USERS_FAILURE_WINDOW=15 \
  24. RICHER_CARD_COMMENT_EDITOR=false \
  25. CARD_OPENED_WEBHOOK_ENABLED=false \
  26. ATTACHMENTS_STORE_PATH="" \
  27. MAX_IMAGE_PIXEL="" \
  28. IMAGE_COMPRESS_RATIO="" \
  29. NOTIFICATION_TRAY_AFTER_READ_DAYS_BEFORE_REMOVE="" \
  30. BIGEVENTS_PATTERN=NONE \
  31. NOTIFY_DUE_DAYS_BEFORE_AND_AFTER="" \
  32. NOTIFY_DUE_AT_HOUR_OF_DAY="" \
  33. EMAIL_NOTIFICATION_TIMEOUT=30000 \
  34. MATOMO_ADDRESS="" \
  35. MATOMO_SITE_ID="" \
  36. MATOMO_DO_NOT_TRACK=true \
  37. MATOMO_WITH_USERNAME=false \
  38. BROWSER_POLICY_ENABLED=true \
  39. TRUSTED_URL="" \
  40. WEBHOOKS_ATTRIBUTES="" \
  41. OAUTH2_ENABLED=false \
  42. OAUTH2_LOGIN_STYLE=redirect \
  43. OAUTH2_CLIENT_ID="" \
  44. OAUTH2_SECRET="" \
  45. OAUTH2_SERVER_URL="" \
  46. OAUTH2_AUTH_ENDPOINT="" \
  47. OAUTH2_USERINFO_ENDPOINT="" \
  48. OAUTH2_TOKEN_ENDPOINT="" \
  49. OAUTH2_ID_MAP="" \
  50. OAUTH2_USERNAME_MAP="" \
  51. OAUTH2_FULLNAME_MAP="" \
  52. OAUTH2_ID_TOKEN_WHITELIST_FIELDS="" \
  53. OAUTH2_REQUEST_PERMISSIONS='openid profile email' \
  54. OAUTH2_EMAIL_MAP="" \
  55. LDAP_ENABLE=false \
  56. LDAP_PORT=389 \
  57. LDAP_HOST="" \
  58. LDAP_BASEDN="" \
  59. LDAP_LOGIN_FALLBACK=false \
  60. LDAP_RECONNECT=true \
  61. LDAP_TIMEOUT=10000 \
  62. LDAP_IDLE_TIMEOUT=10000 \
  63. LDAP_CONNECT_TIMEOUT=10000 \
  64. LDAP_AUTHENTIFICATION=false \
  65. LDAP_AUTHENTIFICATION_USERDN="" \
  66. LDAP_AUTHENTIFICATION_PASSWORD="" \
  67. LDAP_LOG_ENABLED=false \
  68. LDAP_BACKGROUND_SYNC=false \
  69. LDAP_BACKGROUND_SYNC_INTERVAL="" \
  70. LDAP_BACKGROUND_SYNC_KEEP_EXISTANT_USERS_UPDATED=false \
  71. LDAP_BACKGROUND_SYNC_IMPORT_NEW_USERS=false \
  72. LDAP_ENCRYPTION=false \
  73. LDAP_CA_CERT="" \
  74. LDAP_REJECT_UNAUTHORIZED=false \
  75. LDAP_USER_AUTHENTICATION=false \
  76. LDAP_USER_AUTHENTICATION_FIELD=uid \
  77. LDAP_USER_SEARCH_FILTER="" \
  78. LDAP_USER_SEARCH_SCOPE="" \
  79. LDAP_USER_SEARCH_FIELD="" \
  80. LDAP_SEARCH_PAGE_SIZE=0 \
  81. LDAP_SEARCH_SIZE_LIMIT=0 \
  82. LDAP_GROUP_FILTER_ENABLE=false \
  83. LDAP_GROUP_FILTER_OBJECTCLASS="" \
  84. LDAP_GROUP_FILTER_GROUP_ID_ATTRIBUTE="" \
  85. LDAP_GROUP_FILTER_GROUP_MEMBER_ATTRIBUTE="" \
  86. LDAP_GROUP_FILTER_GROUP_MEMBER_FORMAT="" \
  87. LDAP_GROUP_FILTER_GROUP_NAME="" \
  88. LDAP_UNIQUE_IDENTIFIER_FIELD="" \
  89. LDAP_UTF8_NAMES_SLUGIFY=true \
  90. LDAP_USERNAME_FIELD="" \
  91. LDAP_FULLNAME_FIELD="" \
  92. LDAP_MERGE_EXISTING_USERS=false \
  93. LDAP_EMAIL_FIELD="" \
  94. LDAP_EMAIL_MATCH_ENABLE=false \
  95. LDAP_EMAIL_MATCH_REQUIRE=false \
  96. LDAP_EMAIL_MATCH_VERIFIED=false \
  97. LDAP_SYNC_USER_DATA=false \
  98. LDAP_SYNC_USER_DATA_FIELDMAP="" \
  99. LDAP_SYNC_GROUP_ROLES="" \
  100. LDAP_DEFAULT_DOMAIN="" \
  101. LDAP_SYNC_ADMIN_STATUS="" \
  102. LDAP_SYNC_ADMIN_GROUPS="" \
  103. HEADER_LOGIN_ID="" \
  104. HEADER_LOGIN_FIRSTNAME="" \
  105. HEADER_LOGIN_LASTNAME="" \
  106. HEADER_LOGIN_EMAIL="" \
  107. LOGOUT_WITH_TIMER=false \
  108. LOGOUT_IN="" \
  109. LOGOUT_ON_HOURS="" \
  110. LOGOUT_ON_MINUTES="" \
  111. CORS="" \
  112. CORS_ALLOW_HEADERS="" \
  113. CORS_EXPOSE_HEADERS="" \
  114. DEFAULT_AUTHENTICATION_METHOD="" \
  115. SCROLLINERTIA="0" \
  116. SCROLLAMOUNT="auto" \
  117. SCROLLDELTAFACTOR="auto" \
  118. PASSWORD_LOGIN_ENABLED=true
  119. # Copy the app to the image
  120. COPY ${SRC_PATH} /home/wekan/app
  121. RUN \
  122. set -o xtrace && \
  123. # Add non-root user wekan
  124. useradd --user-group --system --home-dir /home/wekan wekan && \
  125. \
  126. # OS dependencies
  127. apt-get update -y && apt-get install -y --no-install-recommends ${BUILD_DEPS} && \
  128. #pip3 install -U pip setuptools wheel && \
  129. \
  130. # Meteor installer doesn't work with the default tar binary, so using bsdtar while installing.
  131. # https://github.com/coreos/bugs/issues/1095#issuecomment-350574389
  132. cp $(which tar) $(which tar)~ && \
  133. ln -sf $(which bsdtar) $(which tar) && \
  134. \
  135. # Download nodejs
  136. wget https://nodejs.org/dist/${NODE_VERSION}/node-${NODE_VERSION}-${ARCHITECTURE}.tar.gz && \
  137. wget https://nodejs.org/dist/${NODE_VERSION}/SHASUMS256.txt.asc && \
  138. #---------------------------------------------------------------------------------------------
  139. # Node Fibers 100% CPU usage issue:
  140. # https://github.com/wekan/wekan-mongodb/issues/2#issuecomment-381453161
  141. # https://github.com/meteor/meteor/issues/9796#issuecomment-381676326
  142. # https://github.com/sandstorm-io/sandstorm/blob/0f1fec013fe7208ed0fd97eb88b31b77e3c61f42/shell/server/00-startup.js#L99-L129
  143. # Also see beginning of wekan/server/authentication.js
  144. # import Fiber from "fibers";
  145. # Fiber.poolSize = 1e9;
  146. # OLD: Download node version 8.12.0 prerelease that has fix included, => Official 8.12.0 has been released
  147. # Description at https://releases.wekan.team/node.txt
  148. #wget https://releases.wekan.team/node-${NODE_VERSION}-${ARCHITECTURE}.tar.gz && \
  149. #echo "1ed54adb8497ad8967075a0b5d03dd5d0a502be43d4a4d84e5af489c613d7795 node-v8.12.0-linux-x64.tar.gz" >> SHASUMS256.txt.asc && \
  150. \
  151. # Verify nodejs authenticity
  152. grep ${NODE_VERSION}-${ARCHITECTURE}.tar.gz SHASUMS256.txt.asc | shasum -a 256 -c - && \
  153. #export GNUPGHOME="$(mktemp -d)" && \
  154. #\
  155. # Try other key servers if ha.pool.sks-keyservers.net is unreachable
  156. # Code from https://github.com/chorrell/docker-node/commit/2b673e17547c34f17f24553db02beefbac98d23c
  157. # gpg keys listed at https://github.com/nodejs/node#release-team
  158. # and keys listed here from previous version of this Dockerfile
  159. #for key in \
  160. #9554F04D7259F04124DE6B476D5A82AC7E37093B \
  161. #94AE36675C464D64BAFA68DD7434390BDBE9B9C5 \
  162. #FD3A5288F042B6850C66B31F09FE44734EB7990E \
  163. #71DCFD284A79C3B38668286BC97EC7A07EDE3FC1 \
  164. #DD8F2338BAE7501E3DD5AC78C273792F7D83545D \
  165. #C4F0DFFF4E8C1A8236409D08E73BC641CC11F4C8 \
  166. #B9AE9905FFD7803F25714661B63B535A4C206CA9 \
  167. #; do \
  168. #gpg --keyserver ha.pool.sks-keyservers.net --recv-keys "$key" || \
  169. #gpg --keyserver pgp.mit.edu --recv-keys "$key" || \
  170. #gpg --keyserver keyserver.pgp.com --recv-keys "$key" ; \
  171. #done && \
  172. #gpg --verify SHASUMS256.txt.asc && \
  173. # Ignore socket files then delete files then delete directories
  174. #find "$GNUPGHOME" -type f | xargs rm -f && \
  175. #find "$GNUPGHOME" -type d | xargs rm -fR && \
  176. rm -f SHASUMS256.txt.asc && \
  177. \
  178. # Install Node
  179. tar xvzf node-${NODE_VERSION}-${ARCHITECTURE}.tar.gz && \
  180. rm node-${NODE_VERSION}-${ARCHITECTURE}.tar.gz && \
  181. mv node-${NODE_VERSION}-${ARCHITECTURE} /opt/nodejs && \
  182. ln -s /opt/nodejs/bin/node /usr/bin/node && \
  183. ln -s /opt/nodejs/bin/npm /usr/bin/npm && \
  184. mkdir -p /opt/nodejs/lib/node_modules/fibers/.node-gyp /root/.node-gyp/8.16.1 /home/wekan/.config && \
  185. chown wekan --recursive /home/wekan/.config && \
  186. \
  187. #DOES NOT WORK: paxctl fix for alpine linux: https://github.com/wekan/wekan/issues/1303
  188. #paxctl -mC `which node` && \
  189. \
  190. # Install Node dependencies. Python path for node-gyp.
  191. npm install -g npm@${NPM_VERSION} && \
  192. #npm config set python python2.7 && \
  193. #npm install -g node-gyp && \
  194. #npm install -g fibers@${FIBERS_VERSION} && \
  195. \
  196. # Change user to wekan and install meteor
  197. cd /home/wekan/ && \
  198. chown wekan --recursive /home/wekan && \
  199. #curl "https://install.meteor.com" -o /home/wekan/install_meteor.sh && \
  200. #curl "https://install.meteor.com/?release=${METEOR_RELEASE}" -o /home/wekan/install_meteor.sh && \
  201. # OLD: sed -i "s|RELEASE=.*|RELEASE=${METEOR_RELEASE}\"\"|g" ./install_meteor.sh && \
  202. # Install Meteor forcing its progress
  203. #sed -i 's/VERBOSITY="--silent"/VERBOSITY="--progress-bar"/' ./install_meteor.sh && \
  204. echo "Starting meteor ${METEOR_RELEASE} installation... \n" && \
  205. gosu wekan:wekan curl https://install.meteor.com/ | /bin/sh && \
  206. mv /root/.meteor /home/wekan/ && \
  207. chown wekan --recursive /home/wekan/.meteor && \
  208. \
  209. # Check if opting for a release candidate instead of major release
  210. #if [ "$USE_EDGE" = false ]; then \
  211. #gosu wekan:wekan sh /home/wekan/install_meteor.sh; \
  212. # gosu wekan:wekan curl https://install.meteor.com/ | sh; \
  213. #else \
  214. # gosu wekan:wekan git clone --recursive --depth 1 -b release/METEOR@${METEOR_EDGE} https://github.com/meteor/meteor.git /home/wekan/.meteor; \
  215. #fi; \
  216. #\
  217. # Get additional packages
  218. #mkdir -p /home/wekan/app/packages && \
  219. #chown wekan:wekan --recursive /home/wekan && \
  220. # REPOS BELOW ARE INCLUDED TO WEKAN REPO
  221. #cd /home/wekan/app/packages && \
  222. #gosu wekan:wekan git clone --depth 1 -b master https://github.com/wekan/flow-router.git kadira-flow-router && \
  223. #gosu wekan:wekan git clone --depth 1 -b master https://github.com/meteor-useraccounts/core.git meteor-useraccounts-core && \
  224. #gosu wekan:wekan git clone --depth 1 -b master https://github.com/wekan/meteor-accounts-cas.git && \
  225. #gosu wekan:wekan git clone --depth 1 -b master https://github.com/wekan/wekan-ldap.git && \
  226. #gosu wekan:wekan git clone --depth 1 -b master https://github.com/wekan/wekan-scrollbar.git && \
  227. #gosu wekan:wekan git clone --depth 1 -b master https://github.com/wekan/meteor-accounts-oidc.git && \
  228. #gosu wekan:wekan git clone --depth 1 -b master --recurse-submodules https://github.com/wekan/markdown.git && \
  229. #gosu wekan:wekan mv meteor-accounts-oidc/packages/switch_accounts-oidc wekan-accounts-oidc && \
  230. #gosu wekan:wekan mv meteor-accounts-oidc/packages/switch_oidc wekan-oidc && \
  231. #gosu wekan:wekan rm -rf meteor-accounts-oidc && \
  232. sed -i 's/api\.versionsFrom/\/\/api.versionsFrom/' /home/wekan/app/packages/meteor-useraccounts-core/package.js && \
  233. cd /home/wekan/.meteor && \
  234. gosu wekan:wekan /home/wekan/.meteor/meteor -- help; \
  235. \
  236. # extract the OpenAPI specification
  237. #npm install -g api2html@0.3.3 && \
  238. #mkdir -p /home/wekan/python && \
  239. #chown wekan --recursive /home/wekan/python && \
  240. #cd /home/wekan/python && \
  241. #gosu wekan:wekan git clone --depth 1 -b master https://github.com/Kronuz/esprima-python && \
  242. #cd /home/wekan/python/esprima-python && \
  243. #python3 setup.py install --record files.txt && \
  244. #cd /home/wekan/app && \
  245. #mkdir -p /home/wekan/app/public/api && \
  246. #chown wekan --recursive /home/wekan/app && \
  247. #gosu wekan:wekan python3 ./openapi/generate_openapi.py --release $(git describe --tags --abbrev=0) > ./public/api/wekan.yml && \
  248. #gosu wekan:wekan /opt/nodejs/bin/api2html -c ./public/logo-header.png -o ./public/api/wekan.html ./public/api/wekan.yml; \
  249. # Build app
  250. cd /home/wekan/app && \
  251. mkdir -p /home/wekan/.npm && \
  252. chown wekan --recursive /home/wekan/.npm /home/wekan/.config /home/wekan/.meteor && \
  253. #gosu wekan:wekan /home/wekan/.meteor/meteor add standard-minifier-js && \
  254. gosu wekan:wekan npm install && \
  255. gosu wekan:wekan /home/wekan/.meteor/meteor build --directory /home/wekan/app_build && \
  256. cp /home/wekan/app/fix-download-unicode/cfs_access-point.txt /home/wekan/app_build/bundle/programs/server/packages/cfs_access-point.js && \
  257. #rm /home/wekan/app_build/bundle/programs/server/npm/node_modules/meteor/rajit_bootstrap3-datepicker/lib/bootstrap-datepicker/node_modules/phantomjs-prebuilt/lib/phantom/bin/phantomjs && \
  258. chown wekan /home/wekan/app_build/bundle/programs/server/packages/cfs_access-point.js && \
  259. #Removed binary version of bcrypt because of security vulnerability that is not fixed yet.
  260. #https://github.com/wekan/wekan/commit/4b2010213907c61b0e0482ab55abb06f6a668eac
  261. #https://github.com/wekan/wekan/commit/7eeabf14be3c63fae2226e561ef8a0c1390c8d3c
  262. #cd /home/wekan/app_build/bundle/programs/server/npm/node_modules/meteor/npm-bcrypt && \
  263. #gosu wekan:wekan rm -rf node_modules/bcrypt && \
  264. #gosu wekan:wekan npm install bcrypt && \
  265. #
  266. # Delete phantomjs
  267. #cd /home/wekan/app_build/bundle && \
  268. #find . -name "*phantomjs*" | xargs rm -rf && \
  269. #
  270. cd /home/wekan/app_build/bundle/programs/server/ && \
  271. gosu wekan:wekan npm install && \
  272. #gosu wekan:wekan npm install bcrypt && \
  273. # Remove legacy webbroser bundle, so that Wekan works also at Android Firefox, iOS Safari, etc.
  274. rm -rf /home/wekan/app_build/bundle/programs/web.browser.legacy && \
  275. mv /home/wekan/app_build/bundle /build && \
  276. \
  277. # Put back the original tar
  278. mv $(which tar)~ $(which tar) && \
  279. \
  280. # Cleanup
  281. apt-get remove --purge -y ${BUILD_DEPS} && \
  282. apt-get autoremove -y && \
  283. npm uninstall -g api2html &&\
  284. rm -R /var/lib/apt/lists/* && \
  285. rm -R /home/wekan/.meteor && \
  286. rm -R /home/wekan/app && \
  287. rm -R /home/wekan/app_build
  288. #cat /home/wekan/python/esprima-python/files.txt | xargs rm -R && \
  289. #rm -R /home/wekan/python
  290. #rm /home/wekan/install_meteor.sh
  291. ENV PORT=8080
  292. EXPOSE $PORT
  293. USER wekan
  294. CMD ["node", "/build/main.js"]