Merge pull request #9 from ONLYOFFICE/feature/docker-compose
Feature/docker compose
This commit is contained in:
commit
d31b8939f8
2 changed files with 159 additions and 98 deletions
|
@ -1,12 +1,10 @@
|
|||
version: '2'
|
||||
services:
|
||||
onlyoffice-document:
|
||||
onlyoffice-documentserver-data:
|
||||
container_name: onlyoffice-documentserver-data
|
||||
image: onlyoffice/4testing-documentserver:latest
|
||||
depends_on:
|
||||
- onlyoffice-mysql
|
||||
- onlyoffice-redis
|
||||
- onlyoffice-rabbitmq
|
||||
environment:
|
||||
- ONLYOFFICE_DATA_CONTAINER=true
|
||||
- MYSQL_SERVER_HOST=onlyoffice-mysql
|
||||
- MYSQL_SERVER_PORT=3306
|
||||
- MYSQL_SERVER_DB_NAME=onlyoffice
|
||||
|
@ -16,6 +14,26 @@ services:
|
|||
- RABBITMQ_SERVER_PASS=guest
|
||||
- REDIS_SERVER_HOST=onlyoffice-redis
|
||||
- REDIS_SERVER_PORT=6379
|
||||
stdin_open: true
|
||||
tty: true
|
||||
restart: always
|
||||
networks:
|
||||
- onlyoffice
|
||||
volumes:
|
||||
- /var/www/onlyoffice/Data
|
||||
- /var/log/onlyoffice
|
||||
- /var/lib/onlyoffice/documentserver/App_Data/cache/files
|
||||
- /var/www/onlyoffice/documentserver-example/public/files
|
||||
- /usr/share/fonts
|
||||
|
||||
onlyoffice-documentserver:
|
||||
image: onlyoffice/4testing-documentserver:latest
|
||||
depends_on:
|
||||
- onlyoffice-documentserver-data
|
||||
- onlyoffice-mysql
|
||||
- onlyoffice-redis
|
||||
- onlyoffice-rabbitmq
|
||||
environment:
|
||||
- HTTP_CHECK=HEAD /healthcheck
|
||||
- EXTRA_SETTINGS=http-check expect status 200
|
||||
stdin_open: true
|
||||
|
@ -26,24 +44,21 @@ services:
|
|||
expose:
|
||||
- '80'
|
||||
- '443'
|
||||
volumes:
|
||||
- document_data:/var/www/onlyoffice/Data
|
||||
- document_log:/var/log/onlyoffice
|
||||
- document_files:/var/lib/onlyoffice/documentserver/App_Data/cache/files
|
||||
- document_example_files:/var/www/onlyoffice/documentserver-example/public/files
|
||||
volumes_from:
|
||||
- onlyoffice-documentserver-data
|
||||
|
||||
onlyoffice-haproxy:
|
||||
container_name: onlyoffice-haproxy
|
||||
image: dockercloud/haproxy:1.2.1
|
||||
depends_on:
|
||||
- onlyoffice-document
|
||||
- onlyoffice-documentserver
|
||||
environment:
|
||||
- MODE=tcp
|
||||
- TCP_PORTS="80, 443"
|
||||
stdin_open: true
|
||||
tty: true
|
||||
links:
|
||||
- onlyoffice-document
|
||||
- onlyoffice-documentserver
|
||||
volumes:
|
||||
- /var/run/docker.sock:/var/run/docker.sock
|
||||
restart: always
|
||||
|
@ -93,7 +108,3 @@ networks:
|
|||
|
||||
volumes:
|
||||
mysql_data:
|
||||
document_data:
|
||||
document_log:
|
||||
document_files:
|
||||
document_example_files:
|
||||
|
|
|
@ -4,7 +4,7 @@ APP_DIR="/var/www/onlyoffice/documentserver"
|
|||
DATA_DIR="/var/www/onlyoffice/Data"
|
||||
LOG_DIR="/var/log/onlyoffice/documentserver"
|
||||
|
||||
ONLYOFFICE_HTTPS=${ONLYOFFICE_HTTPS:-false}
|
||||
ONLYOFFICE_DATA_CONTAINER=${ONLYOFFICE_DATA_CONTAINER:-false}
|
||||
|
||||
SSL_CERTIFICATES_DIR="${DATA_DIR}/certs"
|
||||
SSL_CERTIFICATE_PATH=${SSL_CERTIFICATE_PATH:-${SSL_CERTIFICATES_DIR}/onlyoffice.crt}
|
||||
|
@ -24,26 +24,73 @@ NGINX_WORKER_CONNECTIONS=${NGINX_WORKER_CONNECTIONS:-$(ulimit -n)}
|
|||
|
||||
ONLYOFFICE_DEFAULT_CONFIG=/etc/onlyoffice/documentserver/default.json
|
||||
|
||||
MYSQL_SERVER_HOST=${MYSQL_SERVER_HOST:-"localhost"}
|
||||
MYSQL_SERVER_PORT=${MYSQL_SERVER_PORT:-"3306"}
|
||||
MYSQL_SERVER_DB_NAME=${MYSQL_SERVER_DB_NAME:-"onlyoffice"}
|
||||
MYSQL_SERVER_USER=${MYSQL_SERVER_USER:-"root"}
|
||||
MYSQL_SERVER_PASS=${MYSQL_SERVER_PASS:-""}
|
||||
JSON="json -q -f ${ONLYOFFICE_DEFAULT_CONFIG}"
|
||||
|
||||
RABBITMQ_SERVER_HOST=${RABBITMQ_SERVER_HOST:-"localhost"}
|
||||
RABBITMQ_SERVER_USER=${RABBITMQ_SERVER_USER:-"guest"}
|
||||
RABBITMQ_SERVER_PASS=${RABBITMQ_SERVER_PASS:-"guest"}
|
||||
MYSQL_SERVER_HOST=${MYSQL_SERVER_HOST:-$(${JSON} services.CoAuthoring.sql.dbHost)}
|
||||
MYSQL_SERVER_PORT=${MYSQL_SERVER_PORT:-$(${JSON} services.CoAuthoring.sql.dbPort)}
|
||||
MYSQL_SERVER_DB_NAME=${MYSQL_SERVER_DB_NAME:-$(${JSON} services.CoAuthoring.sql.dbName)}
|
||||
MYSQL_SERVER_USER=${MYSQL_SERVER_USER:-$(${JSON} services.CoAuthoring.sql.dbUser)}
|
||||
MYSQL_SERVER_PASS=${MYSQL_SERVER_PASS:-$(${JSON} services.CoAuthoring.sql.dbPass)}
|
||||
|
||||
REDIS_SERVER_HOST=${REDIS_SERVER_HOST:-"localhost"}
|
||||
REDIS_SERVER_PORT=${REDIS_SERVER_PORT:-"6379"}
|
||||
RABBITMQ_SERVER_URL=$(${JSON} rabbitmq.url)
|
||||
RABBITMQ_SERVER_HOST=${RABBITMQ_SERVER_HOST:-${RABBITMQ_SERVER_URL#'amqp://'}}
|
||||
RABBITMQ_SERVER_USER=${RABBITMQ_SERVER_USER:-$(${JSON} rabbitmq.login)}
|
||||
RABBITMQ_SERVER_PASS=${RABBITMQ_SERVER_PASS:-$(${JSON} rabbitmq.password)}
|
||||
RABBITMQ_SERVER_PORT=${RABBITMQ_SERVER_PORT:-"5672"}
|
||||
|
||||
# create base folders
|
||||
for i in converter docservice spellchecker metrics gc; do
|
||||
mkdir -p "${LOG_DIR}/$i"
|
||||
REDIS_SERVER_HOST=${REDIS_SERVER_HOST:-$(${JSON} services.CoAuthoring.redis.host)}
|
||||
REDIS_SERVER_PORT=${REDIS_SERVER_PORT:-$(${JSON} services.CoAuthoring.redis.port)}
|
||||
|
||||
waiting_for_connection(){
|
||||
until nc -z -w 3 "$1" "$2"; do
|
||||
>&2 echo "Waiting for connection to the $1 host on port $2"
|
||||
sleep 1
|
||||
done
|
||||
}
|
||||
|
||||
mkdir -p ${LOG_DIR}-example
|
||||
waiting_for_mysql(){
|
||||
waiting_for_connection ${MYSQL_SERVER_HOST} ${MYSQL_SERVER_PORT}
|
||||
}
|
||||
|
||||
waiting_for_rabbitmq(){
|
||||
waiting_for_connection ${RABBITMQ_SERVER_HOST} ${RABBITMQ_SERVER_PORT}
|
||||
}
|
||||
|
||||
waiting_for_redis(){
|
||||
waiting_for_connection ${REDIS_SERVER_HOST} ${REDIS_SERVER_PORT}
|
||||
}
|
||||
|
||||
update_mysql_settings(){
|
||||
${JSON} -I -e "this.services.CoAuthoring.sql.dbHost = '${MYSQL_SERVER_HOST}'"
|
||||
${JSON} -I -e "this.services.CoAuthoring.sql.dbPort = '${MYSQL_SERVER_PORT}'"
|
||||
${JSON} -I -e "this.services.CoAuthoring.sql.dbName = '${MYSQL_SERVER_DB_NAME}'"
|
||||
${JSON} -I -e "this.services.CoAuthoring.sql.dbUser = '${MYSQL_SERVER_USER}'"
|
||||
${JSON} -I -e "this.services.CoAuthoring.sql.dbPass = '${MYSQL_SERVER_PASS}'"
|
||||
}
|
||||
|
||||
update_rabbitmq_setting(){
|
||||
${JSON} -I -e "this.rabbitmq.url = 'amqp://${RABBITMQ_SERVER_HOST}'"
|
||||
${JSON} -I -e "this.rabbitmq.login = '${RABBITMQ_SERVER_USER}'"
|
||||
${JSON} -I -e "this.rabbitmq.password = '${RABBITMQ_SERVER_PASS}'"
|
||||
}
|
||||
|
||||
update_redis_settings(){
|
||||
${JSON} -I -e "this.services.CoAuthoring.redis.host = '${REDIS_SERVER_HOST}'"
|
||||
${JSON} -I -e "this.services.CoAuthoring.redis.port = '${REDIS_SERVER_PORT}'"
|
||||
}
|
||||
|
||||
create_mysql_db(){
|
||||
MYSQL="mysql -s -h${MYSQL_SERVER_HOST} -u${MYSQL_SERVER_USER}"
|
||||
if [ -n "${MYSQL_SERVER_PASS}" ]; then
|
||||
MYSQL="$MYSQL -p${MYSQL_SERVER_PASS}"
|
||||
fi
|
||||
|
||||
# Create db on remote server
|
||||
${MYSQL} -e "CREATE DATABASE IF NOT EXISTS ${MYSQL_SERVER_DB_NAME} CHARACTER SET utf8 COLLATE 'utf8_general_ci';"
|
||||
${MYSQL} "${MYSQL_SERVER_DB_NAME}" < "${APP_DIR}/server/schema/createdb.sql"
|
||||
}
|
||||
|
||||
start_nginx(){
|
||||
# Set up nginx
|
||||
sed 's/^worker_processes.*/'"worker_processes ${NGINX_WORKER_PROCESSES};"'/' -i ${NGINX_CONFIG_PATH}
|
||||
sed 's/worker_connections.*/'"worker_connections ${NGINX_WORKER_CONNECTIONS};"'/' -i ${NGINX_CONFIG_PATH}
|
||||
|
@ -83,57 +130,60 @@ else
|
|||
cp ${SYSCONF_TEMPLATES_DIR}/nginx/onlyoffice-documentserver.conf ${NGINX_ONLYOFFICE_PATH}
|
||||
fi
|
||||
|
||||
JSON="json -I -q -f ${ONLYOFFICE_DEFAULT_CONFIG}"
|
||||
|
||||
if [ ${MYSQL_SERVER_HOST} != "localhost" ]; then
|
||||
|
||||
# Change mysql settings
|
||||
${JSON} -e "this.services.CoAuthoring.sql.dbHost = '${MYSQL_SERVER_HOST}'"
|
||||
${JSON} -e "this.services.CoAuthoring.sql.dbPort = '${MYSQL_SERVER_PORT}'"
|
||||
${JSON} -e "this.services.CoAuthoring.sql.dbName = '${MYSQL_SERVER_DB_NAME}'"
|
||||
${JSON} -e "this.services.CoAuthoring.sql.dbUser = '${MYSQL_SERVER_USER}'"
|
||||
${JSON} -e "this.services.CoAuthoring.sql.dbPass = '${MYSQL_SERVER_PASS}'"
|
||||
|
||||
MYSQL="mysql -s -h${MYSQL_SERVER_HOST} -u${MYSQL_SERVER_USER}"
|
||||
if [ -n "${MYSQL_SERVER_PASS}" ]; then
|
||||
MYSQL="$MYSQL -p${MYSQL_SERVER_PASS}"
|
||||
fi
|
||||
|
||||
# Create db on remote server
|
||||
${MYSQL} -e "CREATE DATABASE IF NOT EXISTS ${MYSQL_SERVER_DB_NAME} CHARACTER SET utf8 COLLATE 'utf8_general_ci';"
|
||||
${MYSQL} "${MYSQL_SERVER_DB_NAME}" < "${APP_DIR}/server/schema/createdb.sql"
|
||||
else
|
||||
service mysql start
|
||||
fi
|
||||
|
||||
if [ ${RABBITMQ_SERVER_HOST} != "localhost" ]; then
|
||||
|
||||
# Change rabbitmq settings
|
||||
${JSON} -e "this.rabbitmq.url = 'amqp://${RABBITMQ_SERVER_HOST}'"
|
||||
${JSON} -e "this.rabbitmq.login = '${RABBITMQ_SERVER_USER}'"
|
||||
${JSON} -e "this.rabbitmq.password = '${RABBITMQ_SERVER_PASS}'"
|
||||
|
||||
else
|
||||
service redis-server start
|
||||
fi
|
||||
|
||||
if [ ${REDIS_SERVER_HOST} != "localhost" ]; then
|
||||
|
||||
# Change redis settings
|
||||
${JSON} -e "this.services.CoAuthoring.redis.host = '${REDIS_SERVER_HOST}'"
|
||||
${JSON} -e "this.services.CoAuthoring.redis.port = '${REDIS_SERVER_PORT}'"
|
||||
|
||||
else
|
||||
service rabbitmq-server start
|
||||
fi
|
||||
#start service
|
||||
service nginx start
|
||||
}
|
||||
|
||||
start_supervisor(){
|
||||
# Copy modified supervisor start script
|
||||
cp ${SYSCONF_TEMPLATES_DIR}/supervisor/supervisor /etc/init.d/
|
||||
# Copy modified supervisor config
|
||||
cp ${SYSCONF_TEMPLATES_DIR}/supervisor/supervisord.conf /etc/supervisor/supervisord.conf
|
||||
|
||||
service nginx start
|
||||
#start service
|
||||
service supervisor start
|
||||
}
|
||||
|
||||
# create base folders
|
||||
for i in converter docservice spellchecker metrics gc; do
|
||||
mkdir -p "${LOG_DIR}/$i"
|
||||
done
|
||||
|
||||
mkdir -p ${LOG_DIR}-example
|
||||
|
||||
if [ ${MYSQL_SERVER_HOST} != "localhost" ]; then
|
||||
update_mysql_settings
|
||||
create_mysql_db
|
||||
else
|
||||
if [ ${ONLYOFFICE_DATA_CONTAINER} != "true" ]; then
|
||||
service mysql start
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ ${RABBITMQ_SERVER_HOST} != "localhost" ]; then
|
||||
update_rabbitmq_setting
|
||||
else
|
||||
if [ ${ONLYOFFICE_DATA_CONTAINER} != "true" ]; then
|
||||
service redis-server start
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ ${REDIS_SERVER_HOST} != "localhost" ]; then
|
||||
update_redis_settings
|
||||
else
|
||||
if [ ${ONLYOFFICE_DATA_CONTAINER} != "true" ]; then
|
||||
service rabbitmq-server start
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ ${ONLYOFFICE_DATA_CONTAINER} != "true" ]; then
|
||||
waiting_for_mysql
|
||||
waiting_for_rabbitmq
|
||||
waiting_for_redis
|
||||
|
||||
start_nginx
|
||||
start_supervisor
|
||||
fi
|
||||
|
||||
# Regenerate the fonts list and the fonts thumbnails
|
||||
documentserver-generate-allfonts.sh
|
||||
documentserver-generate-allfonts.sh ${ONLYOFFICE_DATA_CONTAINER}
|
Loading…
Reference in a new issue