Merge pull request #1076 from ONLYOFFICE/feature/win-docker

Feature/win docker
This commit is contained in:
Alexey Safronov 2022-11-23 19:43:52 +03:00 committed by GitHub
commit 5e8ffb9585
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
20 changed files with 250 additions and 97 deletions

1
.gitignore vendored
View File

@ -50,4 +50,3 @@ TestsResults/
**/.yarn/cache
**/.yarn/install-state.gz
config/appsettings.dev.json

View File

@ -0,0 +1,81 @@
$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
}
$Branch = git branch --show-current
$BranchExistRemote = git ls-remote --heads origin $Branch
if (-not $BranchExistRemote) {
Write-Error "The current branch does not exist in the remote repository. Please push changes."
exit
}
$RootDir = Split-Path -Parent $PSScriptRoot
$DockerDir = ($RootDir + "\build\install\docker")
$BuildDate = Get-Date -Format "yyyy-MM-dd"
$LocalIp = (Get-WmiObject -Class 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")
$DockerFile = "Dockerfile.dev"
$EnvExtension = "dev"
$CoreBaseDomain = "localhost"
# Stop all backend services"
& "$PSScriptRoot\start\stop.backend.docker.ps1"
$Env:COMPOSE_IGNORE_ORPHANS = "True"
$Containers = docker ps -a -f "name=^onlyoffice" --format="{{.ID}} {{.Names}}" | Select-String -Pattern ("mysql|rabbitmq|redis|elasticsearch|documentserver") -NotMatch | ConvertFrom-String | ForEach-Object P1
$Images = docker images onlyoffice/docspace* -q
if ($Containers) {
Write-Host "Remove all backend containers" -ForegroundColor Blue
docker rm -f $Containers
}
if ($Images) {
Write-Host "Remove all docker images except 'mysql, rabbitmq, redis, elasticsearch, documentserver'" -ForegroundColor Blue
docker rmi -f $Images
}
Write-Host "Run MySQL" -ForegroundColor Green
docker compose -f ($DockerDir + "\db.yml") up -d
Write-Host "Run environments (redis, rabbitmq)" -ForegroundColor Green
$Env:DOCKERFILE = $DockerFile
docker compose -f ($DockerDir + "\redis.yml") -f ($DockerDir + "\rabbitmq.yml") up -d
if ($args[0] -eq "--no_ds") {
Write-Host "SKIP Document server" -ForegroundColor Blue
}
else {
Write-Host "Run Document server" -ForegroundColor Green
$Env:DOCUMENT_SERVER_IMAGE_NAME = "onlyoffice/documentserver-de:latest"
$Env:ROOT_DIR = $RootDir
docker compose -f ($DockerDir + "\ds.dev.yml") up -d
}
Write-Host "Build all backend services" -ForegroundColor Blue
$Env:DOCKERFILE = $DockerFile
$Env:RELEASE_DATE = $BuildDate
$Env:GIT_BRANCH = $Branch
$Env:SERVICE_DOCEDITOR = $Doceditor
$Env:SERVICE_LOGIN = $Login
$Env:SERVICE_CLIENT = $Client
$Env:APP_CORE_BASE_DOMAIN = $CoreBaseDomain
$Env:ENV_EXTENSION = $EnvExtension
docker compose -f ($DockerDir + "\build.dev.yml") build --build-arg GIT_BRANCH=$Branch --build-arg RELEASE_DATE=$BuildDate
Write-Host "Run DB migration" -ForegroundColor Green
$Env:DOCKERFILE = $DockerFile
docker compose -f ($DockerDir + "\migration-runner.yml") up -d
# Start all backend services"
& "$PSScriptRoot\start\start.backend.docker.ps1"

View File

@ -9,10 +9,17 @@ echo "Root directory:" $dir
cd $dir
branch=$(git branch | sed -n -e 's/^\* \(.*\)/\1/p')
branch=$(git branch --show-current)
echo "GIT_BRANCH:" $branch
branch_exist_remote=$(git ls-remote --heads origin $branch)
if [ -z "$branch_exist_remote" ]; then
echo "The current branch does not exist in the remote repository. Please push changes."
exit 1
fi
cd $dir/build/install/docker/
docker_dir="$( pwd )"
@ -43,11 +50,9 @@ $dir/build/start/stop.backend.docker.sh
echo "Remove all backend containers"
docker rm -f $(docker ps -a | egrep "onlyoffice" | egrep -v "mysql|rabbitmq|redis|elasticsearch|documentserver" | awk 'NR>0 {print $1}')
echo "Remove all backend images"
docker rmi -f $(docker images -a | egrep "onlyoffice" | egrep -v "mysql|rabbitmq|redis|elasticsearch|documentserver" | awk 'NR>0 {print $3}')
echo "Remove all docker images except 'mysql, rabbitmq, redis, elasticsearch, documentserver'"
docker image rm -f $(docker images -a | egrep "onlyoffice" | egrep -v "mysql|rabbitmq|redis|elasticsearch|documentserver" | awk 'NR>0 {print $3}')
docker rmi -f $(docker images -a | egrep "onlyoffice" | egrep -v "mysql|rabbitmq|redis|elasticsearch|documentserver" | awk 'NR>0 {print $3}')
echo "Run MySQL"
@ -58,7 +63,7 @@ if [ "${arch_name}" = "x86_64" ]; then
docker compose -f db.yml up -d
elif [ "${arch_name}" = "arm64" ]; then
echo "CPU Type: arm64 -> run db.yml with arm64v8 image"
MYSQL_IMAGE=arm64v8/mysql:oracle \
MYSQL_IMAGE=arm64v8/mysql:8.0.31-oracle \
docker compose -f db.yml up -d
else
echo "Error: Unknown CPU Type: ${arch_name}."

9
build/build.docker.bat Normal file
View File

@ -0,0 +1,9 @@
@echo off
if %errorlevel% == 0 (
pwsh %~dp0/build.backend.docker.ps1 "start"
)
echo.
pause

View File

@ -0,0 +1,21 @@
$Containers = docker ps -aqf "name=^onlyoffice"
$Images = docker images onlyoffice/docspace* -q
if ($Containers) {
Write-Host "Stop all backend containers" -ForegroundColor Blue
docker stop $Containers
Write-Host "Remove all backend containers" -ForegroundColor Blue
docker rm -f $Containers
}
if ($Images) {
Write-Host "Remove all docker images except 'mysql, rabbitmq, redis, elasticsearch, documentserver'" -ForegroundColor Blue
docker rmi -f $Images
}
Write-Host "Remove unused volumes." -ForegroundColor Blue
docker volume prune -f
Write-Host "Remove unused networks." -ForegroundColor Blue
docker network prune -f

View File

@ -5,7 +5,7 @@
DOCKER_IMAGE_PREFIX=${STATUS}docspace
DOCKER_TAG=latest
CONTAINER_PREFIX=${PRODUCT}-
MYSQL_VERSION=8.0.18
MYSQL_VERSION=8.0.31
MYSQL_IMAGE=mysql:${MYSQL_VERSION}
ELK_VERSION=7.13.1
SERVICE_PORT=5050

View File

@ -319,26 +319,7 @@ ARG SRC_PATH
ENV BUILD_PATH=${BUILD_PATH}
ENV SRC_PATH=${SRC_PATH}
WORKDIR ${BUILD_PATH}/services/ASC.Migration.Runner/
COPY ./docker-migration-entrypoint.sh ./docker-migration-entrypoint.sh
COPY docker-migration-entrypoint.sh docker-migration-entrypoint.sh
COPY --from=base ${SRC_PATH}/ASC.Migration.Runner/service/ .
ENTRYPOINT ["./docker-migration-entrypoint.sh"]
## image for k8s bin-share ##
FROM busybox:latest AS bin_share
RUN mkdir -p /app/appserver/ASC.Files/server && \
mkdir -p /app/appserver/ASC.People/server/ && \
addgroup --system --gid 107 onlyoffice && \
adduser -u 104 onlyoffice --home /var/www/onlyoffice --system -G onlyoffice
COPY bin-share-docker-entrypoint.sh /app/docker-entrypoint.sh
COPY --from=base /var/www/products/ASC.Files/server/ /app/appserver/ASC.Files/server/
COPY --from=base /var/www/products/ASC.People/server/ /app/appserver/ASC.People/server/
ENTRYPOINT ["./app/docker-entrypoint.sh"]
## image for k8s wait-bin-share ##
FROM busybox:latest AS wait_bin_share
RUN mkdir /app
COPY wait-bin-share-docker-entrypoint.sh /app/docker-entrypoint.sh
ENTRYPOINT ["./app/docker-entrypoint.sh"]

View File

@ -1,6 +1,5 @@
version: "3.8"
x-service:
&x-service-base
x-service: &x-service-base
container_name: base
restart: always
expose:
@ -206,8 +205,8 @@ services:
networks:
default:
external:
name: ${NETWORK_NAME}
external: true
volumes:
es_data:

View File

@ -120,20 +120,6 @@ services:
target: webhooks-service
image: "${REPO}/${DOCKER_IMAGE_PREFIX}-webhooks-service:${DOCKER_TAG}"
onlyoffice-bin-share:
build:
context: ./
dockerfile: "${DOCKERFILE}"
target: bin_share
image: "${REPO}/${DOCKER_IMAGE_PREFIX}-bin-share:${DOCKER_TAG}"
onlyoffice-wait-bin-share:
build:
context: ./
dockerfile: "${DOCKERFILE}"
target: wait_bin_share
image: "${REPO}/${DOCKER_IMAGE_PREFIX}-wait-bin-share:${DOCKER_TAG}"
onlyoffice-proxy:
build:
context: ./

View File

@ -196,8 +196,8 @@ services:
networks:
default:
external:
name: ${NETWORK_NAME}
external: true
volumes:
es_data:

View File

@ -13,5 +13,5 @@ services:
networks:
default:
external:
name: ${NETWORK_NAME}
external: true

View File

@ -1,2 +1,3 @@
#!/bin/sh
envsubst '$MAP_HASH_BUCKET_SIZE,$COUNT_WORKER_CONNECTIONS' < /etc/nginx/nginx.conf.template > /etc/nginx/nginx.conf

View File

@ -1,4 +1,4 @@
version: '3'
version: "3"
services:
onlyoffice-rabbitmq:
image: rabbitmq:3
@ -9,5 +9,5 @@ services:
- "80"
networks:
default:
external:
name: ${NETWORK_NAME}
external: true

View File

@ -1,4 +1,4 @@
version: '3'
version: "3"
services:
onlyoffice-redis:
image: redis:7
@ -8,5 +8,5 @@ services:
- "6379"
networks:
default:
external:
name: ${NETWORK_NAME}
external: true

View File

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

View File

@ -0,0 +1,41 @@
$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
}
$Branch = git branch --show-current
$BranchExistRemote = git ls-remote --heads origin $Branch
if (-not $BranchExistRemote) {
Write-Error "The current branch does not exist in the remote repository. Please push changes."
exit
}
$RootDir = Split-Path (Split-Path -Parent $PSScriptRoot) -Parent
$DockerDir = ($RootDir + "\build\install\docker")
$BuildDate = Get-Date -Format "yyyy-MM-dd"
$LocalIp = (Get-WmiObject -Class 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")
$DockerFile = "Dockerfile.dev"
$EnvExtension = "dev"
$CoreBaseDomain = "localhost"
Write-Host "Start all backend services (containers)" -ForegroundColor Green
$Env:DOCKERFILE = $DockerFile
$Env:ROOT_DIR = $RootDir
$Env:RELEASE_DATE = $BuildDate
$Env:GIT_BRANCH = $Branch
$Env:SERVICE_DOCEDITOR = $Doceditor
$Env:SERVICE_LOGIN = $Login
$Env:SERVICE_CLIENT = $Client
$Env:APP_CORE_BASE_DOMAIN = $CoreBaseDomain
$Env:APP_URL_PORTAL = ("http://" + $LocalIp + ":8092")
$Env:ENV_EXTENSION = $EnvExtension
docker compose -f ($DockerDir + "\docspace.dev.yml") up -d

View File

@ -9,10 +9,17 @@ echo "Root directory:" $dir
cd $dir
branch=$(git branch | sed -n -e 's/^\* \(.*\)/\1/p')
branch=$(git branch --show-current)
echo "GIT_BRANCH:" $branch
branch_exist_remote=$(git ls-remote --heads origin $branch)
if [ -z "$branch_exist_remote" ]; then
echo "The current branch does not exist in the remote repository. Please push changes."
exit 1
fi
cd $dir/build/install/docker/
docker_dir="$( pwd )"

View File

@ -0,0 +1,17 @@
$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

View File

@ -0,0 +1 @@
{}