feat: add OnlyOffice for Nextcloud spreadsheets
This commit is contained in:
parent
ac713004b6
commit
e14ff74c5b
|
|
@ -24,9 +24,10 @@ locals {
|
|||
jellyfin_backend_host = var.jellyfin_backend_host != "" ? var.jellyfin_backend_host : var.gitea_backend_host
|
||||
jeannie_api_server_name = "api.${var.server_name}"
|
||||
office_server_name = var.office_server_name
|
||||
server_names = distinct(concat([var.server_name, local.heimdall_server_name, local.homepage_server_name, local.oidc_server_name, local.jellyfin_server_name, local.jeannie_api_server_name, local.office_server_name], var.additional_server_names))
|
||||
office_onlyoffice_server_name = var.office_onlyoffice_server_name
|
||||
server_names = distinct(concat([var.server_name, local.heimdall_server_name, local.homepage_server_name, local.oidc_server_name, local.jellyfin_server_name, local.jeannie_api_server_name, local.office_server_name, local.office_onlyoffice_server_name], var.additional_server_names))
|
||||
matrix_server_names = var.matrix_enabled ? [var.matrix_server_name, var.element_server_name] : []
|
||||
main_server_names = [for name in local.server_names : name if !contains([local.heimdall_server_name, local.homepage_server_name, local.oidc_server_name, local.jellyfin_server_name, local.jeannie_api_server_name, local.office_server_name], name) && !contains(local.matrix_server_names, name)]
|
||||
main_server_names = [for name in local.server_names : name if !contains([local.heimdall_server_name, local.homepage_server_name, local.oidc_server_name, local.jellyfin_server_name, local.jeannie_api_server_name, local.office_server_name, local.office_onlyoffice_server_name], name) && !contains(local.matrix_server_names, name)]
|
||||
default_conf = templatefile("${path.module}/templates/default.conf.tftpl", {
|
||||
server_name = var.server_name
|
||||
server_names = join(" ", local.server_names)
|
||||
|
|
@ -55,6 +56,8 @@ locals {
|
|||
office_backend_host = var.office_backend_host
|
||||
office_backend_port = tostring(var.office_backend_port)
|
||||
office_collabora_backend_port = tostring(var.office_collabora_backend_port)
|
||||
office_onlyoffice_server_name = local.office_onlyoffice_server_name
|
||||
office_onlyoffice_backend_port = tostring(var.office_onlyoffice_backend_port)
|
||||
})
|
||||
default_vcl = templatefile("${path.module}/templates/default.vcl.tftpl", {
|
||||
backend_host = var.backend_host
|
||||
|
|
|
|||
|
|
@ -84,7 +84,7 @@ server {
|
|||
|
||||
server {
|
||||
listen 80;
|
||||
server_name ${heimdall_server_name} ${homepage_server_name} ${oidc_server_name} ${jellyfin_server_name} ${jeannie_api_server_name} ${office_server_name};
|
||||
server_name ${heimdall_server_name} ${homepage_server_name} ${oidc_server_name} ${jellyfin_server_name} ${jeannie_api_server_name} ${office_server_name} ${office_onlyoffice_server_name};
|
||||
|
||||
location ^~ /.well-known/acme-challenge/ {
|
||||
root /var/www/certbot;
|
||||
|
|
@ -97,6 +97,35 @@ server_name ${heimdall_server_name} ${homepage_server_name} ${oidc_server_name}
|
|||
}
|
||||
}
|
||||
|
||||
server {
|
||||
listen 443 ssl;
|
||||
http2 on;
|
||||
server_name ${office_onlyoffice_server_name};
|
||||
|
||||
ssl_certificate /etc/nginx/certs/current.crt;
|
||||
ssl_certificate_key /etc/nginx/certs/current.key;
|
||||
ssl_protocols TLSv1.2 TLSv1.3;
|
||||
ssl_ciphers HIGH:!aNULL:!MD5;
|
||||
client_max_body_size 2g;
|
||||
|
||||
location / {
|
||||
proxy_pass http://${office_backend_host}:${office_onlyoffice_backend_port};
|
||||
proxy_http_version 1.1;
|
||||
proxy_buffering off;
|
||||
proxy_request_buffering off;
|
||||
proxy_read_timeout 3600s;
|
||||
proxy_send_timeout 3600s;
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
proxy_set_header Connection $connection_upgrade;
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header X-Forwarded-Host $host;
|
||||
proxy_set_header X-Forwarded-Proto https;
|
||||
proxy_set_header X-Forwarded-Port 443;
|
||||
}
|
||||
}
|
||||
|
||||
server {
|
||||
listen 443 ssl;
|
||||
http2 on;
|
||||
|
|
|
|||
|
|
@ -168,6 +168,16 @@ variable "office_collabora_backend_port" {
|
|||
default = 9980
|
||||
}
|
||||
|
||||
variable "office_onlyoffice_server_name" {
|
||||
type = string
|
||||
default = "docs.lab2025.duckdns.org"
|
||||
}
|
||||
|
||||
variable "office_onlyoffice_backend_port" {
|
||||
type = number
|
||||
default = 9981
|
||||
}
|
||||
|
||||
# Matrix (isolated vhost + its own cert; does NOT touch shared current.crt)
|
||||
variable "matrix_enabled" {
|
||||
type = bool
|
||||
|
|
|
|||
|
|
@ -1,7 +1,8 @@
|
|||
# Online office stack
|
||||
|
||||
This stack provides browser-based LibreOffice-compatible editing through
|
||||
Nextcloud and Collabora Online. It stores documents in the dedicated
|
||||
This stack provides browser-based office editing through Nextcloud. It deploys
|
||||
ONLYOFFICE Docs for Excel-compatible XLSX editing and keeps Collabora available
|
||||
as a separately managed fallback. It stores documents in the dedicated
|
||||
`/data/homelab-office` tree on Debian and uses PostgreSQL and Redis instead of
|
||||
SQLite or in-container state.
|
||||
|
||||
|
|
@ -11,8 +12,9 @@ The pipeline deploys the stack independently with:
|
|||
./jeannie deploy-office
|
||||
```
|
||||
|
||||
The edge route is `https://office.lab2025.duckdns.org` and is protected by
|
||||
Dex SSO. Dex SSO is configured by the pipeline after the first
|
||||
The Nextcloud edge route is `https://office.lab2025.duckdns.org`; ONLYOFFICE is
|
||||
available at `https://docs.lab2025.duckdns.org`. The Nextcloud route is protected
|
||||
by Dex SSO. Dex SSO is configured by the pipeline after the first
|
||||
Nextcloud boot when `DEX_OFFICE_CLIENT_SECRET` exists in the encrypted Dex
|
||||
secret. Existing older Dex secret files must be regenerated or supplied with
|
||||
`LAB_OFFICE_OIDC_CLIENT_SECRET`; credentials are never committed to the
|
||||
|
|
|
|||
|
|
@ -63,6 +63,22 @@ services:
|
|||
- "${OFFICE_BIND_IP:-127.0.0.1}:${OFFICE_COLLABORA_PORT:-9980}:9980"
|
||||
networks: [office]
|
||||
|
||||
onlyoffice:
|
||||
image: ${OFFICE_ONLYOFFICE_IMAGE:-onlyoffice/documentserver:latest}
|
||||
container_name: ${OFFICE_ONLYOFFICE_CONTAINER_NAME:-homelab-office-onlyoffice}
|
||||
restart: unless-stopped
|
||||
environment:
|
||||
JWT_ENABLED: "true"
|
||||
JWT_SECRET: ${OFFICE_ONLYOFFICE_JWT_SECRET:?OFFICE_ONLYOFFICE_JWT_SECRET is required}
|
||||
JWT_HEADER: Authorization
|
||||
USE_UNAUTHORIZED_STORAGE: "false"
|
||||
ports:
|
||||
- "${OFFICE_BIND_IP:-127.0.0.1}:${OFFICE_ONLYOFFICE_PORT:-9981}:80"
|
||||
volumes:
|
||||
- ${OFFICE_ONLYOFFICE_DATA_DIR:-/data/homelab-office/onlyoffice}:/var/www/onlyoffice/Data
|
||||
- ${OFFICE_ONLYOFFICE_LOG_DIR:-/data/homelab-office/onlyoffice-logs}:/var/log/onlyoffice
|
||||
networks: [office]
|
||||
|
||||
networks:
|
||||
office:
|
||||
name: ${OFFICE_NETWORK:-homelab-office}
|
||||
|
|
|
|||
2
jeannie
2
jeannie
|
|
@ -56,7 +56,7 @@ Build And Bootstrap
|
|||
deploy-api Deploy the Temporal-backed Jeannie API on Debian.
|
||||
deploy-heimdall Deploy the Debian-hosted Heimdall dashboard.
|
||||
deploy-dex Deploy the Debian-hosted Dex SSO stack.
|
||||
deploy-office Deploy Nextcloud + Collabora online office.
|
||||
deploy-office Deploy Nextcloud + ONLYOFFICE/Collabora online office.
|
||||
deploy-matrix Deploy the Matrix homeserver (Synapse + Element + Postgres).
|
||||
deploy-ai-stack Deploy the Debian-hosted AI gateway stack.
|
||||
deploy-ai-tools Install/wire local AI CLIs to the AI gateway.
|
||||
|
|
|
|||
|
|
@ -57,6 +57,8 @@ mapping = {
|
|||
"services.office.install_dir": "LAB_OFFICE_INSTALL_DIR",
|
||||
"services.office.http_port": "LAB_OFFICE_HTTP_PORT",
|
||||
"services.office.collabora_port": "LAB_OFFICE_COLLABORA_PORT",
|
||||
"services.office.onlyoffice_port": "LAB_OFFICE_ONLYOFFICE_PORT",
|
||||
"services.office.onlyoffice_url": "LAB_OFFICE_ONLYOFFICE_URL",
|
||||
"services.office.public_url": "LAB_OFFICE_PUBLIC_URL",
|
||||
"services.jellyfin.http_port": "LAB_JELLYFIN_HTTP_PORT",
|
||||
"services.jellyfin.public_url": "LAB_JELLYFIN_PUBLIC_URL",
|
||||
|
|
@ -291,6 +293,8 @@ export_homelab_inventory_tf_vars() {
|
|||
export_if_unset TF_VAR_office_backend_host "${LAB_OFFICE_BACKEND_HOST:-${LAB_DEBIAN_TAILSCALE_IP:-${LAB_DEBIAN_LAN_IP:-}}}"
|
||||
export_if_unset TF_VAR_office_backend_port "${LAB_OFFICE_HTTP_PORT:-8090}"
|
||||
export_if_unset TF_VAR_office_collabora_backend_port "${LAB_OFFICE_COLLABORA_PORT:-9980}"
|
||||
export_if_unset TF_VAR_office_onlyoffice_server_name "${LAB_OFFICE_ONLYOFFICE_HOST:-docs.${LAB_DOMAIN:-lab2025.duckdns.org}}"
|
||||
export_if_unset TF_VAR_office_onlyoffice_backend_port "${LAB_OFFICE_ONLYOFFICE_PORT:-9981}"
|
||||
export_if_unset TF_VAR_jeannie_api_backend_host "${LAB_JEANNIE_API_BACKEND_HOST:-${LAB_DEBIAN_TAILSCALE_IP:-${LAB_DEBIAN_LAN_IP:-}}}"
|
||||
export_if_unset TF_VAR_jeannie_api_backend_port "${LAB_JEANNIE_API_BACKEND_PORT:-8787}"
|
||||
export_if_unset TF_VAR_gitops_repo_url "${LAB_GITOPS_REPO_URL:-}"
|
||||
|
|
|
|||
|
|
@ -971,17 +971,22 @@ deploy_office() {
|
|||
local install_dir="${LAB_OFFICE_INSTALL_DIR:-/data/homelab-office}"
|
||||
local source_dir="${REPO_ROOT}/infra/office"
|
||||
local public_host="${LAB_OFFICE_PUBLIC_HOST:-office.${LAB_DOMAIN:-lab2025.duckdns.org}}"
|
||||
local onlyoffice_host="${LAB_OFFICE_ONLYOFFICE_HOST:-docs.${LAB_DOMAIN:-lab2025.duckdns.org}}"
|
||||
local bind_ip="${LAB_OFFICE_BIND_IP:-0.0.0.0}"
|
||||
local http_port="${LAB_OFFICE_HTTP_PORT:-8090}"
|
||||
local collabora_port="${LAB_OFFICE_COLLABORA_PORT:-9980}"
|
||||
local onlyoffice_port="${LAB_OFFICE_ONLYOFFICE_PORT:-9981}"
|
||||
local env_file="${install_dir}/.env"
|
||||
local nextcloud_data_dir="${install_dir}/nextcloud"
|
||||
local postgres_data_dir="${install_dir}/postgres"
|
||||
local redis_data_dir="${install_dir}/redis"
|
||||
local onlyoffice_data_dir="${install_dir}/onlyoffice"
|
||||
local onlyoffice_log_dir="${install_dir}/onlyoffice-logs"
|
||||
local random_value
|
||||
local dex_env
|
||||
local office_oidc_secret="${LAB_OFFICE_OIDC_CLIENT_SECRET:-}"
|
||||
local office_oidc_issuer="${LAB_DEX_PUBLIC_URL:-https://auth.${LAB_DOMAIN:-lab2025.duckdns.org}}"
|
||||
local onlyoffice_jwt_secret=""
|
||||
|
||||
office_oidc_issuer="${office_oidc_issuer%/}"
|
||||
|
||||
|
|
@ -1005,7 +1010,7 @@ deploy_office() {
|
|||
echo "Office SSO secret is missing. Run ./jeannie dex-secret ensure or set LAB_OFFICE_OIDC_CLIENT_SECRET." >&2
|
||||
exit 1
|
||||
fi
|
||||
sudo mkdir -p "${install_dir}" "${nextcloud_data_dir}" "${postgres_data_dir}" "${redis_data_dir}"
|
||||
sudo mkdir -p "${install_dir}" "${nextcloud_data_dir}" "${postgres_data_dir}" "${redis_data_dir}" "${onlyoffice_data_dir}" "${onlyoffice_log_dir}"
|
||||
sudo cp "${source_dir}/docker-compose.yml" "${install_dir}/docker-compose.yml"
|
||||
|
||||
if ! sudo test -s "${env_file}"; then
|
||||
|
|
@ -1022,9 +1027,12 @@ PY
|
|||
random_value="$(random_value)"
|
||||
sudo tee "${env_file}" >/dev/null <<ENV_EOF
|
||||
OFFICE_PUBLIC_HOST=${public_host}
|
||||
OFFICE_ONLYOFFICE_HOST=${onlyoffice_host}
|
||||
OFFICE_BIND_IP=${bind_ip}
|
||||
OFFICE_HTTP_PORT=${http_port}
|
||||
OFFICE_COLLABORA_PORT=${collabora_port}
|
||||
OFFICE_ONLYOFFICE_PORT=${onlyoffice_port}
|
||||
OFFICE_ONLYOFFICE_JWT_SECRET=$(random_value)
|
||||
OFFICE_POSTGRES_PASSWORD=${random_value}
|
||||
OFFICE_REDIS_PASSWORD=$(random_value)
|
||||
OFFICE_ADMIN_USER=${LAB_OFFICE_ADMIN_USER:-jv}
|
||||
|
|
@ -1043,6 +1051,17 @@ ENV_EOF
|
|||
"${LAB_OFFICE_ADMIN_USER:-jv}" "${random_value}" | sudo tee -a "${env_file}" >/dev/null
|
||||
sudo chmod 600 "${env_file}"
|
||||
fi
|
||||
if ! sudo grep -q '^OFFICE_ONLYOFFICE_JWT_SECRET=' "${env_file}"; then
|
||||
random_value="$(openssl rand -hex 32 2>/dev/null || python3 -c 'import secrets; print(secrets.token_hex(32))')"
|
||||
printf 'OFFICE_ONLYOFFICE_HOST=%s\nOFFICE_ONLYOFFICE_PORT=%s\nOFFICE_ONLYOFFICE_JWT_SECRET=%s\n' \
|
||||
"${onlyoffice_host}" "${onlyoffice_port}" "${random_value}" | sudo tee -a "${env_file}" >/dev/null
|
||||
sudo chmod 600 "${env_file}"
|
||||
fi
|
||||
onlyoffice_jwt_secret="$(sudo sed -n 's/^OFFICE_ONLYOFFICE_JWT_SECRET=//p' "${env_file}" | tail -1)"
|
||||
if [[ -z "${onlyoffice_jwt_secret}" ]]; then
|
||||
echo "ONLYOFFICE JWT secret is missing from ${env_file}." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
(
|
||||
cd "${install_dir}"
|
||||
|
|
@ -1056,11 +1075,29 @@ ENV_EOF
|
|||
(cd "${install_dir}" && sudo docker compose --env-file "${env_file}" logs --tail=120) >&2 || true
|
||||
exit 1
|
||||
fi
|
||||
if ! curl -fsS --connect-timeout 5 "http://127.0.0.1:${onlyoffice_port}/healthcheck" >/dev/null; then
|
||||
echo "ONLYOFFICE did not become reachable at http://127.0.0.1:${onlyoffice_port}/healthcheck." >&2
|
||||
(cd "${install_dir}" && sudo docker compose --env-file "${env_file}" logs --tail=160 onlyoffice) >&2 || true
|
||||
exit 1
|
||||
fi
|
||||
|
||||
sudo docker exec "${OFFICE_NEXTCLOUD_CONTAINER_NAME:-homelab-office-nextcloud}" \
|
||||
sh -lc 'su -s /bin/sh www-data -c "php occ app:install richdocuments 2>/dev/null || true; php occ app:enable richdocuments 2>/dev/null || true; php occ config:app:set richdocuments wopi_url --value=http://collabora:9980 2>/dev/null || true; php occ app:install user_oidc 2>/dev/null || true; php occ app:enable user_oidc 2>/dev/null || true"' || true
|
||||
sudo docker exec "${OFFICE_NEXTCLOUD_CONTAINER_NAME:-homelab-office-nextcloud}" \
|
||||
sh -lc 'su -s /bin/sh www-data -c "php occ richdocuments:activate-config"'
|
||||
sudo docker exec -i \
|
||||
-e "ONLYOFFICE_JWT_SECRET=${onlyoffice_jwt_secret}" \
|
||||
-e "ONLYOFFICE_PUBLIC_URL=https://${onlyoffice_host}/" \
|
||||
"${OFFICE_NEXTCLOUD_CONTAINER_NAME:-homelab-office-nextcloud}" \
|
||||
sh -s <<'OFFICE_ONLYOFFICE_EOF'
|
||||
set -eu
|
||||
su -s /bin/sh www-data -c "php occ app:install onlyoffice 2>/dev/null || true; php occ app:enable onlyoffice"
|
||||
su -s /bin/sh www-data -c "php occ config:app:set onlyoffice DocumentServerUrl --value=\"${ONLYOFFICE_PUBLIC_URL}\""
|
||||
su -s /bin/sh www-data -c "php occ config:app:set onlyoffice DocumentServerInternalUrl --value=http://onlyoffice/"
|
||||
su -s /bin/sh www-data -c "php occ config:app:set onlyoffice StorageUrl --value=http://nextcloud/"
|
||||
su -s /bin/sh www-data -c "php occ config:app:set onlyoffice jwt_secret --value=\"${ONLYOFFICE_JWT_SECRET}\""
|
||||
su -s /bin/sh www-data -c "php occ app:disable richdocuments 2>/dev/null || true"
|
||||
OFFICE_ONLYOFFICE_EOF
|
||||
sudo docker exec -i \
|
||||
-e "OIDC_CLIENT_SECRET=${office_oidc_secret}" \
|
||||
-e "OIDC_ISSUER=${office_oidc_issuer}" \
|
||||
|
|
|
|||
Loading…
Reference in New Issue