Merge pull request #45 from ONLYOFFICE/feature/new-scripts-docker-dev-python

Feature/new scripts docker dev python
This commit is contained in:
Alexey Safronov 2023-11-08 18:36:43 +04:00 committed by GitHub
commit 18cbf19a71
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
22 changed files with 384 additions and 610 deletions

View File

@ -1,7 +0,0 @@
@echo off
pwsh %~dp0/build.backend.docker.ps1 %*
echo.
pause

View File

@ -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

201
build.backend.docker.py Executable file
View File

@ -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()

View File

@ -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

View File

@ -1,7 +0,0 @@
@echo off
pwsh %~dp0/clear.backend.docker.ps1
echo.
pause

View File

@ -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
}

48
clear.backend.docker.py Executable file
View File

@ -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")

View File

@ -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

View File

@ -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
}

View File

@ -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))

View File

@ -1,7 +0,0 @@
@echo off
pwsh %~dp0/restart.backend.docker.ps1 %*
echo.
pause

View File

@ -1,5 +0,0 @@
# Stop all backend services"
& "$PSScriptRoot\stop.backend.docker.ps1"
# Start all backend services"
& "$PSScriptRoot\start.backend.docker.ps1"

View File

@ -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)

View File

@ -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

View File

@ -1,7 +0,0 @@
@echo off
pwsh %~dp0/start.backend.docker.ps1 %*
echo.
pause

View File

@ -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

View File

@ -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)

View File

@ -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

View File

@ -1,7 +0,0 @@
@echo off
pwsh %~dp0/stop.backend.docker.ps1
echo.
pause

View File

@ -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

17
start/stop.backend.docker.py Executable file
View File

@ -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)

View File

@ -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}')