Dockerfile 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. # ---------------------------------------------
  2. # Overleaf Community Edition (overleaf/overleaf)
  3. # ---------------------------------------------
  4. ARG OVERLEAF_BASE_TAG=sharelatex/sharelatex-base:latest
  5. FROM $OVERLEAF_BASE_TAG
  6. WORKDIR /overleaf
  7. # Add required source files
  8. # -------------------------
  9. ADD server-ce/genScript.js /overleaf/genScript.js
  10. ADD server-ce/services.js /overleaf/services.js
  11. ADD package.json package-lock.json /overleaf/
  12. ADD libraries/ /overleaf/libraries/
  13. ADD services/ /overleaf/services/
  14. # Add npm patches
  15. # -----------------------
  16. ADD patches/ /overleaf/patches
  17. # Install npm dependencies and build webpack assets
  18. # ------------------------
  19. RUN --mount=type=cache,target=/root/.cache \
  20. --mount=type=cache,target=/root/.npm \
  21. --mount=type=cache,target=/overleaf/services/web/node_modules/.cache,id=server-ce-webpack-cache \
  22. --mount=type=tmpfs,target=/tmp true \
  23. && node genScript install | bash \
  24. && node genScript compile | bash
  25. # Copy runit service startup scripts to its location
  26. # --------------------------------------------------
  27. ADD server-ce/runit /etc/service
  28. # Copy runit global settings to its location
  29. # ------------------------------------------
  30. ADD server-ce/config/env.sh /etc/overleaf/env.sh
  31. # Configure nginx
  32. # ---------------
  33. ADD server-ce/nginx/nginx.conf.template /etc/nginx/templates/nginx.conf.template
  34. ADD server-ce/nginx/overleaf.conf /etc/nginx/sites-enabled/overleaf.conf
  35. ADD server-ce/nginx/clsi-nginx.conf /etc/nginx/sites-enabled/clsi-nginx.conf
  36. # Configure log rotation
  37. # ----------------------
  38. ADD server-ce/logrotate/overleaf /etc/logrotate.d/overleaf
  39. RUN chmod 644 /etc/logrotate.d/overleaf
  40. # Configure cron tasks
  41. # ----------------------
  42. ADD server-ce/cron /overleaf/cron
  43. ADD server-ce/config/crontab-history /etc/cron.d/crontab-history
  44. RUN chmod 600 /etc/cron.d/crontab-history
  45. ADD server-ce/config/crontab-deletion /etc/cron.d/crontab-deletion
  46. RUN chmod 600 /etc/cron.d/crontab-deletion
  47. # Copy Phusion Image startup and shutdown scripts to their locations
  48. # ------------------------------------------------------------------
  49. COPY server-ce/init_scripts/ /etc/my_init.d/
  50. COPY server-ce/init_preshutdown_scripts/ /etc/my_init.pre_shutdown.d/
  51. # Copy app settings files
  52. # -----------------------
  53. COPY server-ce/config/settings.js /etc/overleaf/settings.js
  54. # Copy history-v1 files
  55. # -----------------------
  56. COPY server-ce/config/production.json /overleaf/services/history-v1/config/production.json
  57. COPY server-ce/config/custom-environment-variables.json /overleaf/services/history-v1/config/custom-environment-variables.json
  58. # Copy grunt thin wrapper
  59. # -----------------------
  60. ADD server-ce/bin/grunt /usr/local/bin/grunt
  61. RUN chmod +x /usr/local/bin/grunt
  62. # Copy history helper scripts
  63. # ---------------------------
  64. ADD server-ce/bin/flush-history-queues /overleaf/bin/flush-history-queues
  65. RUN chmod +x /overleaf/bin/flush-history-queues
  66. ADD server-ce/bin/force-history-resyncs /overleaf/bin/force-history-resyncs
  67. RUN chmod +x /overleaf/bin/force-history-resyncs
  68. # File that controls open|closed status of the site
  69. # -------------------------------------------------
  70. ENV SITE_MAINTENANCE_FILE "/etc/overleaf/site_status"
  71. RUN touch $SITE_MAINTENANCE_FILE
  72. # Set Environment Variables
  73. # --------------------------------
  74. ENV OVERLEAF_CONFIG /etc/overleaf/settings.js
  75. ENV WEB_API_USER "overleaf"
  76. ENV ADMIN_PRIVILEGE_AVAILABLE "true"
  77. ENV OVERLEAF_APP_NAME "Overleaf Community Edition"
  78. ENV OPTIMISE_PDF "true"
  79. # Phusion Image timeouts before sending SIGKILL to processes
  80. # ----------------------------------------------------------
  81. ENV KILL_PROCESS_TIMEOUT 55
  82. ENV KILL_ALL_PROCESSES_TIMEOUT 55
  83. ENV GRACEFUL_SHUTDOWN_DELAY_SECONDS 1
  84. ENV NODE_ENV "production"
  85. ENV LOG_LEVEL "info"
  86. EXPOSE 80
  87. ENTRYPOINT ["/sbin/my_init"]
  88. # Store the revision
  89. # ------------------
  90. # This should be the last step to optimize docker image caching.
  91. ARG MONOREPO_REVISION
  92. RUN echo "monorepo-server-ce,$MONOREPO_REVISION" > /var/www/revisions.txt