Dockerfile 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  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 .pnp.register.mjs /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. # Corepack setup, shared between all the images.
  15. ENV COREPACK_HOME=/opt/corepack
  16. RUN corepack enable && corepack install -g yarn@4.14.1
  17. ENV COREPACK_ENABLE_NETWORK=0
  18. # Install yarn dependencies
  19. # -------------------------
  20. RUN --mount=type=cache,target=/root/.cache \
  21. --mount=type=cache,target=/root/.yarn/berry/cache,id=server-ce-yarn-cache \
  22. --mount=type=cache,target=/usr/local/share/.cache/yarn,id=server-ce-yarn-fallback-cache \
  23. --mount=type=tmpfs,target=/tmp node genScript install | bash
  24. # Add the actual source files
  25. # ---------------------------
  26. COPY --parents libraries/ services/ tools/migrations/ /overleaf/
  27. RUN --mount=type=cache,target=/root/.cache \
  28. --mount=type=cache,target=/root/.yarn/berry/cache,id=server-ce-yarn-cache \
  29. --mount=type=cache,target=/usr/local/share/.cache/yarn,id=server-ce-yarn-fallback-cache \
  30. --mount=type=cache,target=/overleaf/services/web/.cache,id=server-ce-webpack-cache \
  31. --mount=type=tmpfs,target=/tmp \
  32. node genScript compile | bash
  33. # Enable Yarn PnP resolution for all Node.js processes
  34. # -----------------------------------------------------
  35. ENV NODE_OPTIONS="--require /overleaf/.pnp.cjs --import /overleaf/.pnp.register.mjs"
  36. # Copy runit service startup scripts to its location
  37. # --------------------------------------------------
  38. ADD server-ce/runit /etc/service
  39. # Copy runit global settings to its location
  40. # ------------------------------------------
  41. ADD server-ce/config/env.sh /etc/overleaf/env.sh
  42. # Configure nginx
  43. # ---------------
  44. ADD server-ce/nginx/nginx.conf.template /etc/nginx/templates/nginx.conf.template
  45. ADD server-ce/nginx/overleaf.conf /etc/nginx/sites-enabled/overleaf.conf
  46. ADD server-ce/nginx/clsi-nginx.conf /etc/nginx/sites-enabled/clsi-nginx.conf
  47. # Configure log rotation
  48. # ----------------------
  49. ADD server-ce/logrotate/overleaf /etc/logrotate.d/overleaf
  50. RUN chmod 644 /etc/logrotate.d/overleaf
  51. # Configure cron tasks
  52. # ----------------------
  53. ADD server-ce/cron /overleaf/cron
  54. ADD server-ce/config/crontab-history /etc/cron.d/crontab-history
  55. RUN chmod 600 /etc/cron.d/crontab-history
  56. ADD server-ce/config/crontab-deletion /etc/cron.d/crontab-deletion
  57. RUN chmod 600 /etc/cron.d/crontab-deletion
  58. # Copy Phusion Image startup and shutdown scripts to their locations
  59. # ------------------------------------------------------------------
  60. COPY server-ce/init_scripts/ /etc/my_init.d/
  61. COPY server-ce/init_preshutdown_scripts/ /etc/my_init.pre_shutdown.d/
  62. # Copy app settings files
  63. # -----------------------
  64. COPY server-ce/config/settings.js /etc/overleaf/settings.js
  65. # Copy history-v1 files
  66. # -----------------------
  67. COPY server-ce/config/production.json /overleaf/services/history-v1/config/production.json
  68. COPY server-ce/config/custom-environment-variables.json /overleaf/services/history-v1/config/custom-environment-variables.json
  69. # Copy grunt thin wrapper
  70. # -----------------------
  71. ADD server-ce/bin/grunt /usr/local/bin/grunt
  72. RUN chmod +x /usr/local/bin/grunt
  73. # Copy history helper scripts
  74. # ---------------------------
  75. ADD server-ce/bin/flush-history-queues /overleaf/bin/flush-history-queues
  76. RUN chmod +x /overleaf/bin/flush-history-queues
  77. ADD server-ce/bin/force-history-resyncs /overleaf/bin/force-history-resyncs
  78. RUN chmod +x /overleaf/bin/force-history-resyncs
  79. # Copy Latexmkrc
  80. # -----------------------
  81. COPY server-ce/config/latexmkrc /usr/local/share/latexmk/LatexMk
  82. # File that controls open|closed status of the site
  83. # -------------------------------------------------
  84. ENV SITE_MAINTENANCE_FILE="/etc/overleaf/site_status"
  85. RUN touch $SITE_MAINTENANCE_FILE
  86. # Set Environment Variables
  87. # --------------------------------
  88. ENV OVERLEAF_CONFIG=/etc/overleaf/settings.js
  89. ENV WEB_API_USER="overleaf"
  90. ENV ADMIN_PRIVILEGE_AVAILABLE="true"
  91. ENV OVERLEAF_APP_NAME="Overleaf Community Edition"
  92. ENV OPTIMISE_PDF="true"
  93. # Phusion Image timeouts before sending SIGKILL to processes
  94. # ----------------------------------------------------------
  95. ENV KILL_PROCESS_TIMEOUT=55
  96. ENV KILL_ALL_PROCESSES_TIMEOUT=55
  97. ENV GRACEFUL_SHUTDOWN_DELAY_SECONDS=1
  98. ENV NODE_ENV="production"
  99. ENV LOG_LEVEL="info"
  100. EXPOSE 80
  101. ENTRYPOINT ["/sbin/my_init"]