Skip to content

Instantly share code, notes, and snippets.

@eliasp
Last active May 20, 2022 22:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save eliasp/d43296a5a5ba050f739f4cd2c01c8db1 to your computer and use it in GitHub Desktop.
Save eliasp/d43296a5a5ba050f739f4cd2c01c8db1 to your computer and use it in GitHub Desktop.
Run OnlyOffice Document Server using Podman and Caddy on Ubuntu 20.04

This is just a basic setup.

  • automatic TLS via Caddy's built-in ACME support
  • no backup of any data
  • no advanced container security

Install Podman

source /etc/os-release
echo "deb https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/stable/xUbuntu_${VERSION_ID}/ /" > /etc/apt/sources.list.d/devel:kubic:libcontainers:stable.list
curl -L https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/stable/xUbuntu_${VERSION_ID}/Release.key | apt-key add -
apt-get update -qq
sudo apt-get -qq -y install podman

Create Host Directories for Document Server and Caddy

mkdir -p /var/lib/onlyoffice/data
mkdir -p /var/lib/caddy/{data,config}
mkdir -p /etc/{onlyoffice,caddy}

Create Only Office Document Server Configuration

echo -e "JWT_ENABLED=true\nJWT_SECRET=$(echo $RANDOM | sha256sum | cut -d' ' -f1)" > /etc/onlyoffice/env.conf

Create Caddy Configuration

NOTE: make sure to replace onlyoffice.yourdomain.tld and your@mmailaddress.tld

/etc/caddy/Caddyfile

{
  http_port 18080
  https_port 18443
}

http://onlyoffice.yourdomain.tld {
  redir https://{host}{uri} permanent
}

https://onlyoffice.yourdomain.tld {
  tls your@mailaddress.tld
  reverse_proxy http://127.0.0.1:80 {
  }
}

Create a Pod for OnlyOffice Document Server

podman pod create --name onlyoffice --publish 80:18080 --publish 443:18443

Run the Document Server and Caddy

podman run -td --pod onlyoffice -v /var/lib/onlyoffice/data:/app/onlyoffice/DocumentServer/data --env-file=/etc/onlyoffice/env.conf --name documentserver docker.io/onlyoffice/documentserver
podman run -td --pod onlyoffice -p 80:18080 -p 443:18443 -v /var/lib/caddy/config:/config -v /var/lib/caddy/data:/data -v /etc/caddy/Caddyfile:/etc/caddy/Caddyfile --name caddy docker.io/caddy

Start Containers Automatically on Boot

cd /etc/systemd/system
podman generate systemd --name --files onlyoffice
systemctl daemon-reload
systemctl enable --now pod-onlyoffice
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment