From 0944595b5a70c5dd7cd626958b4620862d6417f3 Mon Sep 17 00:00:00 2001 From: ba1ash Date: Sun, 12 Oct 2025 22:04:00 +0200 Subject: [PATCH] Add hocuspocus. --- .env.example | 2 ++ docker-compose.yml | 10 ++++++++++ proxy/Caddyfile.template | 20 +++++++++++++------- proxy/Dockerfile | 5 ++++- 4 files changed, 29 insertions(+), 8 deletions(-) diff --git a/.env.example b/.env.example index 0769e420..4dce4a14 100644 --- a/.env.example +++ b/.env.example @@ -17,3 +17,5 @@ RAILS_MIN_THREADS=4 RAILS_MAX_THREADS=16 PGDATA="/var/lib/postgresql/data" OPDATA="/var/openproject/assets" +OPENPROJECT_COLLABORATIVE__EDITING__HOCUSPOCUS__URL=ws://localhost:8080/hocuspocus +OPENPROJECT_COLLABORATIVE__EDITING__HOCUSPOCUS__SECRET=secret12345 diff --git a/docker-compose.yml b/docker-compose.yml index b59cf4f8..59c6110f 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -19,6 +19,8 @@ x-op-app: &app RAILS_CACHE_STORE: "memcache" OPENPROJECT_CACHE__MEMCACHE__SERVER: "cache:11211" OPENPROJECT_RAILS__RELATIVE__URL__ROOT: "${OPENPROJECT_RAILS__RELATIVE__URL__ROOT:-}" + OPENPROJECT_COLLABORATIVE__EDITING__HOCUSPOCUS__URL: "${OPENPROJECT_COLLABORATIVE__EDITING__HOCUSPOCUS__URL}" + OPENPROJECT_COLLABORATIVE__EDITING__HOCUSPOCUS__SECRET: "${OPENPROJECT_COLLABORATIVE__EDITING__HOCUSPOCUS__SECRET}" DATABASE_URL: "${DATABASE_URL:-postgres://postgres:p4ssw0rd@db/openproject?pool=20&encoding=unicode&reconnect=true}" RAILS_MIN_THREADS: ${RAILS_MIN_THREADS:-4} RAILS_MAX_THREADS: ${RAILS_MAX_THREADS:-16} @@ -51,6 +53,7 @@ services: context: ./proxy args: APP_HOST: web + HOCUSPOCUS_HOST: hocuspocus image: openproject/proxy <<: *restart_policy ports: @@ -114,3 +117,10 @@ services: restart: on-failure networks: - backend + + hocuspocus: + image: openproject/hocuspocus:main-88913ad0 + networks: + - frontend + environment: + SECRET: "${OPENPROJECT_COLLABORATIVE__EDITING__HOCUSPOCUS__SECRET}" diff --git a/proxy/Caddyfile.template b/proxy/Caddyfile.template index 7de7b974..bc892f74 100644 --- a/proxy/Caddyfile.template +++ b/proxy/Caddyfile.template @@ -1,12 +1,18 @@ :80 { - reverse_proxy * http://${APP_HOST}:8080 { - # The following directives are needed to make the proxy forward explicitly the X-Forwarded-* headers. If unset, - # Caddy will reset them. See: https://caddyserver.com/docs/caddyfile/directives/reverse_proxy#defaults - # This is needed, if you are using a reverse proxy in front of the compose stack and Caddy is NOT your first - # point of contact. - # When using Caddy is reachable as a first point of contact, it is highly recommended to configure the server's - # global `trusted_proxies` directive. See: https://caddyserver.com/docs/caddyfile/options#trusted-proxies + # Reverse proxy for WebSocket connections + @hocuspocus { + path /hocuspocus* + } + reverse_proxy @hocuspocus ${HOCUSPOCUS_HOST}:1234 { + header_up X-Forwarded-Proto {header.X-Forwarded-Proto} + header_up X-Forwarded-For {header.X-Forwarded-For} + } + # Reverse proxy for all other HTTP requests + @app { + not path /hocuspocus* + } + reverse_proxy @app ${APP_HOST}:8080 { header_up X-Forwarded-Proto {header.X-Forwarded-Proto} header_up X-Forwarded-For {header.X-Forwarded-For} } diff --git a/proxy/Dockerfile b/proxy/Dockerfile index 5a6591b7..f95bdc65 100644 --- a/proxy/Dockerfile +++ b/proxy/Dockerfile @@ -3,6 +3,9 @@ FROM caddy:2 COPY ./Caddyfile.template /etc/caddy/Caddyfile.template ARG APP_HOST -RUN sed 's|${APP_HOST}|'"$APP_HOST"'|g' /etc/caddy/Caddyfile.template > /etc/caddy/Caddyfile +ARG HOCUSPOCUS_HOST +RUN sed -e 's|${APP_HOST}|'"$APP_HOST"'|g' \ + -e 's|${HOCUSPOCUS_HOST}|'"$HOCUSPOCUS_HOST"'|g' \ + /etc/caddy/Caddyfile.template > /etc/caddy/Caddyfile ENTRYPOINT ["caddy", "run", "--config", "/etc/caddy/Caddyfile"]