This guide deploys ONLYOFFICE Document Server with Docker Compose on Debian 10 to latest stable, Ubuntu LTS, and RHEL 9+ compatible hosts.
- name: Deploy ONLYOFFICE Docs
hosts: onlyoffice-docs
become: true
vars:
app_root: /opt/onlyoffice-docs
app_port: 80
jwt_secret: "{{ vault_onlyoffice_jwt_secret }}"
db_password: "{{ vault_onlyoffice_db_password }}"
tasks:
- name: Install Docker on Debian/Ubuntu
apt:
name:
- docker.io
- docker-compose-plugin
state: present
update_cache: true
when: ansible_os_family == "Debian"
- name: Install Docker on RHEL family
dnf:
name:
- docker-ce
- docker-ce-cli
- containerd.io
- docker-compose-plugin
state: present
when: ansible_os_family == "RedHat"
- name: Enable and start Docker
service:
name: docker
state: started
enabled: true
- name: Create app directory
file:
path: "{{ app_root }}"
state: directory
mode: "0755"
- name: Write Docker Compose file
copy:
dest: "{{ app_root }}/docker-compose.yml"
mode: "0644"
content: |
version: '3.8'
services:
onlyoffice:
image: onlyoffice/documentserver:latest
container_name: onlyoffice-document-server
restart: unless-stopped
ports:
- "{{ app_port }}:80"
volumes:
- ./logs:/var/log/onlyoffice
- ./data:/var/www/onlyoffice/Data
- ./lib:/var/lib/onlyoffice
- ./db:/var/lib/postgresql
environment:
- JWT_ENABLED=true
- JWT_SECRET={{ jwt_secret }}
- DB_TYPE=postgres
- DB_HOST=localhost
- DB_PORT=5432
- DB_NAME=onlyoffice
- DB_USER=onlyoffice_user
- DB_PWD={{ db_password }}
- name: Start application stack
community.docker.docker_compose:
project_src: "{{ app_root }}"
state: present
- name: Wait for ONLYOFFICE to be ready
uri:
url: "http://localhost:{{ app_port }}/webapps/hello"
status_code: 200
register: result
until: result.status == 200
retries: 60
delay: 5
Create an ansible-vault file with secure secrets:
# group_vars/all/vault.yml
vault_onlyoffice_jwt_secret: "your-32-character-random-secret-here"
vault_onlyoffice_db_password: "your-secure-database-password"
Generate the JWT secret with: openssl rand -hex 32
# Run the playbook
ansible-playbook -i inventory.ini onlyoffice-docs.yml
# With vault password
ansible-playbook -i inventory.ini onlyoffice-docs.yml --ask-vault-pass
For production deployments, consider adding:
/var/www/onlyoffice/Data and databaseFor Nextcloud/ownCloud integration:
https://your-serverSee Configuration and Security for production hardening.
Any questions?
Feel free to contact us. Find all contact information on our contact page.