Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit dad11441 authored by sajid khan's avatar sajid khan
Browse files

onlyoffice-document-server service added to docker-compose.local.yml and...

onlyoffice-document-server service added to docker-compose.local.yml and slim.Dockerfile updated to auto-configure OnlyOffice integration in Nextcloud.
parent 3c136168
Loading
Loading
Loading
Loading
Loading
+11 −6
Original line number Diff line number Diff line
@@ -22,12 +22,17 @@ DB_PASSWORD=123456
DB_NAME=nextcloud

# New: OnlyOffice
ONLYOFFICE_DOCUMENT_SERVER_URL=http://documentserver  # Internal Docker URL (auto-adjusts to https in staging/prod via env)
ONLYOFFICE_JWT_SECRET=your_jwt_secret_here  # Generate: openssl rand -hex 32
ONLYOFFICE_JWT_HEADER=AuthorizationJwt
ONLYOFFICE_INNER_REQUEST_TIMEOUT=3600
ONLYOFFICE_MAX_FILE_SIZE=10000000  # 10MB
ONLYOFFICE_DB_PASSWORD=onlyoffice  # For DB user; override in production with secure password
# ONLYOFFICE_DOCUMENT_SERVER_URL=http://documentserver  # Internal Docker URL (auto-adjusts to https in staging/prod via env)
# ONLYOFFICE_JWT_SECRET=your_jwt_secret_here  # Generate: openssl rand -hex 32
# ONLYOFFICE_JWT_HEADER=AuthorizationJwt
# ONLYOFFICE_INNER_REQUEST_TIMEOUT=3600
# ONLYOFFICE_MAX_FILE_SIZE=10000000  # 10MB
# ONLYOFFICE_DB_PASSWORD=onlyoffice  # For DB user; override in production with secure password

ONLYOFFICE_WOPI_URL=http://onlyoffice-document-server/
ONLYOFFICE_JWT_ENABLED=false
ONLYOFFICE_JWT_SECRET=your_jwt_secret_here


# redis
REDIS_HOST=redis
+24 −0
Original line number Diff line number Diff line
<?php
if (!isset($CONFIG)) $CONFIG = [];

$map = [
    'ONLYOFFICE_WOPI_URL' => 'DocumentServerUrl',
    'ONLYOFFICE_JWT_ENABLED' => 'jwt_enabled',
    'ONLYOFFICE_JWT_SECRET' => 'jwt_secret',
];

foreach ($map as $env => $key) {
    $val = getenv($env);
    if ($val !== false && $val !== '') {
        if ($key === 'jwt_enabled') {
            $CONFIG['onlyoffice'][$key] = filter_var($val, FILTER_VALIDATE_BOOLEAN);
        } else {
            $CONFIG['onlyoffice'][$key] = $val;
        }
    }
}

# Default for local runs
if (empty($CONFIG['onlyoffice']['DocumentServerUrl'])) {
    $CONFIG['onlyoffice']['DocumentServerUrl'] = 'http://onlyoffice-document-server/';
}
+29 −0
Original line number Diff line number Diff line
@@ -44,4 +44,33 @@ else
    sh -c "php $DST_DIR/occ config:system:set profile.enabled --value=false --type=boolean"
fi


# --- AUTO INSTALL & ENABLE ONLYOFFICE APP ---
DST_DIR="/var/www/html"
OCC="php $DST_DIR/occ"

echo "Checking OnlyOffice app installation..."
if [ "$(id -u)" = 0 ]; then
    su -p www-data -s /bin/sh -c "$OCC app:install onlyoffice || true"
    su -p www-data -s /bin/sh -c "$OCC app:enable onlyoffice || true"
else
    $OCC app:install onlyoffice || true
    $OCC app:enable onlyoffice || true
fi

echo "OnlyOffice app installed and enabled."
# --- ADD SAMPLE FILES TO ADMIN ACCOUNT ---
ADMIN_USER="${NEXTCLOUD_ADMIN_USER:-admin}"
ADMIN_PASS="${NEXTCLOUD_ADMIN_PASSWORD:-admin}"
SAMPLES_DIR="/config/onlyoffice/samples"

if [ -d "$SAMPLES_DIR" ]; then
    echo "Importing OnlyOffice sample files..."
    for f in "$SAMPLES_DIR"/*; do
        fname=$(basename "$f")
        curl -u "${ADMIN_USER}:${ADMIN_PASS}" -T "$f" \
          "http://localhost:8080/remote.php/webdav/Samples/${fname}" || true
    done
fi

/entrypoint.sh "$@"
+3 −0
Original line number Diff line number Diff line
CREATE USER onlyoffice WITH PASSWORD 'onlyoffice_password';
CREATE DATABASE onlyoffice OWNER onlyoffice;
GRANT ALL PRIVILEGES ON DATABASE onlyoffice TO onlyoffice;
 No newline at end of file
+23 −0
Original line number Diff line number Diff line
@@ -8,6 +8,7 @@ services:
      - POSTGRES_PASSWORD=${DB_PASSWORD}
    volumes:
      - db:/var/lib/postgresql/data
      - ./db/init:/docker-entrypoint-initdb.d:ro
    healthcheck:
      test: ["CMD-SHELL", "pg_isready -U ${DB_USER} -d ${DB_NAME}"]
      interval: 10s
@@ -62,10 +63,32 @@ services:
    depends_on:
      - nextcloud

  onlyoffice-document-server:
    image: onlyoffice/documentserver:7.4.1
    restart: unless-stopped
    environment:
      - JWT_ENABLED=${ONLYOFFICE_JWT_ENABLED:-false}
      - JWT_SECRET=${ONLYOFFICE_JWT_SECRET:-change-me}
    ports:
      - "8082:80"
    networks:
      - proxy-network
      - worker-network
    healthcheck:
      test: ["CMD", "curl", "-f", "http://localhost/healthcheck"]
      interval: 10s
      timeout: 5s
      retries: 5
    volumes:
      - onlyoffice-data:/var/www/onlyoffice/Data
      - onlyoffice-logs:/var/log/onlyoffice

volumes: !override
  db:
  nextcloud-config:
  nextcloud-data:
  onlyoffice-data:
  onlyoffice-logs:

networks:
  proxy-network:
Loading