Dockerfile 12 KB

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