Dockerfile 13 KB

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