Dockerfile 4.3 KB

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