parent
b590340a10
commit
7d1606bc95
44
.travis.yml
Normal file
44
.travis.yml
Normal 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
|
@ -27,6 +27,7 @@ RUN echo "#!/bin/sh\nexit 0" > /usr/sbin/policy-rc.d && \
|
||||
libxml2 \
|
||||
libxss1 \
|
||||
libxtst6 \
|
||||
mysql-client \
|
||||
nano \
|
||||
net-tools \
|
||||
netcat \
|
||||
|
11
README.md
11
README.md
@ -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.
|
||||
|
@ -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
|
||||
|
@ -57,11 +57,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 +95,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 +150,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 +164,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(){
|
||||
@ -232,10 +260,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 +282,20 @@ 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_nginx_settings(){
|
||||
@ -340,10 +389,10 @@ if [ ${ONLYOFFICE_DATA_CONTAINER_HOST} = "localhost" ]; then
|
||||
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}
|
||||
@ -390,7 +439,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
|
||||
|
||||
|
@ -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
40
tests/defaults.env
Normal 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
35
tests/mysql.yml
Normal 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
32
tests/postgres-old.yml
Normal 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
33
tests/postgres.yml
Normal 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
37
tests/test.sh
Executable 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
|
Loading…
x
Reference in New Issue
Block a user