Merge branch 'develop' into hotfix/v5.4.2

This commit is contained in:
Alexey Golubev 2019-11-29 15:16:41 +03:00 committed by GitHub
commit f4c0bd13b2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 334 additions and 37 deletions

44
.travis.yml Normal file
View file

@ -0,0 +1,44 @@
language: generic
dist: trusty
env:
# postgresql
- config: postgres.yml
# custom values
- config: postgres.yml
DB_NAME: mydb
DB_USER: myuser
DB_PWD: password
POSTGRES_DB: mydb
POSTGRES_USER: myuser
# deprecated variables
- config: postgres-old.yml
POSTGRESQL_SERVER_HOST: onlyoffice-postgresql
POSTGRESQL_SERVER_PORT: 5432
POSTGRESQL_SERVER_DB_NAME: onlyoffice
POSTGRESQL_SERVER_USER: onlyoffice
POSTGRESQL_SERVER_PASS: onlyoffice
# mysql
- config: mysql.yml
DB_TYPE: mysql
DB_HOST: onlyoffice-mysql
DB_PORT: 3306
# activemq
- config: activemq.yml
AMQP_SERVER_TYPE: activemq
AMQP_SERVER_URL: amqp://guest:guest@onlyoffice-activemq
services:
- docker
script:
# Go to tests dir
- cd ${PWD}/tests
# Run test.
- ./test.sh

View file

@ -29,6 +29,7 @@ RUN echo "#!/bin/sh\nexit 0" > /usr/sbin/policy-rc.d && \
libxml2 \
libxss1 \
libxtst6 \
mysql-client \
nano \
net-tools \
netcat \
@ -44,6 +45,7 @@ RUN echo "#!/bin/sh\nexit 0" > /usr/sbin/policy-rc.d && \
supervisor \
xvfb \
zlib1g && \
echo "SERVER_ADDITIONAL_ERL_ARGS=\"+S 1:1\"" | tee -a /etc/rabbitmq/rabbitmq-env.conf && \
sudo -u postgres psql -c "CREATE DATABASE $ONLYOFFICE_VALUE;" && \
sudo -u postgres psql -c "CREATE USER $ONLYOFFICE_VALUE WITH password '$ONLYOFFICE_VALUE';" && \
sudo -u postgres psql -c "GRANT ALL privileges ON DATABASE $ONLYOFFICE_VALUE TO $ONLYOFFICE_VALUE;" && \

View file

@ -162,11 +162,12 @@ Below is the complete list of parameters that can be set using environment varia
- **SSL_KEY_PATH**: The path to the SSL certificate's private key. Defaults to `/var/www/onlyoffice/Data/certs/onlyoffice.key`.
- **SSL_DHPARAM_PATH**: The path to the Diffie-Hellman parameter. Defaults to `/var/www/onlyoffice/Data/certs/dhparam.pem`.
- **SSL_VERIFY_CLIENT**: Enable verification of client certificates using the `CA_CERTIFICATES_PATH` file. Defaults to `false`
- **POSTGRESQL_SERVER_HOST**: The IP address or the name of the host where the PostgreSQL server is running.
- **POSTGRESQL_SERVER_PORT**: The PostgreSQL server port number.
- **POSTGRESQL_SERVER_DB_NAME**: The name of a PostgreSQL database to be created on the image startup.
- **POSTGRESQL_SERVER_USER**: The new user name with superuser permissions for the PostgreSQL account.
- **POSTGRESQL_SERVER_PASS**: The password set for the PostgreSQL account.
- **DB_TYPE**: The database type. Supported values are `postgres`, `mariadb` or `mysql`. Defaults to `postgres`.
- **DB_HOST**: The IP address or the name of the host where the database server is running.
- **DB_PORT**: The database server port number.
- **DB_NAME**: The name of a database to be created on the image startup.
- **DB_USER**: The new user name with superuser permissions for the database account.
- **DB_PWD**: The password set for the database account.
- **AMQP_SERVER_URL**: The [AMQP URL](http://www.rabbitmq.com/uri-spec.html "RabbitMQ URI Specification") to connect to message broker server.
- **AMQP_SERVER_TYPE**: The message broker type. Supported values are `rabbitmq` or `activemq`. Defaults to `rabbitmq`.
- **REDIS_SERVER_HOST**: The IP address or the name of the host where the Redis server is running.
@ -176,6 +177,7 @@ Below is the complete list of parameters that can be set using environment varia
- **JWT_ENABLED**: Specifies the enabling the JSON Web Token validation by the ONLYOFFICE Document Server. Defaults to `false`.
- **JWT_SECRET**: Defines the secret key to validate the JSON Web Token in the request to the ONLYOFFICE Document Server. Defaults to `secret`.
- **JWT_HEADER**: Defines the http header that will be used to send the JSON Web Token. Defaults to `Authorization`.
- **JWT_IN_BODY**: Specifies the enabling the token validation in the request body to the ONLYOFFICE Document Server. Defaults to `false`.
## Installing ONLYOFFICE Document Server integrated with Community and Mail Servers

View file

@ -5,10 +5,11 @@ services:
image: onlyoffice/documentserver:latest
environment:
- ONLYOFFICE_DATA_CONTAINER=true
- POSTGRESQL_SERVER_HOST=onlyoffice-postgresql
- POSTGRESQL_SERVER_PORT=5432
- POSTGRESQL_SERVER_DB_NAME=onlyoffice
- POSTGRESQL_SERVER_USER=onlyoffice
- DB_TYPE=postgres
- DB_HOST=onlyoffice-postgresql
- DB_PORT=5432
- DB_NAME=onlyoffice
- DB_USER=onlyoffice
- AMQP_SERVER_URL=amqp://guest:guest@onlyoffice-rabbitmq
- REDIS_SERVER_HOST=onlyoffice-redis
- REDIS_SERVER_PORT=6379
@ -16,6 +17,7 @@ services:
#- JWT_ENABLED=true
#- JWT_SECRET=secret
#- JWT_HEADER=Authorization
#- JWT_IN_BODY=true
stdin_open: true
restart: always
networks:

View file

@ -38,6 +38,7 @@ NGINX_WORKER_CONNECTIONS=${NGINX_WORKER_CONNECTIONS:-$(ulimit -n)}
JWT_ENABLED=${JWT_ENABLED:-false}
JWT_SECRET=${JWT_SECRET:-secret}
JWT_HEADER=${JWT_HEADER:-Authorization}
JWT_IN_BODY=${JWT_IN_BODY:-false}
ONLYOFFICE_DEFAULT_CONFIG=${CONF_DIR}/local.json
ONLYOFFICE_LOG4JS_CONFIG=${CONF_DIR}/log4js/production.json
@ -57,11 +58,32 @@ PGDATA=${PG_ROOT}/${PG_VERSION}/${PG_NAME}
PG_NEW_CLUSTER=false
read_setting(){
POSTGRESQL_SERVER_HOST=${POSTGRESQL_SERVER_HOST:-$(${JSON} services.CoAuthoring.sql.dbHost)}
POSTGRESQL_SERVER_PORT=${POSTGRESQL_SERVER_PORT:-5432}
POSTGRESQL_SERVER_DB_NAME=${POSTGRESQL_SERVER_DB_NAME:-$(${JSON} services.CoAuthoring.sql.dbName)}
POSTGRESQL_SERVER_USER=${POSTGRESQL_SERVER_USER:-$(${JSON} services.CoAuthoring.sql.dbUser)}
POSTGRESQL_SERVER_PASS=${POSTGRESQL_SERVER_PASS:-$(${JSON} services.CoAuthoring.sql.dbPass)}
deprecated_var POSTGRESQL_SERVER_HOST DB_HOST
deprecated_var POSTGRESQL_SERVER_PORT DB_PORT
deprecated_var POSTGRESQL_SERVER_DB_NAME DB_NAME
deprecated_var POSTGRESQL_SERVER_USER DB_USER
deprecated_var POSTGRESQL_SERVER_PASS DB_PWD
DB_HOST=${DB_HOST:-${POSTGRESQL_SERVER_HOST:-$(${JSON} services.CoAuthoring.sql.dbHost)}}
case $DB_TYPE in
"postgres")
DB_PORT=${DB_PORT:-"5432"}
;;
"mariadb"|"mysql")
DB_PORT=${DB_PORT:-"3306"}
;;
"")
DB_PORT=${DB_PORT:-${POSTGRESQL_SERVER_PORT:-$(${JSON} services.CoAuthoring.sql.dbPort)}}
;;
*)
echo "ERROR: unknown database type"
exit 1
;;
esac
DB_NAME=${DB_NAME:-${POSTGRESQL_SERVER_DB_NAME:-$(${JSON} services.CoAuthoring.sql.dbName)}}
DB_USER=${DB_USER:-${POSTGRESQL_SERVER_USER:-$(${JSON} services.CoAuthoring.sql.dbUser)}}
DB_PWD=${DB_PWD:-${POSTGRESQL_SERVER_PASS:-$(${JSON} services.CoAuthoring.sql.dbPass)}}
DB_TYPE=${DB_TYPE:-$(${JSON} services.CoAuthoring.sql.type)}
RABBITMQ_SERVER_URL=${RABBITMQ_SERVER_URL:-$(${JSON} rabbitmq.url)}
AMQP_SERVER_URL=${AMQP_SERVER_URL:-${RABBITMQ_SERVER_URL}}
@ -74,6 +96,12 @@ read_setting(){
DS_LOG_LEVEL=${DS_LOG_LEVEL:-$(${JSON_LOG} categories.default.level)}
}
deprecated_var() {
if [[ -n ${!1} ]]; then
echo "Variable $1 is deprecated. Use $2 instead."
fi
}
parse_rabbitmq_url(){
local amqp=$1
@ -123,8 +151,8 @@ waiting_for_connection(){
done
}
waiting_for_postgresql(){
waiting_for_connection ${POSTGRESQL_SERVER_HOST} ${POSTGRESQL_SERVER_PORT}
waiting_for_db(){
waiting_for_connection $DB_HOST $DB_PORT
}
waiting_for_amqp(){
@ -137,12 +165,13 @@ waiting_for_redis(){
waiting_for_datacontainer(){
waiting_for_connection ${ONLYOFFICE_DATA_CONTAINER_HOST} ${ONLYOFFICE_DATA_CONTAINER_PORT}
}
update_postgresql_settings(){
${JSON} -I -e "this.services.CoAuthoring.sql.dbHost = '${POSTGRESQL_SERVER_HOST}'"
${JSON} -I -e "this.services.CoAuthoring.sql.dbPort = '${POSTGRESQL_SERVER_PORT}'"
${JSON} -I -e "this.services.CoAuthoring.sql.dbName = '${POSTGRESQL_SERVER_DB_NAME}'"
${JSON} -I -e "this.services.CoAuthoring.sql.dbUser = '${POSTGRESQL_SERVER_USER}'"
${JSON} -I -e "this.services.CoAuthoring.sql.dbPass = '${POSTGRESQL_SERVER_PASS}'"
update_db_settings(){
${JSON} -I -e "this.services.CoAuthoring.sql.type = '${DB_TYPE}'"
${JSON} -I -e "this.services.CoAuthoring.sql.dbHost = '${DB_HOST}'"
${JSON} -I -e "this.services.CoAuthoring.sql.dbPort = '${DB_PORT}'"
${JSON} -I -e "this.services.CoAuthoring.sql.dbName = '${DB_NAME}'"
${JSON} -I -e "this.services.CoAuthoring.sql.dbUser = '${DB_USER}'"
${JSON} -I -e "this.services.CoAuthoring.sql.dbPass = '${DB_PWD}'"
}
update_rabbitmq_setting(){
@ -207,6 +236,9 @@ update_jwt_settings(){
${JSON} -I -e "this.services.CoAuthoring.token.inbox.header = '${JWT_HEADER}'"
${JSON} -I -e "this.services.CoAuthoring.token.outbox.header = '${JWT_HEADER}'"
${JSON} -I -e "this.services.CoAuthoring.token.inbox.inBody = '${JWT_IN_BODY}'"
${JSON} -I -e "this.services.CoAuthoring.token.outbox.inBody = '${JWT_IN_BODY}'"
if [ -f "${ONLYOFFICE_EXAMPLE_CONFIG}" ] && [ "${JWT_ENABLED}" == "true" ]; then
${JSON_EXAMPLE} -I -e "this.server.token.enable = ${JWT_ENABLED}"
${JSON_EXAMPLE} -I -e "this.server.token.secret = '${JWT_SECRET}'"
@ -232,10 +264,21 @@ create_postgresql_db(){
sudo -u postgres psql -c "GRANT ALL privileges ON DATABASE onlyoffice TO onlyoffice;"
}
create_postgresql_tbl(){
CONNECTION_PARAMS="-h${POSTGRESQL_SERVER_HOST} -p${POSTGRESQL_SERVER_PORT} -U${POSTGRESQL_SERVER_USER} -w"
if [ -n "${POSTGRESQL_SERVER_PASS}" ]; then
export PGPASSWORD=${POSTGRESQL_SERVER_PASS}
create_db_tbl() {
case $DB_TYPE in
"postgres")
create_postgresql_tbl
;;
"mariadb"|"mysql")
create_mysql_tbl
;;
esac
}
create_postgresql_tbl() {
CONNECTION_PARAMS="-h$DB_HOST -p$DB_PORT -U$DB_USER -w"
if [ -n "$DB_PWD" ]; then
export PGPASSWORD=$DB_PWD
fi
PSQL="psql -q $CONNECTION_PARAMS"
@ -243,10 +286,33 @@ create_postgresql_tbl(){
# Create db on remote server
if $PSQL -lt | cut -d\| -f 1 | grep -qw | grep 0; then
$CREATEDB $POSTGRESQL_SERVER_DB_NAME
$CREATEDB $DB_NAME
fi
$PSQL -d "${POSTGRESQL_SERVER_DB_NAME}" -f "${APP_DIR}/server/schema/postgresql/createdb.sql"
$PSQL -d "$DB_NAME" -f "$APP_DIR/server/schema/postgresql/createdb.sql"
}
create_mysql_tbl() {
CONNECTION_PARAMS="-h$DB_HOST -P$DB_PORT -u$DB_USER -p$DB_PWD -w"
MYSQL="mysql -q $CONNECTION_PARAMS"
# Create db on remote server
$MYSQL -e "CREATE DATABASE IF NOT EXISTS $DB_NAME DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci;" >/dev/null 2>&1
$MYSQL $DB_NAME < "$APP_DIR/server/schema/mysql/createdb.sql" >/dev/null 2>&1
}
update_welcome_page() {
WELCOME_PAGE="${APP_DIR}-example/welcome/docker.html"
if [[ -e $WELCOME_PAGE ]]; then
DOCKER_CONTAINER_ID=$(basename $(cat /proc/1/cpuset))
if [[ -x $(command -v docker) ]]; then
DOCKER_CONTAINER_NAME=$(docker inspect --format="{{.Name}}" $DOCKER_CONTAINER_ID)
sed 's/$(sudo docker ps -q)/'"${DOCKER_CONTAINER_NAME#/}"'/' -i $WELCOME_PAGE
else
sed 's/$(sudo docker ps -q)/'"${DOCKER_CONTAINER_ID::12}"'/' -i $WELCOME_PAGE
fi
fi
}
update_nginx_settings(){
@ -335,15 +401,17 @@ if [ ${ONLYOFFICE_DATA_CONTAINER_HOST} = "localhost" ]; then
read_setting
update_welcome_page
update_log_settings
update_jwt_settings
# update settings by env variables
if [ ${POSTGRESQL_SERVER_HOST} != "localhost" ]; then
update_postgresql_settings
waiting_for_postgresql
create_postgresql_tbl
if [ $DB_HOST != "localhost" ]; then
update_db_settings
waiting_for_db
create_db_tbl
else
# change rights for postgres directory
chown -R postgres:postgres ${PG_ROOT}
@ -377,6 +445,8 @@ else
# read settings after the data container in ready state
# to prevent get unconfigureted data
read_setting
update_welcome_page
fi
#start needed local services
@ -390,7 +460,7 @@ if [ ${PG_NEW_CLUSTER} = "true" ]; then
fi
if [ ${ONLYOFFICE_DATA_CONTAINER} != "true" ]; then
waiting_for_postgresql
waiting_for_db
waiting_for_amqp
waiting_for_redis

View file

@ -4,8 +4,8 @@ services:
container_name: onlyoffice-documentserver
image: onlyoffice/4testing-documentserver-ie:latest
environment:
- AMQP_SERVER_URL=amqp://guest:guest@onlyoffice-activemq
- AMQP_SERVER_TYPE=activemq
- AMQP_SERVER_TYPE
- AMQP_SERVER_URL
stdin_open: true
restart: always
ports:
@ -18,8 +18,8 @@ services:
container_name: onlyoffice-activemq
image: webcenter/activemq:5.14.3
environment:
- ACTIVEMQ_USERS_guest=guest
- ACTIVEMQ_GROUPS_owners=guest
- ACTIVEMQ_USERS_guest
- ACTIVEMQ_GROUPS_owners
restart: always
networks:
- onlyoffice

40
tests/defaults.env Normal file
View file

@ -0,0 +1,40 @@
# DocumentServer Container
ONLYOFFICE_DATA_CONTAINER=true
DB_TYPE=postgres
DB_HOST=onlyoffice-postgresql
DB_PORT=5432
DB_NAME=onlyoffice
DB_USER=onlyoffice
DB_PWD=onlyoffice
AMQP_SERVER_TYPE=rabbitmq
AMQP_SERVER_URL=amqp://guest:guest@onlyoffice-rabbitmq
REDIS_SERVER_HOST=onlyoffice-redis
REDIS_SERVER_PORT=6379
JWT_ENABLED=true
JWT_SECRET=secret
JWT_HEADER=Authorization
ONLYOFFICE_DATA_CONTAINER_HOST=onlyoffice-documentserver-data
BALANCE=uri depth 3
EXCLUDE_PORTS=443
HTTP_CHECK=GET /healthcheck
EXTRA_SETTINGS=http-check expect string true
FORCE_SSL=true
# HAProxy Container
MODE=http
CERT_FOLDER=/certs/
# ActiveMQ Container
ACTIVEMQ_USERS_guest=guest
ACTIVEMQ_GROUPS_owners=guest
# Postgres Container
POSTGRES_DB=onlyoffice
POSTGRES_USER=onlyoffice
# MySQL Container
MYSQL_DATABASE=onlyoffice
MYSQL_USER=onlyoffice
MYSQL_PASSWORD=onlyoffice
MYSQL_ALLOW_EMPTY_PASSWORD=yes

35
tests/mysql.yml Normal file
View file

@ -0,0 +1,35 @@
version: '2'
services:
onlyoffice-documentserver:
container_name: onlyoffice-documentserver
image: onlyoffice/4testing-documentserver-ie:latest
depends_on:
- onlyoffice-mysql
environment:
- DB_TYPE
- DB_HOST
- DB_PORT
- DB_NAME
- DB_USER
- DB_PWD
stdin_open: true
restart: always
ports:
- '80:80'
onlyoffice-mysql:
container_name: onlyoffice-mysql
image: mysql:5.7
environment:
- MYSQL_DATABASE
- MYSQL_USER
- MYSQL_PASSWORD
- MYSQL_ALLOW_EMPTY_PASSWORD
restart: always
volumes:
- mysql_data:/var/lib/mysql
expose:
- '3306'
volumes:
mysql_data:

32
tests/postgres-old.yml Normal file
View file

@ -0,0 +1,32 @@
version: '2'
services:
onlyoffice-documentserver:
container_name: onlyoffice-documentserver
image: onlyoffice/4testing-documentserver-ie:latest
depends_on:
- onlyoffice-postgresql
environment:
- POSTGRESQL_SERVER_HOST
- POSTGRESQL_SERVER_PORT
- POSTGRESQL_SERVER_DB_NAME
- POSTGRESQL_SERVER_USER
- POSTGRESQL_SERVER_PASS
stdin_open: true
restart: always
ports:
- '80:80'
onlyoffice-postgresql:
container_name: onlyoffice-postgresql
image: postgres:9.5
environment:
- POSTGRES_DB
- POSTGRES_USER
restart: always
expose:
- '5432'
volumes:
- postgresql_data:/var/lib/postgresql
volumes:
postgresql_data:

33
tests/postgres.yml Normal file
View file

@ -0,0 +1,33 @@
version: '2'
services:
onlyoffice-documentserver:
container_name: onlyoffice-documentserver
image: onlyoffice/4testing-documentserver-ie:latest
depends_on:
- onlyoffice-postgresql
environment:
- DB_TYPE
- DB_HOST
- DB_PORT
- DB_NAME
- DB_USER
- DB_PWD
stdin_open: true
restart: always
ports:
- '80:80'
onlyoffice-postgresql:
container_name: onlyoffice-postgresql
image: postgres:9.5
environment:
- POSTGRES_DB
- POSTGRES_USER
restart: always
expose:
- '5432'
volumes:
- postgresql_data:/var/lib/postgresql
volumes:
postgresql_data:

37
tests/test.sh Executable file
View file

@ -0,0 +1,37 @@
#!/bin/bash
# Check if the yml exists
if [[ ! -f $config ]]; then
echo "File $config doesn't exist!"
exit 1
fi
env_file=defaults.env
# Copy .env
if [[ -f $env_file ]]; then
cp $env_file .env
else
echo "File $env_file doesn't exist!"
exit 1
fi
# Run test environment
docker-compose -p ds -f $config up -d
wakeup_timeout=30
# Get documentserver healthcheck status
echo "Wait for service wake up"
sleep $wakeup_timeout
healthcheck_res=$(wget --no-check-certificate -qO - localhost/healthcheck)
# Fail if it isn't true
if [[ $healthcheck_res == "true" ]]; then
echo "Healthcheck passed."
else
echo "Healthcheck failed!"
exit 1
fi
docker-compose -p ds -f $config down