diff --git a/build.backend.docker.bat b/build.backend.docker.bat deleted file mode 100644 index e538a525ed..0000000000 --- a/build.backend.docker.bat +++ /dev/null @@ -1,7 +0,0 @@ -@echo off - -pwsh %~dp0/build.backend.docker.ps1 %* - -echo. - -pause \ No newline at end of file diff --git a/build.backend.docker.ps1 b/build.backend.docker.ps1 deleted file mode 100644 index 15fe253899..0000000000 --- a/build.backend.docker.ps1 +++ /dev/null @@ -1,133 +0,0 @@ -param( - [switch] $h = $false, - [switch] $f = $false, - [switch] $s = $true, - [switch] $c = $false, - [switch] $d = $false -) - -if ($h) { - Write-Host "Build and run backend and working environment. (Use 'yarn start' to run client -> https://github.com/ONLYOFFICE/DocSpace-client)" - Write-Host - Write-Host "Syntax: available params [-h|f|s|c|d|]" - Write-Host "Options:" - Write-Host "h Print this Help." - Write-Host "f Force rebuild base images." - Write-Host "s Run as SAAS otherwise as STANDALONE." - Write-Host "c Run as COMMUNITY otherwise ENTERPRISE." - Write-Host "d Run dnsmasq." - Write-Host - exit -} - -$PSversionMajor = $PSVersionTable.PSVersion | sort-object major | ForEach-Object { $_.major } -$PSversionMinor = $PSVersionTable.PSVersion | sort-object minor | ForEach-Object { $_.minor } - -if ($PSversionMajor -lt 7 -or $PSversionMinor -lt 2) { - Write-Error "Powershell version must be greater than or equal to 7.2." - exit -} - -$RootDir = Split-Path -Parent $PSScriptRoot -$DockerDir = "$RootDir\buildtools\install\docker" -$LocalIp = (Get-CimInstance -ClassName Win32_NetworkAdapterConfiguration | Where-Object { $_.DHCPEnabled -ne $null -and $_.DefaultIPGateway -ne $null }).IPAddress | Select-Object -First 1 - -$Doceditor = ($LocalIp + ":5013") -$Login = ($LocalIp + ":5011") -$Client = ($LocalIp + ":5001") -$PortalUrl = ("http://" + $LocalIp) -$ProxyVersion="v1.0.0" - -# Stop all backend services" -& "$PSScriptRoot\start\stop.backend.docker.ps1" - -$Env:COMPOSE_IGNORE_ORPHANS = "True" - -$ExistsNetwork= docker network ls --format '{{.Name}}' | findstr "onlyoffice" - -if (-not $ExistsNetwork) { - docker network create --driver bridge onlyoffice -} - -Write-Host "Run MySQL" -ForegroundColor Green -docker compose -f "$DockerDir\db.yml" up -d - -if ($d) { - Write-Host "Run local dns server" -ForegroundColor Green - $Env:ROOT_DIR=$RootDir - docker compose -f "$DockerDir\dnsmasq.yml" up -d -} - -Write-Host "Build backend services (to `publish/` folder)" -ForegroundColor Green -& "$PSScriptRoot\install\common\build-services.ps1" - -$Env:DOCUMENT_SERVER_IMAGE_NAME = "onlyoffice/documentserver-de:latest" -$Env:INSTALLATION_TYPE = "ENTERPRISE" -$Env:MIGRATION_TYPE = "STANDALONE" - -if ($c) { - $Env:DOCUMENT_SERVER_IMAGE_NAME = "onlyoffice/documentserver:latest" - $Env:INSTALLATION_TYPE = "COMMUNITY" -} - -if (-not $s) { - $Env:MIGRATION_TYPE = "SAAS" -} - -Set-Location -Path $RootDir - -$DotnetVersion = "dev" -$NodeVersion = "dev" -$ProxyVersion = "dev" - -$ExistsDotnet= docker images --format "{{.Repository}}:{{.Tag}}" | findstr "onlyoffice/4testing-docspace-dotnet-runtime:$DotnetVersion" -$ExistsNode= docker images --format "{{.Repository}}:{{.Tag}}" | findstr "onlyoffice/4testing-docspace-nodejs-runtime:$NodeVersion" -$ExistsProxy= docker images --format "{{.Repository}}:{{.Tag}}" | findstr "onlyoffice/4testing-docspace-proxy-runtime:$ProxyVersion" - -if (!$ExistsDotnet -or $f) { - Write-Host "Build dotnet base image from source (apply new dotnet config)" -ForegroundColor Green - docker build -t "onlyoffice/4testing-docspace-dotnet-runtime:$DotnetVersion" -f "$DockerDir\Dockerfile.runtime" --target dotnetrun . -} else { - Write-Host "SKIP build dotnet base image (already exists)" -ForegroundColor Blue -} - -if (!$ExistsNode -or $f) { - Write-Host "Build node base image from source" -ForegroundColor Green - docker build -t "onlyoffice/4testing-docspace-nodejs-runtime:$NodeVersion" -f "$DockerDir\Dockerfile.runtime" --target noderun . -} else { - Write-Host "SKIP build node base image (already exists)" -ForegroundColor Blue -} - -if (!$ExistsProxy -or $f) { - Write-Host "Build proxy base image from source (apply new nginx config)" -ForegroundColor Green - docker build -t "onlyoffice/4testing-docspace-proxy-runtime:$ProxyVersion" -f "$DockerDir\Dockerfile.runtime" --target router . -} else { - Write-Host "SKIP build proxy base image (already exists)" -ForegroundColor Blue -} - -Write-Host "Run migration and services" -ForegroundColor Green -$Env:ENV_EXTENSION="dev" -$Env:Baseimage_Dotnet_Run="onlyoffice/4testing-docspace-dotnet-runtime:$DotnetVersion" -$Env:Baseimage_Nodejs_Run="onlyoffice/4testing-docspace-nodejs-runtime:$NodeVersion" -$Env:Baseimage_Proxy_Run="onlyoffice/4testing-docspace-proxy-runtime:$ProxyVersion" -$Env:SERVICE_DOCEDITOR=$Doceditor -$Env:SERVICE_LOGIN=$Login -$Env:SERVICE_CLIENT=$Client -$Env:ROOT_DIR=$RootDir -$Env:BUILD_PATH="/var/www" -$Env:SRC_PATH="$RootDir\publish\services" -$Env:DATA_DIR="$RootDir\data" -$Env:APP_URL_PORTAL=$PortalUrl -docker compose -f "$DockerDir\docspace.profiles.yml" -f "$DockerDir\docspace.overcome.yml" --profile migration-runner --profile backend-local up -d - -Write-Host "== Build params ==" -ForegroundColor Green -Write-Host "APP_URL_PORTAL: $PortalUrl" -ForegroundColor Blue -Write-Host "LOCAL IP: $LocalIp" -ForegroundColor Blue -Write-Host "SERVICE_DOCEDITOR: $Env:SERVICE_DOCEDITOR" -ForegroundColor Blue -Write-Host "SERVICE_LOGIN: $Env:SERVICE_LOGIN" -ForegroundColor Blue -Write-Host "SERVICE_CLIENT: $Env:SERVICE_CLIENT" -ForegroundColor Blue -Write-Host "INSTALLATION_TYPE: $Env:INSTALLATION_TYPE" -ForegroundColor Blue -Write-Host "MIGRATION TYPE: $Env:MIGRATION_TYPE" -ForegroundColor Blue -Write-Host "DS IMAGE: $Env:DOCUMENT_SERVER_IMAGE_NAME" -ForegroundColor Blue - -Set-Location -Path $PSScriptRoot \ No newline at end of file diff --git a/build.backend.docker.py b/build.backend.docker.py new file mode 100755 index 0000000000..7692da1530 --- /dev/null +++ b/build.backend.docker.py @@ -0,0 +1,201 @@ +#!/usr/bin/python3 + +import os +import socket +import subprocess +import sys, getopt +import shutil +import platform + +def help(): + # Display Help + print("Build and run backend and working environment. (Use 'yarn start' to run client -> https://github.com/ONLYOFFICE/DocSpace-client)") + print() + print("Syntax: available params [-h|f|s|c|d|]") + print("options:") + print("h Print this Help.") + print("f Force rebuild base images.") + print("s Run as SAAS otherwise as STANDALONE.") + print("c Run as COMMUNITY otherwise ENTERPRISE.") + print("d Run dnsmasq.") + print() + +rd = os.path.dirname(os.path.abspath(__file__)) +dir = os.path.abspath(os.path.join(rd, "..")) +dockerDir = os.path.join(dir, "buildtools", "install", "docker") +local_ip = socket.gethostbyname_ex(socket.gethostname())[-1][-1] + +doceditor = f"{local_ip}:5013" +login = f"{local_ip}:5011" +client = f"{local_ip}:5001" +portal_url = f"http://{local_ip}" + +force = False +dns = False +standalone = True +community = False + +migration_type = "STANDALONE" # SAAS +installation_type = "ENTERPRISE" +document_server_image_name = "onlyoffice/documentserver-de:latest" + +# Get the options +opts, args = getopt.getopt(sys.argv[1:], "hfscd") +for opt, arg in opts: + if opt == "-h": + help() + sys.exit() + elif opt == "-f": + force = arg if arg else True + elif opt == "-s": + standalone = arg if arg else False + elif opt == "-c": + community = arg if arg else True + elif opt == "-d": + dns = arg if arg else True + else: + print("Error: Invalid '-" + opt + "' option") + sys.exit() + +print("Run script directory:", dir) +print("Root directory:", dir) +print("Docker files root directory:", dockerDir) + +print() +print(f"SERVICE_DOCEDITOR: {doceditor}") +print(f"SERVICE_LOGIN: {login}") +print(f"SERVICE_CLIENT: {client}") +print(f"DOCSPACE_APP_URL: {portal_url}") + +print() +print("FORCE REBUILD BASE IMAGES:", force) +print("Run dnsmasq:", dns) + +if standalone == False: + migration_type = "SAAS" + +if community == True: + installation_type = "COMMUNITY" + document_server_image_name = "onlyoffice/documentserver:latest" + +print() +print("MIGRATION TYPE:", migration_type) +print("INSTALLATION TYPE:", installation_type) +print("DS image:", document_server_image_name) +print() + +# Stop all backend services +subprocess.run(["python", os.path.join(dir, "buildtools", "start", "stop.backend.docker.py")]) + +print("Run MySQL") + +arch_name = platform.uname().machine + +print(f"PLATFORM {arch_name}") + +existsnetwork = subprocess.check_output(["docker", "network", "ls"]).decode("utf-8").splitlines() +existsnetwork = [line.split()[1] for line in existsnetwork] + +if "onlyoffice" not in existsnetwork: + subprocess.run(["docker", "network", "create", "--driver", "bridge", "onlyoffice"]) + +if arch_name == "x86_64" or arch_name == "AMD64": + print("CPU Type: x86_64 -> run db.yml") + subprocess.run(["docker", "compose", "-f", os.path.join(dockerDir, "db.yml"), "up", "-d"]) +elif arch_name == "arm64": + print("CPU Type: arm64 -> run db.yml with arm64v8 image") + os.environ["MYSQL_IMAGE"] = "arm64v8/mysql:8.0.32-oracle" + subprocess.run(["docker", "compose", "-f", os.path.join(dockerDir, "db.yml"), "up", "-d"]) +else: + print("Error: Unknown CPU Type:", arch_name) + sys.exit(1) + +if dns == True: + print("Run local dns server") + os.environ["ROOT_DIR"] = dir + subprocess.run(["docker", "compose", "-f", os.path.join(dockerDir, "dnsmasq.yml"), "up", "-d"]) + +print("Clear publish folder") +shutil.rmtree(os.path.join(dir, "publish/services"), True) + +print("Build backend services (to 'publish/' folder)") +subprocess.run(["python", os.path.join(dir, "buildtools", "install", "common", "build-services.py")]) + +def check_image(image_name): + return subprocess.check_output(["docker", "images", "--format", "'{{.Repository}}:{{.Tag}}'"], shell=True, text=True).__contains__(image_name) + +dotnet_image_name = "onlyoffice/4testing-docspace-dotnet-runtime" +dotnet_version = "dev" +dotnet_image = f"{dotnet_image_name}:{dotnet_version}" + +exists = check_image(dotnet_image) + +if not exists or force == True: + print("Build dotnet base image from source (apply new dotnet config)") + subprocess.run(["docker", "build", "-t", dotnet_image, "-f", os.path.join(dockerDir, "Dockerfile.runtime"), "--target", "dotnetrun", "."]) +else: + print(f"SKIP build {dotnet_image} (already exists)") + +node_image_name = "onlyoffice/4testing-docspace-nodejs-runtime" +node_version = "dev" +node_image = f"{node_image_name}:{node_version}" + +exists = check_image(node_image) + +if not exists or force == True: + print("Build nodejs base image from source") + subprocess.run(["docker", "build", "-t", node_image, "-f", os.path.join(dockerDir, "Dockerfile.runtime"), "--target", "noderun", "."]) +else: + print(f"SKIP build {node_image} (already exists)") + +proxy_image_name = "onlyoffice/4testing-docspace-proxy-runtime" +proxy_version = "dev" +proxy_image = f"{proxy_image_name}:{proxy_version}" + +exists = check_image(proxy_image) + +if not exists or force == True: + print("Build proxy base image from source (apply new nginx config)") + subprocess.run(["docker", "build", "-t", proxy_image, "-f", os.path.join(dockerDir, "Dockerfile.runtime"), "--target", "router", "."]) +else: + print(f"SKIP build {proxy_image} (already exists)") + +print("Run migration and services") + +os.environ["ENV_EXTENSION"] = "dev" +os.environ["INSTALLATION_TYPE"] = installation_type +os.environ["Baseimage_Dotnet_Run"] = "onlyoffice/4testing-docspace-dotnet-runtime:" + dotnet_version +os.environ["Baseimage_Nodejs_Run"] = "onlyoffice/4testing-docspace-nodejs-runtime:" + node_version +os.environ["Baseimage_Proxy_Run"] = "onlyoffice/4testing-docspace-proxy-runtime:" + proxy_version +os.environ["DOCUMENT_SERVER_IMAGE_NAME"] = document_server_image_name +os.environ["SERVICE_DOCEDITOR"] = doceditor +os.environ["SERVICE_LOGIN"] = login +os.environ["SERVICE_CLIENT"] = client +os.environ["ROOT_DIR"] = dir +os.environ["BUILD_PATH"] = "/var/www" +os.environ["SRC_PATH"] = os.path.join(dir, "publish/services") +os.environ["DATA_DIR"] = os.path.join(dir, "data") +os.environ["APP_URL_PORTAL"] = portal_url +os.environ["MIGRATION_TYPE"] = migration_type +subprocess.run(["docker-compose", "-f", os.path.join(dockerDir, "docspace.profiles.yml"), "-f", os.path.join(dockerDir, "docspace.overcome.yml"), "--profile", "migration-runner", "--profile", "backend-local", "up", "-d"]) + +print() +print("Run script directory:", dir) +print("Root directory:", dir) +print("Docker files root directory:", dockerDir) + +print() +print(f"SERVICE_DOCEDITOR: {doceditor}") +print(f"SERVICE_LOGIN: {login}") +print(f"SERVICE_CLIENT: {client}") +print(f"DOCSPACE_APP_URL: {portal_url}") + +print() +print("FORCE REBUILD BASE IMAGES:", force) +print("Run dnsmasq:", dns) + +print() +print("MIGRATION TYPE:", migration_type) +print("INSTALLATION TYPE:", installation_type) +print("DS image:", document_server_image_name) +print() diff --git a/build.backend.docker.sh b/build.backend.docker.sh deleted file mode 100755 index 7cbc9b17bc..0000000000 --- a/build.backend.docker.sh +++ /dev/null @@ -1,203 +0,0 @@ -#!/bin/bash - -############################################################ -# Help # -############################################################ -Help() -{ - # Display Help - echo "Build and run backend and working environment. (Use 'yarn start' to run client -> https://github.com/ONLYOFFICE/DocSpace-client)" - echo - echo "Syntax: available params [-h|f|s|c|d|]" - echo "options:" - echo "h Print this Help." - echo "f Force rebuild base images." - echo "s Run as SAAS otherwise as STANDALONE." - echo "c Run as COMMUNITY otherwise ENTERPRISE." - echo "d Run dnsmasq." - echo -} - -rd="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" -dir=$(builtin cd $rd/../; pwd) -dockerDir="$dir/buildtools/install/docker" -local_ip=$(ipconfig getifaddr en0) - -doceditor=${local_ip}:5013 -login=${local_ip}:5011 -client=${local_ip}:5001 -portal_url="http://$local_ip" - -force=false -dns=false -standalone=true -community=false - -migration_type="STANDALONE" # SAAS -installation_type=ENTERPRISE -document_server_image_name=onlyoffice/documentserver-de:latest - -# Get the options -while getopts "h:f:s:c:d:" opt; do - echo "argument -${opt} called with parameter $OPTARG" >&2 - case $opt in - h) # Display this Help - Help - exit - ;; - f) # Force rebuild base images - force=${OPTARG:-true} - ;; - s) # Run as STANDALONE (otherwise SAAS) - standalone=${OPTARG:-true} - ;; - c) # Run as COMMUNITY (otherwise ENTERPRISE) - community=${OPTARG:-true} - ;; - d) # Run dnsmasq - dns=${OPTARG:-true} - ;; - \?) # Invalid option - echo "Error: Invalid '-$OPTARG' option" - exit - ;; - esac -done - -echo "Run script directory:" $dir -echo "Root directory:" $dir -echo "Docker files root directory:" $dockerDir - -echo -echo "SERVICE_DOCEDITOR: $doceditor" -echo "SERVICE_LOGIN: $login" -echo "SERVICE_CLIENT: $client" -echo "DOCSPACE_APP_URL: $portal_url" - -echo -echo "FORCE REBUILD BASE IMAGES: $force" -echo "Run dnsmasq: $dns" - -if [ "$standalone" = false ]; then - migration_type="SAAS" -fi - -if [ "$community" = true ]; then - installation_type="COMMUNITY" - document_server_image_name=onlyoffice/documentserver:latest -fi - -echo -echo "MIGRATION TYPE: $migration_type" -echo "INSTALLATION TYPE: $installation_type" -echo "DS image: $document_server_image_name" -echo - -# Stop all backend services" -$dir/buildtools/start/stop.backend.docker.sh - -echo "Run MySQL" - -arch_name="$(uname -m)" - -existsnetwork=$(docker network ls | awk '{print $2;}' | { grep -x onlyoffice || true; }); - -if [[ -z ${existsnetwork} ]]; then - docker network create --driver bridge onlyoffice -fi - -if [ "${arch_name}" = "x86_64" ]; then - echo "CPU Type: x86_64 -> run db.yml" - docker compose -f $dockerDir/db.yml up -d -elif [ "${arch_name}" = "arm64" ]; then - echo "CPU Type: arm64 -> run db.yml with arm64v8 image" - MYSQL_IMAGE=arm64v8/mysql:8.0.32-oracle \ - docker compose -f $dockerDir/db.yml up -d -else - echo "Error: Unknown CPU Type: ${arch_name}." - exit 1 -fi - -if [ "$dns" = true ]; then - echo "Run local dns server" - ROOT_DIR=$dir \ - docker compose -f $dockerDir/dnsmasq.yml up -d -fi - -echo "Clear publish folder" -rm -rf $dir/publish/services - -echo "Build backend services (to "publish/" folder)" -bash $dir/buildtools/install/common/build-services.sh -pb backend-publish -pc Debug -de "$dockerDir/docker-entrypoint.py" - -dotnet_version=dev - -exists=$(docker images | egrep "onlyoffice/4testing-docspace-dotnet-runtime" | egrep "$dotnet_version" | awk 'NR>0 {print $1 ":" $2}') - -if [ "${exists}" = "" ] || [ "$force" = true ]; then - echo "Build dotnet base image from source (apply new dotnet config)" - docker build -t onlyoffice/4testing-docspace-dotnet-runtime:$dotnet_version -f $dockerDir/Dockerfile.runtime --target dotnetrun . -else - echo "SKIP build dotnet base image (already exists)" -fi - -node_version=dev - -exists=$(docker images | egrep "onlyoffice/4testing-docspace-nodejs-runtime" | egrep "$node_version" | awk 'NR>0 {print $1 ":" $2}') - -if [ "${exists}" = "" ] || [ "$force" = true ]; then - echo "Build nodejs base image from source" - docker build -t onlyoffice/4testing-docspace-nodejs-runtime:$node_version -f $dockerDir/Dockerfile.runtime --target noderun . -else - echo "SKIP build nodejs base image (already exists)" -fi - -proxy_version=dev - -exists=$(docker images | egrep "onlyoffice/4testing-docspace-proxy-runtime" | egrep "$proxy_version" | awk 'NR>0 {print $1 ":" $2}') - -if [ "${exists}" = "" ] || [ "$force" = true ]; then - echo "Build proxy base image from source (apply new nginx config)" - docker build -t onlyoffice/4testing-docspace-proxy-runtime:$proxy_version -f $dockerDir/Dockerfile.runtime --target router . -else - echo "SKIP build proxy base image (already exists)" -fi - -echo "Run migration and services" -ENV_EXTENSION="dev" \ -INSTALLATION_TYPE=$installation_type \ -Baseimage_Dotnet_Run="onlyoffice/4testing-docspace-dotnet-runtime:$dotnet_version" \ -Baseimage_Nodejs_Run="onlyoffice/4testing-docspace-nodejs-runtime:$node_version" \ -Baseimage_Proxy_Run="onlyoffice/4testing-docspace-proxy-runtime:$proxy_version" \ -DOCUMENT_SERVER_IMAGE_NAME=$document_server_image_name \ -SERVICE_DOCEDITOR=$doceditor \ -SERVICE_LOGIN=$login \ -SERVICE_CLIENT=$client \ -ROOT_DIR=$dir \ -BUILD_PATH="/var/www" \ -SRC_PATH="$dir/publish/services" \ -DATA_DIR="$dir/data" \ -APP_URL_PORTAL=$portal_url \ -MIGRATION_TYPE=$migration_type \ -docker-compose -f $dockerDir/docspace.profiles.yml -f $dockerDir/docspace.overcome.yml --profile migration-runner --profile backend-local up -d - -echo -echo "Run script directory:" $dir -echo "Root directory:" $dir -echo "Docker files root directory:" $dockerDir - -echo -echo "SERVICE_DOCEDITOR: $doceditor" -echo "SERVICE_LOGIN: $login" -echo "SERVICE_CLIENT: $client" -echo "DOCSPACE_APP_URL: $portal_url" - -echo -echo "FORCE REBUILD BASE IMAGES: $force" -echo "Run dnsmasq: $dns" - -echo -echo "MIGRATION TYPE: $migration_type" -echo "INSTALLATION TYPE: $installation_type" -echo "DS image: $document_server_image_name" -echo diff --git a/clear.backend.docker.bat b/clear.backend.docker.bat deleted file mode 100644 index 7d215cfc09..0000000000 --- a/clear.backend.docker.bat +++ /dev/null @@ -1,7 +0,0 @@ -@echo off - -pwsh %~dp0/clear.backend.docker.ps1 - -echo. - -pause \ No newline at end of file diff --git a/clear.backend.docker.ps1 b/clear.backend.docker.ps1 deleted file mode 100644 index de6f9a2dfd..0000000000 --- a/clear.backend.docker.ps1 +++ /dev/null @@ -1,37 +0,0 @@ -$Containers = docker ps -aqf "name=^onlyoffice" -$Images = docker images onlyoffice/4testing-docspace* -q -$RootDir = Split-Path -Parent $PSScriptRoot -$DockerDir = ($RootDir + "\buildtools\install\docker") - -Write-Host "Clean up containers, volumes or networks" -ForegroundColor Green - -if ($Containers -or $Images) { - Write-Host "Remove all backend containers" -ForegroundColor Blue - - $Env:DOCUMENT_SERVER_IMAGE_NAME="onlyoffice/documentserver-de:latest" - $Env:Baseimage_Dotnet_Run="onlyoffice/4testing-docspace-dotnet-runtime:dev" - $Env:Baseimage_Nodejs_Run="onlyoffice/4testing-docspace-nodejs-runtime:dev" - $Env:Baseimage_Proxy_Run="onlyoffice/4testing-docspace-proxy-runtime:dev" - $Env:SERVICE_CLIENT="localhost:5001" - $Env:BUILD_PATH="/var/www" - $Env:SRC_PATH="$RootDir\publish\services" - $Env:ROOT_DIR=$RootDir - $Env:DATA_DIR="$RootDir\data" - - docker compose -f "$DockerDir\docspace.profiles.yml" -f "$DockerDir\docspace.overcome.yml" --profile "migration-runner" --profile "backend-local" down --volumes - - Write-Host "Remove docker contatiners 'mysql'" -ForegroundColor Blue - docker compose -f "$DockerDir\db.yml" down --volumes - - Write-Host "Remove docker volumes" -ForegroundColor Blue - docker volume prune -f -a - - Write-Host "Remove docker base images (onlyoffice/4testing-docspace)" -ForegroundColor Blue - docker rmi -f $Images - - Write-Host "Remove docker networks" -ForegroundColor Blue - docker network prune -f -} -else { - Write-Host "No containers, images, volumes or networks to clean up" -ForegroundColor Green -} \ No newline at end of file diff --git a/clear.backend.docker.py b/clear.backend.docker.py new file mode 100755 index 0000000000..b4a0d92fca --- /dev/null +++ b/clear.backend.docker.py @@ -0,0 +1,48 @@ +#!/usr/bin/python3 + +import os, sys +import subprocess + +rd = os.path.dirname(os.path.abspath(__file__)) +root_dir = os.path.abspath(os.path.join(rd, "..")) +docker_dir = os.path.join(root_dir, "buildtools", "install", "docker") + +containers = subprocess.check_output(["docker", "ps", "-aq", "-f", "name=^onlyoffice"], encoding='utf-8').strip().split() +images = subprocess.check_output(["docker", "images", "onlyoffice/4testing-docspace*", "-q"], encoding='utf-8').strip().split() + +if containers or images: + print("Clean up containers, volumes or networks") + + print("Remove all backend containers") + + os.environ["Baseimage_Dotnet_Run"] = "onlyoffice/4testing-docspace-dotnet-runtime:dev" + os.environ["Baseimage_Nodejs_Run"] = "onlyoffice/4testing-docspace-nodejs-runtime:dev" + os.environ["Baseimage_Proxy_Run"] = "onlyoffice/4testing-docspace-proxy-runtime:dev" + os.environ["DOCUMENT_SERVER_IMAGE_NAME"] = "onlyoffice/documentserver-de:latest" + os.environ["SERVICE_CLIENT"] = "localhost:5001" + os.environ["ROOT_DIR"] = root_dir + os.environ["BUILD_PATH"] = "/var/www" + os.environ["SRC_PATH"] = os.path.join(root_dir, "publish/services") + os.environ["DATA_DIR"] = os.path.join(root_dir, "data") + subprocess.run(["docker-compose", "-f", os.path.join(docker_dir, "docspace.profiles.yml"), "-f", os.path.join(docker_dir, "docspace.overcome.yml"), "--profile", "migration-runner", "--profile", "backend-local", "down", "--volumes"]) + + print("Remove docker contatiners 'mysql'") + db_command = f"docker compose -f {os.path.join(docker_dir, 'db.yml')} down --volumes" + subprocess.run(db_command, shell=True) + + print("Remove docker volumes") + volumes_command = f"docker volume prune -fa" + subprocess.run(volumes_command, shell=True) + + print("Remove docker base images (onlyoffice/4testing-docspace)") + subprocess.run(['docker', 'rmi', '-f'] + images, check=True) + + print("Remove docker networks") + network_command = f"docker network prune -f" + subprocess.run(network_command, shell=True) + + print("Remove docker build cache") + cache_command = f"docker buildx prune -f" + subprocess.run(cache_command, shell=True) +else: + print("No containers or images to clean up") diff --git a/clear.backend.docker.sh b/clear.backend.docker.sh deleted file mode 100755 index c92bbe5bfd..0000000000 --- a/clear.backend.docker.sh +++ /dev/null @@ -1,38 +0,0 @@ -#!/bin/bash - -Containers=$(docker ps -a | egrep "onlyoffice" | awk 'NR>0 {print $1}') -RunDir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" -RootDir=$(builtin cd $RunDir/../; pwd) -DockerDir="${RootDir}/buildtools/install/docker" - -echo "Clean up containers, volumes or networks" - -if [[ $Containers != "" ]] -then - echo "Remove all backend containers" - - DOCUMENT_SERVER_IMAGE_NAME=onlyoffice/documentserver-de:latest \ - Baseimage_Dotnet_Run="onlyoffice/4testing-docspace-dotnet-runtime:dev" \ - Baseimage_Nodejs_Run="onlyoffice/4testing-docspace-nodejs-runtime:dev" \ - Baseimage_Proxy_Run="onlyoffice/4testing-docspace-proxy-runtime:dev" \ - SERVICE_CLIENT="localhost:5001" \ - BUILD_PATH="/var/www" \ - SRC_PATH="${RootDir}/publish/services" \ - ROOT_DIR=$RootDir \ - DATA_DIR="${RootDir}/data" \ - docker-compose -f "${DockerDir}/docspace.profiles.yml" -f "${DockerDir}/docspace.overcome.yml" --profile migration-runner --profile backend-local down --volumes - - echo "Remove docker contatiners 'mysql'" - docker compose -f "${DockerDir}/db.yml" down --volumes - - echo "Remove docker volumes" - docker volume prune -f -a - - echo "Remove docker base images (onlyoffice/4testing-docspace)" - docker rmi -f $(docker images -a | egrep "onlyoffice/4testing-docspace" | awk 'NR>0 {print $3}') - - echo "Remove unused networks." - docker network prune -f -else - echo "No containers, images, volumes or networks to clean up" -fi diff --git a/config/appsettings.json b/config/appsettings.json index 1096f8727c..1ab6f09de4 100644 --- a/config/appsettings.json +++ b/config/appsettings.json @@ -34,7 +34,10 @@ "oidc": { "authority": "" }, - "server-root": "" + "server-root": "", + "username": { + "regex": "^[\\p{L}\\p{M}' \\-]+$" + } }, "license": { "file": { @@ -415,7 +418,8 @@ "script": ["'self'", "'unsafe-inline'", "'unsafe-eval'"], "style": ["'self'", "'unsafe-inline'"], "img": ["'self'", "data:", "blob:"], - "frame": ["'self'"] + "frame": ["'self'"], + "fonts": ["'self'", "data:"] }, "zendesk": { "def": ["*.zdassets.com", "*.zopim.com", "*.zendesk.com", "wss:"], @@ -427,8 +431,8 @@ "def": ["*.googleapis.com"] }, "oform": { - "img": ["*.onlyoffice.com"], - "def": ["*.onlyoffice.com"] + "img": ["static-oforms.teamlab.info"], + "def": ["cmsoforms.teamlab.info", "oforms.teamlab.info"] } }, "logocolors": [ @@ -462,6 +466,11 @@ "region": "us-east-1", "logGroupName": "/asc/docspace/cluster/cluster_name/general", "logStreamName": "${hostname} - ${applicationContext} - ${date} - ${guid}" + }, + "dynamoDB": { + "accessKeyId": "", + "secretAccessKey": "", + "region": "us-east-1" } } } diff --git a/config/backup.json b/config/backup.json index c3dc289bd2..6e3acf6dc2 100644 --- a/config/backup.json +++ b/config/backup.json @@ -15,8 +15,6 @@ "Cleaner": { "Period":"00:15:00" - }, - "ChunkSize": 524288000, - "MaxLocalSize": 1048576000 + } } } \ No newline at end of file diff --git a/config/nginx/onlyoffice.conf b/config/nginx/onlyoffice.conf index 9a0b7c30d7..8041d92980 100644 --- a/config/nginx/onlyoffice.conf +++ b/config/nginx/onlyoffice.conf @@ -113,7 +113,7 @@ server { if redis_pass ~= "" then local res, err = red:auth(redis_pass) if not res then - ngx.log(ngx.ERR, "failed to authenticate: ", err) + ngx.log(ngx.INFO, "failed to authenticate: ", err) return end end diff --git a/config/nlog.config b/config/nlog.config index f4522c0b2d..e6dfd6ee1a 100644 --- a/config/nlog.config +++ b/config/nlog.config @@ -46,12 +46,12 @@ - + - + diff --git a/config/storage.json b/config/storage.json index 6b9faa8ba6..62245ec012 100644 --- a/config/storage.json +++ b/config/storage.json @@ -41,6 +41,7 @@ "data": "00000000-0000-0000-0000-000000000000", "type": "disc", "path": "$STORAGE_ROOT\\Products\\Files\\logos\\{0}", + "validatorType": "ASC.Files.Core.VirtualRooms.RoomLogoValidator, ASC.Files.Core", "domain": [ { "name": "logos_temp", diff --git a/debuginfo.py b/debuginfo.py new file mode 100755 index 0000000000..a6fc574dcd --- /dev/null +++ b/debuginfo.py @@ -0,0 +1,97 @@ +#!/usr/bin/python3 + +import os +from git import Repo +from datetime import datetime + +rd = os.path.dirname(os.path.abspath(__file__)) +root_dir = os.path.abspath(os.path.join(rd, "..")) + +CLIENT = "client" +SERVER = "server" +BUILDTOOLS = "buildtools" +REPO_CLIENT_URL = f"https://github.com/ONLYOFFICE/DocSpace-client" +REPO_SERVER_URL = f"https://github.com/ONLYOFFICE/DocSpace-server" +REPO_BUILDTOOLS_URL = f"https://github.com/ONLYOFFICE/DocSpace-buildtools" +LIMIT_DAYS = 30 +MESSAGE_SEPARATOR = '__MESSAGE_SEPARATOR__' +SEP = 'ยง' + +# https://git-scm.com/docs/pretty-formats +format = f"%H{SEP}%as{SEP}%an{SEP}%s %b{MESSAGE_SEPARATOR}" + +data = {} + + +def fetchCommits(url, type): + path = os.path.join(root_dir, type) + #print(path, os.path.exists(path)) + if os.path.exists(path) == False: + print("Error folder does not exists", path) + return + + repo = Repo(path) + + info = f"| [DocSpace-{type}]({url}) | [{repo.active_branch.name}]({url}/tree/{repo.active_branch.name}) | [{repo.head.commit}]({url}/commit/{repo.head.commit}) |{os.linesep}" + + commits_str = repo.git.log(f"--pretty=format: {format}", "--no-merges", f"--since={LIMIT_DAYS}.days") + #print(commits_str) + + commits = commits_str.strip().split(MESSAGE_SEPARATOR) + #print(commits) + + for item in commits: + elements = item.replace('\n', '').split(SEP) + + if len(elements) != 4: + continue + + hash = elements[0].strip() + date = datetime.strptime(elements[1].strip(), "%Y-%m-%d") + name = elements[2].strip() + text = elements[3].strip().capitalize() + + if date not in data: + data[date] = {} + + if name not in data[date]: + data[date][name] = [] + + data[date][name].append(f"- [{type}]: {text} [`{hash[0:7]}`]({url}/commit/{hash})") + + return info + +result = f"## Changelog{os.linesep}" + +result += f"| Repo | Branch | Last Commit |{os.linesep}" +result += f"| :- | :- | :- |{os.linesep}" + +result += fetchCommits(REPO_CLIENT_URL, CLIENT) +result += fetchCommits(REPO_SERVER_URL, SERVER) +result += fetchCommits(REPO_BUILDTOOLS_URL, BUILDTOOLS) + +# Create debuginfo.md content +for date in sorted(data, reverse=True): + niceDate = date.strftime("%d %B %Y") + result += f"### {niceDate}{os.linesep}" + for name in sorted(data[date]): + result += f"#### {name}{os.linesep}" + for commit in data[date][name]: + result += f"{commit}{os.linesep}" + +print(result) + +pathMD = os.path.join(root_dir, CLIENT, "public/debuginfo.md") +# Open text file in write mode +text_file = open(pathMD, "w") + +# Write content to file +n = text_file.write(result) + +if n == len(result): + print("Success! String written to text file.") +else: + print("Failure! String not written to text file.") + +# Close file +text_file.close() \ No newline at end of file diff --git a/install/OneClickInstall/install-Docker.sh b/install/OneClickInstall/install-Docker.sh index 519d082620..06159901e1 100644 --- a/install/OneClickInstall/install-Docker.sh +++ b/install/OneClickInstall/install-Docker.sh @@ -491,9 +491,9 @@ while [ "$1" != "" ]; do echo " -ies, --installelastic install or update elasticsearch (true|false)" echo " -espr, --elasticprotocol the protocol for the connection to elasticsearch (default value http)" echo " -esh, --elastichost the IP address or hostname of the elasticsearch" - echo " -esp, --elasticport elasticsearch port number (default value 6379)" + echo " -esp, --elasticport elasticsearch port number (default value 9200)" echo " -rdsh, --redishost the IP address or hostname of the redis server" - echo " -rdsp, --redisport redis server port number (default value 9200)" + echo " -rdsp, --redisport redis server port number (default value 6379)" echo " -rdsu, --redisusername redis user name" echo " -rdspass, --redispassword password set for redis account" echo " -rbth, --rabbitmqhost the IP address or hostname of the rabbitmq server" @@ -947,7 +947,7 @@ domain_check () { echo "Select 'N' to cancel ${PACKAGE_SYSNAME^^} ${PRODUCT_NAME} installation." if read_continue_installation; then if [[ -f "$DOCKER_DAEMON_FILE" ]]; then - sed -i '/{/a\ "dns": ["8.8.8.8", "8.8.4.4"],' "$DOCKER_DAEMON_FILE" + sed -i 's!{!& "dns": ["8.8.8.8", "8.8.4.4"],!' "$DOCKER_DAEMON_FILE" else echo "{\"dns\": [\"8.8.8.8\", \"8.8.4.4\"]}" | tee "$DOCKER_DAEMON_FILE" >/dev/null fi diff --git a/install/common/build-backend.sh b/install/common/build-backend.sh index 87fdcbcd97..c748b3081a 100644 --- a/install/common/build-backend.sh +++ b/install/common/build-backend.sh @@ -42,10 +42,11 @@ done echo "== BACK-END-BUILD ==" -cd ${SRC_PATH} +cd ${SRC_PATH}/server dotnet build ASC.Web.slnf ${ARGS} -dotnet build ASC.Migrations.sln -o ${SRC_PATH}/ASC.Migration.Runner/service/ +dotnet build ASC.Migrations.sln -o ${SRC_PATH}/server/ASC.Migration.Runner/service/ +cd ${SRC_PATH}/client # Array of names backend services in directory common (Nodejs) services_name_backend_nodejs=() services_name_backend_nodejs+=(ASC.Socket.IO) @@ -54,5 +55,5 @@ services_name_backend_nodejs+=(ASC.SsoAuth) # Build backend services (Nodejs) for i in ${!services_name_backend_nodejs[@]}; do echo "== Build ${services_name_backend_nodejs[$i]} project ==" - yarn install --cwd common/${services_name_backend_nodejs[$i]} --frozen-lockfile + yarn install --cwd ${SRC_PATH}/server/common/${services_name_backend_nodejs[$i]} --frozen-lockfile done diff --git a/install/common/build-frontend.sh b/install/common/build-frontend.sh index 9304bae8f2..a5f74e9910 100644 --- a/install/common/build-frontend.sh +++ b/install/common/build-frontend.sh @@ -57,10 +57,12 @@ done echo "== FRONT-END-BUILD ==" cd ${SRC_PATH} -yarn install # debug config if [ "$DEBUG_INFO" = true ]; then - yarn debug-info + pip install -r ${SRC_PATH}/buildtools/requirements.txt + python3 ${SRC_PATH}/buildtools/debuginfo.py fi +cd ${SRC_PATH}/client +yarn install yarn ${BUILD_ARGS} yarn ${DEPLOY_ARGS} diff --git a/install/common/build-services.ps1 b/install/common/build-services.ps1 deleted file mode 100644 index 30dc6f2a39..0000000000 --- a/install/common/build-services.ps1 +++ /dev/null @@ -1,57 +0,0 @@ -$SRC_PATH=(get-item $PSScriptRoot ).parent.parent.parent.FullName -$BUILD_PATH="$SRC_PATH\publish" - -$BACKEND_NODEJS_SERVICES="ASC.Socket.IO","ASC.SsoAuth" -$BACKEND_DOTNETCORE_SERVICES="ASC.Files", "ASC.People", "ASC.Data.Backup", "ASC.Files.Service", "ASC.Notify", "ASC.Studio.Notify", "ASC.Web.Api", "ASC.Web.Studio", "ASC.Data.Backup.BackgroundTasks", "ASC.ClearEvents", "ASC.ApiSystem", "ASC.Web.HealthChecks.UI" -$SELF_CONTAINED="false" -$PUBLISH_CNF="Debug" - -$FRONTEND_BUILD_ARGS="build" -$FRONTEND_DEPLOY_ARGS="deploy" -$DEBUG_INFO_CHECK="" -$MIGRATION_CHECK="true" -$DOCKER_ENTRYPOINT="$SRC_PATH\buildtools\install\docker\docker-entrypoint.py" - -if(Test-Path -Path "$BUILD_PATH\services" ){ - Write-Host "== Clean up services ==" -ForegroundColor Green - Remove-Item "$BUILD_PATH\services" -Recurse -} - -Write-Host "== Build ASC.Web.slnf ==" -ForegroundColor Green -dotnet build "$SRC_PATH\server\ASC.Web.slnf" - -Write-Host "== Build ASC.Migrations.sln ==" -ForegroundColor Green -dotnet build "$SRC_PATH\server\ASC.Migrations.sln" -o "$BUILD_PATH\services\ASC.Migration.Runner\service\" - -Write-Host "== Add docker-migration-entrypoint.sh to ASC.Migration.Runner ==" -ForegroundColor Green -$FilePath = "$BUILD_PATH\services\ASC.Migration.Runner\service\docker-migration-entrypoint.sh" -Get-Content "$SRC_PATH\buildtools\install\docker\docker-migration-entrypoint.sh" -raw | % {$_ -replace "`r", ""} | Set-Content -NoNewline $FilePath - -foreach ($SERVICE in $BACKEND_NODEJS_SERVICES) -{ - Write-Host "== Build $SERVICE project ==" -ForegroundColor Green - yarn install --cwd "$SRC_PATH\server\common\$SERVICE" --frozen-lockfile - - $DST = "$BUILD_PATH\services\$SERVICE\service\" - - if(!(Test-Path -Path $DST )){ - New-Item -ItemType "directory" -Path $DST - } - - Write-Host "== Copy service data to `publish\services\${SERVICE}\service` ==" -ForegroundColor Green - Copy-Item -Path "$SRC_PATH\server\common\$SERVICE\*" -Destination $DST -Recurse - Write-Host "== Add docker-entrypoint.py to $SERVICE ==" -ForegroundColor Green - Copy-Item $DOCKER_ENTRYPOINT -Destination $DST -} - -Write-Host "== Publish ASC.Web.slnf ==" -ForegroundColor Green -dotnet publish "$SRC_PATH\server\ASC.Web.slnf" -p "PublishProfile=FolderProfile" - -Set-Location -Path $PSScriptRoot - -foreach ($SERVICE in $BACKEND_DOTNETCORE_SERVICES) -{ - Write-Host "== Add docker-entrypoint.py to $SERVICE ==" -ForegroundColor Green - $DST = "$BUILD_PATH\services\$SERVICE\service\" - Copy-Item $DOCKER_ENTRYPOINT -Destination $DST -} diff --git a/install/common/build-services.py b/install/common/build-services.py new file mode 100755 index 0000000000..aec3d154cb --- /dev/null +++ b/install/common/build-services.py @@ -0,0 +1,87 @@ +#!/usr/bin/python3 + +import os +import stat +import subprocess +import shutil +import time + +SRC_PATH = os.path.dirname(os.path.dirname(os.path.dirname(os.path.dirname(__file__)))) +BUILD_PATH = os.path.join(SRC_PATH, "publish") + +print(f"SRC_PATH = {SRC_PATH}") +print(f"BUILD_PATH = {BUILD_PATH}") + +BACKEND_NODEJS_SERVICES = ["ASC.Socket.IO", "ASC.SsoAuth"] +BACKEND_DOTNETCORE_SERVICES = ["ASC.Files", "ASC.People", "ASC.Data.Backup", "ASC.Files.Service", "ASC.Notify", "ASC.Studio.Notify", "ASC.Web.Api", "ASC.Web.Studio", "ASC.Data.Backup.BackgroundTasks", "ASC.ClearEvents", "ASC.ApiSystem", "ASC.Web.HealthChecks.UI"] + +DOCKER_ENTRYPOINT="docker-entrypoint.py" +DOCKER_ENTRYPOINT_PATH = os.path.join(SRC_PATH, "buildtools", "install", "docker", DOCKER_ENTRYPOINT) + +if os.path.exists(os.path.join(BUILD_PATH, "services")): + print("== Clean up services ==") + shutil.rmtree(os.path.join(BUILD_PATH, "services")) + +print("== Build ASC.Web.slnf ==") +subprocess.run(["dotnet", "build", os.path.join(SRC_PATH, "server", "ASC.Web.slnf")]) + +print("== Build ASC.Migrations.sln ==") +subprocess.run(["dotnet", "build", os.path.join(SRC_PATH, "server", "ASC.Migrations.sln"), "-o", os.path.join(BUILD_PATH, "services", "ASC.Migration.Runner", "service")]) + +print("== Add docker-migration-entrypoint.sh to ASC.Migration.Runner ==") +file_path = os.path.join(BUILD_PATH, "services", "ASC.Migration.Runner", "service", "docker-migration-entrypoint.sh") +src_file_path = os.path.join(SRC_PATH, "buildtools", "install", "docker", "docker-migration-entrypoint.sh") + +WINDOWS_LINE_ENDING = b'\r\n' +UNIX_LINE_ENDING = b'\n' + +with open(src_file_path, 'rb') as open_file: + content = open_file.read() + +content = content.replace(WINDOWS_LINE_ENDING, UNIX_LINE_ENDING) + +with open(file_path, 'wb') as open_file: + open_file.write(content) + +st = os.stat(file_path) +os.chmod(file_path, st.st_mode | stat.S_IEXEC) + +format = "zip" + +for service in BACKEND_NODEJS_SERVICES: + print(f"== Build {service} project ==") + src = os.path.join(SRC_PATH, "server", "common", service) + subprocess.run(["yarn", "install"], cwd=src, shell=True) + + dst = os.path.join(BUILD_PATH, "services", service, "service") + if not os.path.exists(dst): + os.makedirs(dst, exist_ok=True) + + archive_src = os.path.join(SRC_PATH, "server", "common", service, f"service.{format}") + archive = os.path.join(BUILD_PATH, "services", service, f"service.{format}") + + print("Make service archive", archive_src) + start = time.time() + shutil.make_archive(root_dir=src, format=format, base_name=dst) + end = time.time() + print(f"Took {(end-start)*1000.0} ms") + + print("Unpack service archive", archive) + start = time.time() + shutil.unpack_archive(archive, dst) + end = time.time() + print(f"Took {(end-start)*1000.0} ms") + + print("Remove service archive", archive) + os.remove(archive) + + print(f"== Add docker-entrypoint.py to {service}") + shutil.copyfile(DOCKER_ENTRYPOINT_PATH, os.path.join(dst, DOCKER_ENTRYPOINT)) + +print("== Publish ASC.Web.slnf ==") +subprocess.run(["dotnet", "publish", os.path.join(SRC_PATH, "server", "ASC.Web.slnf"), "-p", "PublishProfile=FolderProfile"]) + +for service in BACKEND_DOTNETCORE_SERVICES: + print(f"== Add {DOCKER_ENTRYPOINT} to {service}") + dst = os.path.join(BUILD_PATH, "services", service, "service") + shutil.copyfile(DOCKER_ENTRYPOINT_PATH, os.path.join(dst, DOCKER_ENTRYPOINT)) diff --git a/install/deb/debian/rules b/install/deb/debian/rules index d86143429a..dacb7ecb8f 100755 --- a/install/deb/debian/rules +++ b/install/deb/debian/rules @@ -50,6 +50,7 @@ override_dh_auto_build: sed 's_\(minlevel=\)"[^"]*"_\1"Warn"_g' -i ${SRC_PATH}/config/nlog.config sed 's_etc/nginx_etc/openresty_g' -i ${SRC_PATH}/config/nginx/*.conf + sed -i 's_$public_root_/var/www/%{product}/public/_' config/nginx/onlyoffice.conf sed 's/teamlab.info/onlyoffice.com/g' -i ${SRC_PATH}/config/autofac.consumers.json json -I -f ${SRC_PATH}/client/public/scripts/config.json -e "this.wrongPortalNameUrl=\"\"" sed -e 's/$$router_host/127.0.0.1/g' -e 's/the_host/host/g' -e 's/the_scheme/scheme/g' -e 's_includes_/etc/openresty/includes_g' -i ${SRC_PATH}/buildtools/install/docker/config/nginx/onlyoffice-proxy*.conf diff --git a/install/docker/Dockerfile.app b/install/docker/Dockerfile.app index 0a2869c6e4..21d7eaa815 100644 --- a/install/docker/Dockerfile.app +++ b/install/docker/Dockerfile.app @@ -28,6 +28,7 @@ RUN apt-get -y update && \ sudo \ locales \ git \ + python3-pip \ npm && \ locale-gen en_US.UTF-8 && \ npm install --global yarn && \ @@ -54,8 +55,8 @@ RUN cd ${SRC_PATH} && \ sed -i "s/\"number\".*,/\"number\": \"${PRODUCT_VERSION}.${BUILD_NUMBER}\",/g" /app/onlyoffice/config/appsettings.json && \ sed -e 's/#//' -i /etc/nginx/conf.d/onlyoffice.conf && \ cd ${SRC_PATH}/buildtools/install/common/ && \ - bash build-frontend.sh -sp "${SRC_PATH}/client" -ba "${BUILD_ARGS}" -da "${DEPLOY_ARGS}" -di "${DEBUG_INFO}" && \ - bash build-backend.sh -sp "${SRC_PATH}/server" && \ + bash build-frontend.sh -sp "${SRC_PATH}" -ba "${BUILD_ARGS}" -da "${DEPLOY_ARGS}" -di "${DEBUG_INFO}" && \ + bash build-backend.sh -sp "${SRC_PATH}" && \ bash publish-backend.sh -pc "${PUBLISH_CNF}" -sp "${SRC_PATH}/server" -bp "${BUILD_PATH}" && \ cp -rf ${SRC_PATH}/server/products/ASC.Files/Server/DocStore ${BUILD_PATH}/products/ASC.Files/server/ && \ rm -rf ${SRC_PATH}/server/common/* && \ @@ -311,7 +312,7 @@ WORKDIR ${BUILD_PATH}/studio/ASC.Web.Studio/ COPY --chown=onlyoffice:onlyoffice docker-entrypoint.py ./docker-entrypoint.py COPY --from=base --chown=onlyoffice:onlyoffice ${BUILD_PATH}/services/ASC.Web.Studio/service/ . -CMD ["ASC.Web.Studio.dll", "ASC.Web.Studio"] +CMD ["ASC.Web.Studio.dll", "ASC.Web.Studio", "core:eventBus:subscriptionClientName=asc_event_bus_webstudio_queue"] ## ASC.Web.HealthChecks.UI ## FROM dotnetrun AS healthchecks diff --git a/install/docker/docker-healthchecks-entrypoint.sh b/install/docker/docker-healthchecks-entrypoint.sh index fecc4a3d88..04dd04ee20 100755 --- a/install/docker/docker-healthchecks-entrypoint.sh +++ b/install/docker/docker-healthchecks-entrypoint.sh @@ -31,6 +31,7 @@ STUDIO_NOTIFY_HOST=${STUDIO_NOTIFY_HOST:-"${CONTAINER_PREFIX}studio-notify:${SER API_HOST=${API_HOST:-"${CONTAINER_PREFIX}api:${SERVICE_PORT}"} STUDIO_HOST=${STUDIO_HOST:-"${CONTAINER_PREFIX}studio:${SERVICE_PORT}"} +sed -i "/\"Name\": \"ASC.ApiCache\"/,/{/d" ${PATH_TO_CONF}/appsettings.json sed -i "s!localhost:5010!${API_SYSTEM_HOST}!g" ${PATH_TO_CONF}/appsettings.json sed -i "s!localhost:5012!${BACKUP_HOST}!g" ${PATH_TO_CONF}/appsettings.json sed -i "s!localhost:5032!${BACKUP_BACKGRUOND_TASKS_HOST}!g" ${PATH_TO_CONF}/appsettings.json diff --git a/install/rpm/SPECS/build.spec b/install/rpm/SPECS/build.spec index 630636104b..de9bcbf3c3 100644 --- a/install/rpm/SPECS/build.spec +++ b/install/rpm/SPECS/build.spec @@ -26,6 +26,7 @@ sed 's_\(minlevel=\)"[^"]*"_\1"Warn"_g' -i config/nlog.config sed 's/teamlab.info/onlyoffice.com/g' -i config/autofac.consumers.json sed 's_etc/nginx_etc/openresty_g' -i config/nginx/*.conf +sed -i 's_$public_root_/var/www/%{product}/public/_' config/nginx/onlyoffice.conf sed -e 's/$router_host/127.0.0.1/g' -e 's/the_host/host/g' -e 's/the_scheme/scheme/g' -e 's_includes_/etc/openresty/includes_g' -i install/docker/config/nginx/onlyoffice-proxy*.conf sed -e '/.pid/d' -e '/temp_path/d' -e 's_etc/nginx_etc/openresty_g' -e 's/\.log/-openresty.log/g' -i install/docker/config/nginx/templates/nginx.conf.template sed -i "s_\(.*root\).*;_\1 \"/var/www/%{product}\";_g" -i install/docker/config/nginx/letsencrypt.conf diff --git a/install/win/DocSpace.aip b/install/win/DocSpace.aip index 0aaaa72022..da79c53627 100644 --- a/install/win/DocSpace.aip +++ b/install/win/DocSpace.aip @@ -1079,7 +1079,7 @@ - + @@ -1254,7 +1254,6 @@ - @@ -1309,6 +1308,7 @@ + @@ -1566,38 +1566,38 @@ - + - + - + - - + + - - - + + + - + - - + + - + diff --git a/install/win/build-batch.bat b/install/win/build-batch.bat index a6fc2dd2e8..b7a8b0f6c4 100644 --- a/install/win/build-batch.bat +++ b/install/win/build-batch.bat @@ -68,6 +68,10 @@ REM echo ######## Remove AWSTarget from nlog.config ######## del /f /q buildtools\install\win\Files\nginx\conf\onlyoffice-login.conf del /f /q buildtools\install\win\Files\nginx\conf\onlyoffice-story.conf +::Remove unused services from HealthCheck | Bug 64516 +%sed% -i "/\"Name\": \"ASC.ApiCache\"/,/{/d" buildtools\install\win\Files\services\ASC.Web.HealthChecks.UI\service\appsettings.json +%sed% -i "/\"Name\": \"ASC.ApiSystem\"/,/{/d" buildtools\install\win\Files\services\ASC.Web.HealthChecks.UI\service\appsettings.json + ::configure nuget.config copy "server\NuGet.config" . /y %sed% -i "s/\.nuget\\packages/server\\.nuget\\packages/g" NuGet.config diff --git a/install/win/tools/DocEditor.xml b/install/win/tools/DocEditor.xml index 99b8557128..ea5eff2e8f 100644 --- a/install/win/tools/DocEditor.xml +++ b/install/win/tools/DocEditor.xml @@ -4,6 +4,7 @@ ONLYOFFICE DocSpace DocEditor RealTime Automatic + false node "{APPDIR}products\ASC.Files\editor\server.js" diff --git a/install/win/tools/Login.xml b/install/win/tools/Login.xml index 82299d38e0..379a6961c2 100644 --- a/install/win/tools/Login.xml +++ b/install/win/tools/Login.xml @@ -4,6 +4,7 @@ ONLYOFFICE DocSpace Login RealTime Automatic + false node "{APPDIR}products\ASC.Login\login\server.js" diff --git a/install/win/tools/Socket.IO.xml b/install/win/tools/Socket.IO.xml index be40e5d953..8377604e7b 100644 --- a/install/win/tools/Socket.IO.xml +++ b/install/win/tools/Socket.IO.xml @@ -4,6 +4,7 @@ ONLYOFFICE DocSpace Socket.IO RealTime Automatic + false node "{APPDIR}services\ASC.Socket.IO\service\server.js" diff --git a/install/win/tools/SsoAuth.xml b/install/win/tools/SsoAuth.xml index 6d46ff54d3..c14532ae75 100644 --- a/install/win/tools/SsoAuth.xml +++ b/install/win/tools/SsoAuth.xml @@ -4,6 +4,7 @@ ONLYOFFICE DocSpace ASC.SsoAuth.Svc RealTime Automatic + false node "{APPDIR}services\ASC.SsoAuth\service\app.js" diff --git a/install/win/utils.vbs b/install/win/utils.vbs index d23642b75e..7a02458a5c 100644 --- a/install/win/utils.vbs +++ b/install/win/utils.vbs @@ -121,7 +121,34 @@ End Function Function SetMACHINEKEY On Error Resume Next - Session.Property("MACHINE_KEY") = RandomString( 12 ) + Dim strFilePath, strJSON, strPattern, objRegExp, objMatches + + ' Specify the path to your JSON file + strFilePath = Session.Property("APPDIR") & "config\appsettings.production.json" + + ' Read the JSON content + Set objFSO = CreateObject("Scripting.FileSystemObject") + Set objFile = objFSO.OpenTextFile(strFilePath, 1) + strJSON = objFile.ReadAll + objFile.Close + + ' Define the regular expression pattern to match the "machinekey" value + strPattern = """machinekey"": ""([^""]+)""" + + ' Create a regular expression object and execute the pattern on the JSON string + Set objRegExp = New RegExp + objRegExp.Global = False + objRegExp.IgnoreCase = True + objRegExp.Pattern = strPattern + + Set objMatches = objRegExp.Execute(strJSON) + + ' Check if a match was found + If objMatches.Count > 0 Then + Session.Property("MACHINE_KEY") = objMatches(0).Submatches(0) + Else + Session.Property("MACHINE_KEY") = RandomString(16) + End If End Function diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000000..edc51ee8c8 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,3 @@ +gitdb==4.0.11 +GitPython==3.1.40 +smmap==5.0.1 diff --git a/run.translations.tests.sh b/run.translations.tests.sh index 82c630b53e..ced8d7652e 100755 --- a/run.translations.tests.sh +++ b/run.translations.tests.sh @@ -5,4 +5,4 @@ dir=$(builtin cd $rd/../; pwd) echo "Root directory:" $dir -dotnet test $dir/client/common/Tests/Frontend.Translations.Tests/Frontend.Translations.Tests.csproj --filter "TestCategory=Locales" -l:html --results-directory "$dir/TestsResults" --environment "BASE_DIR=$dir" \ No newline at end of file +dotnet test $dir/client/common/Tests/Frontend.Translations.Tests/Frontend.Translations.Tests.csproj --filter "TestCategory=Locales" -l:html --results-directory "$dir/TestsResults" --environment "BASE_DIR=$dir/client" \ No newline at end of file diff --git a/start/restart.backend.docker.bat b/start/restart.backend.docker.bat deleted file mode 100644 index 464988e1fd..0000000000 --- a/start/restart.backend.docker.bat +++ /dev/null @@ -1,7 +0,0 @@ -@echo off - -pwsh %~dp0/restart.backend.docker.ps1 %* - -echo. - -pause \ No newline at end of file diff --git a/start/restart.backend.docker.ps1 b/start/restart.backend.docker.ps1 deleted file mode 100644 index c42a57a008..0000000000 --- a/start/restart.backend.docker.ps1 +++ /dev/null @@ -1,5 +0,0 @@ -# Stop all backend services" -& "$PSScriptRoot\stop.backend.docker.ps1" - -# Start all backend services" -& "$PSScriptRoot\start.backend.docker.ps1" \ No newline at end of file diff --git a/start/restart.backend.docker.py b/start/restart.backend.docker.py new file mode 100644 index 0000000000..534fc24a60 --- /dev/null +++ b/start/restart.backend.docker.py @@ -0,0 +1,16 @@ +#!/usr/bin/python3 + +import subprocess +import time +import os + +rd = os.path.dirname(__file__) + +start = time.time() + +print("Restart all backend services (containers)") +subprocess.run(["python", os.path.join(rd, "stop.backend.docker.py")]) +subprocess.run(["python", os.path.join(rd, "start.backend.docker.py")]) + +end = time.time() +print("\nElapsed time", end - start) \ No newline at end of file diff --git a/start/restart.backend.docker.sh b/start/restart.backend.docker.sh deleted file mode 100755 index 4edfe6df43..0000000000 --- a/start/restart.backend.docker.sh +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/bash - -dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" -echo "Root directory:" $dir - -$dir/stop.backend.docker.sh - -$dir/start.backend.docker.sh \ No newline at end of file diff --git a/start/start.backend.docker.bat b/start/start.backend.docker.bat deleted file mode 100644 index 090dcdb495..0000000000 --- a/start/start.backend.docker.bat +++ /dev/null @@ -1,7 +0,0 @@ -@echo off - -pwsh %~dp0/start.backend.docker.ps1 %* - -echo. - -pause \ No newline at end of file diff --git a/start/start.backend.docker.ps1 b/start/start.backend.docker.ps1 deleted file mode 100644 index fdf9bda954..0000000000 --- a/start/start.backend.docker.ps1 +++ /dev/null @@ -1,32 +0,0 @@ -$PSversionMajor = $PSVersionTable.PSVersion | sort-object major | ForEach-Object { $_.major } -$PSversionMinor = $PSVersionTable.PSVersion | sort-object minor | ForEach-Object { $_.minor } - -if ($PSversionMajor -lt 7 -or $PSversionMinor -lt 2) { - Write-Error "Powershell version must be greater than or equal to 7.2." - exit -} - -$RootDir = Split-Path (Split-Path -Parent $PSScriptRoot) -Parent -$DockerDir = ($RootDir + "\buildtools\install\docker") -$LocalIp = (Get-CimInstance -ClassName Win32_NetworkAdapterConfiguration | Where-Object { $_.DHCPEnabled -ne $null -and $_.DefaultIPGateway -ne $null }).IPAddress | Select-Object -First 1 - -$Doceditor = ($LocalIp + ":5013") -$Login = ($LocalIp + ":5011") -$Client = ($LocalIp + ":5001") - -Set-Location -Path $DockerDir - -Write-Host "Start all services (containers)" -ForegroundColor Green -$Env:ENV_EXTENSION="dev" -$Env:Baseimage_Dotnet_Run="onlyoffice/4testing-docspace-dotnet-runtime:v1.0.0" -$Env:Baseimage_Nodejs_Run="onlyoffice/4testing-docspace-nodejs-runtime:v1.0.0" -$Env:Baseimage_Proxy_Run="onlyoffice/4testing-docspace-proxy-runtime:v1.0.0" -$Env:DOCUMENT_SERVER_IMAGE_NAME="onlyoffice/documentserver-de:latest" -$Env:SERVICE_DOCEDITOR=$Doceditor -$Env:SERVICE_LOGIN=$Login -$Env:SERVICE_CLIENT=$Client -$Env:ROOT_DIR=$RootDir -$Env:BUILD_PATH="/var/www" -$Env:SRC_PATH="$RootDir\publish\services" -$Env:DATA_DIR="$RootDir\data" -docker compose -f docspace.profiles.yml -f docspace.overcome.yml --profile migration-runner --profile backend-local start \ No newline at end of file diff --git a/start/start.backend.docker.py b/start/start.backend.docker.py new file mode 100644 index 0000000000..7ba4b52ac8 --- /dev/null +++ b/start/start.backend.docker.py @@ -0,0 +1,15 @@ +#!/usr/bin/python3 + +import subprocess +import time + +start = time.time() +container_ids = subprocess.check_output(["docker", "ps", "-aq", "-f", "label=com.docker.compose.project=docker"], encoding='utf-8') +containers = container_ids.strip().split() + +if containers: + print("Start all backend services (containers)") + subprocess.run(['docker', 'start'] + containers, check=True) + +end = time.time() +print("\nElapsed time", end - start) \ No newline at end of file diff --git a/start/start.backend.docker.sh b/start/start.backend.docker.sh deleted file mode 100755 index dd78fdda2b..0000000000 --- a/start/start.backend.docker.sh +++ /dev/null @@ -1,41 +0,0 @@ -#!/bin/bash - - -rd="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" -echo "Run script directory:" $dir - -dir=$(builtin cd $rd/../../; pwd) - -echo "Root directory:" $dir - -cd $dir/buildtools/install/docker/ - -docker_dir="$( pwd )" - -echo "Docker directory:" $docker_dir - -local_ip=$(ipconfig getifaddr en0) - -echo "LOCAL IP: $local_ip" - -doceditor=${local_ip}:5013 -login=${local_ip}:5011 -client=${local_ip}:5001 - -echo "SERVICE_DOCEDITOR: $doceditor" -echo "SERVICE_LOGIN: $login" -echo "SERVICE_CLIENT: $client" - -Baseimage_Dotnet_Run="onlyoffice/4testing-docspace-dotnet-runtime:v1.0.0" \ -Baseimage_Nodejs_Run="onlyoffice/4testing-docspace-nodejs-runtime:v1.0.0" \ -Baseimage_Proxy_Run="onlyoffice/4testing-docspace-proxy-runtime:v1.0.0" \ -BUILD_PATH="/var/www" \ -SRC_PATH="$dir/publish/services" \ -SERVICE_DOCEDITOR=$doceditor \ -SERVICE_LOGIN=$login \ -SERVICE_CLIENT=$client \ -ROOT_DIR=$dir \ -DATA_DIR="$dir/data" \ -ENV_EXTENSION="dev" \ -DOCUMENT_SERVER_IMAGE_NAME=onlyoffice/documentserver-de:latest \ -docker-compose -f docspace.profiles.yml -f docspace.overcome.yml --profile backend-local start diff --git a/start/stop.backend.docker.bat b/start/stop.backend.docker.bat deleted file mode 100644 index c68a50e400..0000000000 --- a/start/stop.backend.docker.bat +++ /dev/null @@ -1,7 +0,0 @@ -@echo off - -pwsh %~dp0/stop.backend.docker.ps1 - -echo. - -pause \ No newline at end of file diff --git a/start/stop.backend.docker.ps1 b/start/stop.backend.docker.ps1 deleted file mode 100644 index b62cc6f7ea..0000000000 --- a/start/stop.backend.docker.ps1 +++ /dev/null @@ -1,17 +0,0 @@ -$PSversionMajor = $PSVersionTable.PSVersion | sort-object major | ForEach-Object { $_.major } -$PSversionMinor = $PSVersionTable.PSVersion | sort-object minor | ForEach-Object { $_.minor } - -if ($PSversionMajor -lt 7 -or $PSversionMinor -lt 2) { - Write-Error "Powershell version must be greater than or equal to 7.2." - exit -} - -$Containers = docker ps -a -f "name=^onlyoffice" --format="{{.ID}} {{.Names}}" | Select-String -Pattern ("mysql|rabbitmq|redis|elasticsearch|documentserver") -NotMatch | ConvertFrom-String | ForEach-Object P1 - -if (-not $Containers) { - Write-Host "No containers to stop" -ForegroundColor Blue - exit -} - -Write-Host "Stop all backend services (containers)" -ForegroundColor Green -docker stop $Containers \ No newline at end of file diff --git a/start/stop.backend.docker.py b/start/stop.backend.docker.py new file mode 100755 index 0000000000..574c0746a5 --- /dev/null +++ b/start/stop.backend.docker.py @@ -0,0 +1,17 @@ +#!/usr/bin/python3 + +import subprocess +import time + +start = time.time() +container_ids = subprocess.check_output(["docker", "ps", "-q", "-f", "label=com.docker.compose.project=docker"], encoding='utf-8') +containers = container_ids.strip().split() + +if containers: + print("Stop all backend services (containers)") + subprocess.run(['docker', 'stop'] + containers, check=True) +else: + print("No containers to stop") + +end = time.time() +print("\nElapsed time", end - start) diff --git a/start/stop.backend.docker.sh b/start/stop.backend.docker.sh deleted file mode 100755 index 6a6154bf38..0000000000 --- a/start/stop.backend.docker.sh +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/bash - -echo "Stop all backend services (containers)" -docker stop $(docker ps -a | egrep "onlyoffice" | egrep -v "mysql|rabbitmq|redis|elasticsearch|documentserver" | awk 'NR>0 {print $1}') \ No newline at end of file