diff --git a/m/tent/configuration.nix b/m/tent/configuration.nix index 2b7f3f42..afbb2dbc 100644 --- a/m/tent/configuration.nix +++ b/m/tent/configuration.nix @@ -11,6 +11,7 @@ ./nix-serve.nix ./gitlab-runner.nix ./gitea.nix + ./openproject.nix ../hut/public-inbox.nix ../hut/msmtp.nix ../module/p.nix diff --git a/m/tent/nginx.nix b/m/tent/nginx.nix index 71207a43..d390871e 100644 --- a/m/tent/nginx.nix +++ b/m/tent/nginx.nix @@ -52,6 +52,16 @@ in proxy_pass http://127.0.0.1:8081; proxy_redirect http:// $scheme://; } + location /op { + proxy_pass http://127.0.0.1:8080; + proxy_pass_header Server; + proxy_redirect off; + proxy_set_header X-Forwarded-Proto https; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Scheme $scheme; + proxy_pass_request_headers on; + } location /grafana { proxy_pass http://127.0.0.1:2342; proxy_redirect http:// $scheme://; diff --git a/m/tent/openproject.nix b/m/tent/openproject.nix new file mode 100644 index 00000000..2afd085c --- /dev/null +++ b/m/tent/openproject.nix @@ -0,0 +1,51 @@ +{ pkgs, ... }: + +let + dataDir = "/var/lib/openproject/assets"; +in +{ + # TODO: Create a new user and group to run openproject + + # Ensure directory exists + systemd.tmpfiles.rules = [ + "d ${dataDir} 777 root root" + ]; + + systemd.services.openproject = let + openprojectSrc = pkgs.fetchFromGitHub { + owner = "opf"; + repo = "openproject-docker-compose"; + rev = "b66694f26020a205fbefd697530fee287d1ddea2"; # branch stable/17 + sha256 = "sha256-m23vM0NyaTA54sjAHlFJ8mOhOjqp9CAciLx4UxzFfHI="; + }; + envFile = pkgs.writeText ".env" '' + # https://www.openproject.org/docs/installation-and-operations/configuration/environment/ + TAG=17-slim + OPENPROJECT_HTTPS=true + SECRET_KEY_BASE=OVERWRITE_ME + OPENPROJECT_HOST__NAME=jungle.bsc.es + PORT=127.0.0.1:8080 + OPENPROJECT_RAILS__RELATIVE__URL__ROOT=/op + IMAP_ENABLED=false + DATABASE_URL=postgres://postgres:p4ssw0rd@db/openproject?pool=20&encoding=unicode&reconnect=true + RAILS_MIN_THREADS=4 + RAILS_MAX_THREADS=16 + PGDATA="/var/lib/postgresql/data" + OPDATA="${dataDir}" + COLLABORATIVE_SERVER_URL=ws://localhost:8080/hocuspocus + COLLABORATIVE_SERVER_SECRET=secret12345 + ''; + in { + # Needs docker-compose package + path = with pkgs; [ docker-compose ]; + script = '' + docker-compose \ + -p openproject \ + -f ${openprojectSrc}/docker-compose.yml \ + --env-file ${envFile} \ + up --build --pull always + ''; + wantedBy = [ "multi-user.target" ]; + after = [ "docker.service" "docker.socket" ]; + }; +}