Merge pull request #9 from ONLYOFFICE/feature/docker-compose
Feature/docker compose
This commit is contained in:
commit
d31b8939f8
@ -1,12 +1,10 @@
|
|||||||
version: '2'
|
version: '2'
|
||||||
services:
|
services:
|
||||||
onlyoffice-document:
|
onlyoffice-documentserver-data:
|
||||||
|
container_name: onlyoffice-documentserver-data
|
||||||
image: onlyoffice/4testing-documentserver:latest
|
image: onlyoffice/4testing-documentserver:latest
|
||||||
depends_on:
|
|
||||||
- onlyoffice-mysql
|
|
||||||
- onlyoffice-redis
|
|
||||||
- onlyoffice-rabbitmq
|
|
||||||
environment:
|
environment:
|
||||||
|
- ONLYOFFICE_DATA_CONTAINER=true
|
||||||
- MYSQL_SERVER_HOST=onlyoffice-mysql
|
- MYSQL_SERVER_HOST=onlyoffice-mysql
|
||||||
- MYSQL_SERVER_PORT=3306
|
- MYSQL_SERVER_PORT=3306
|
||||||
- MYSQL_SERVER_DB_NAME=onlyoffice
|
- MYSQL_SERVER_DB_NAME=onlyoffice
|
||||||
@ -16,6 +14,26 @@ services:
|
|||||||
- RABBITMQ_SERVER_PASS=guest
|
- RABBITMQ_SERVER_PASS=guest
|
||||||
- REDIS_SERVER_HOST=onlyoffice-redis
|
- REDIS_SERVER_HOST=onlyoffice-redis
|
||||||
- REDIS_SERVER_PORT=6379
|
- 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
|
- HTTP_CHECK=HEAD /healthcheck
|
||||||
- EXTRA_SETTINGS=http-check expect status 200
|
- EXTRA_SETTINGS=http-check expect status 200
|
||||||
stdin_open: true
|
stdin_open: true
|
||||||
@ -26,24 +44,21 @@ services:
|
|||||||
expose:
|
expose:
|
||||||
- '80'
|
- '80'
|
||||||
- '443'
|
- '443'
|
||||||
volumes:
|
volumes_from:
|
||||||
- document_data:/var/www/onlyoffice/Data
|
- onlyoffice-documentserver-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
|
|
||||||
|
|
||||||
onlyoffice-haproxy:
|
onlyoffice-haproxy:
|
||||||
container_name: onlyoffice-haproxy
|
container_name: onlyoffice-haproxy
|
||||||
image: dockercloud/haproxy:1.2.1
|
image: dockercloud/haproxy:1.2.1
|
||||||
depends_on:
|
depends_on:
|
||||||
- onlyoffice-document
|
- onlyoffice-documentserver
|
||||||
environment:
|
environment:
|
||||||
- MODE=tcp
|
- MODE=tcp
|
||||||
- TCP_PORTS="80, 443"
|
- TCP_PORTS="80, 443"
|
||||||
stdin_open: true
|
stdin_open: true
|
||||||
tty: true
|
tty: true
|
||||||
links:
|
links:
|
||||||
- onlyoffice-document
|
- onlyoffice-documentserver
|
||||||
volumes:
|
volumes:
|
||||||
- /var/run/docker.sock:/var/run/docker.sock
|
- /var/run/docker.sock:/var/run/docker.sock
|
||||||
restart: always
|
restart: always
|
||||||
@ -93,7 +108,3 @@ networks:
|
|||||||
|
|
||||||
volumes:
|
volumes:
|
||||||
mysql_data:
|
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"
|
DATA_DIR="/var/www/onlyoffice/Data"
|
||||||
LOG_DIR="/var/log/onlyoffice/documentserver"
|
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_CERTIFICATES_DIR="${DATA_DIR}/certs"
|
||||||
SSL_CERTIFICATE_PATH=${SSL_CERTIFICATE_PATH:-${SSL_CERTIFICATES_DIR}/onlyoffice.crt}
|
SSL_CERTIFICATE_PATH=${SSL_CERTIFICATE_PATH:-${SSL_CERTIFICATES_DIR}/onlyoffice.crt}
|
||||||
@ -24,33 +24,80 @@ NGINX_WORKER_CONNECTIONS=${NGINX_WORKER_CONNECTIONS:-$(ulimit -n)}
|
|||||||
|
|
||||||
ONLYOFFICE_DEFAULT_CONFIG=/etc/onlyoffice/documentserver/default.json
|
ONLYOFFICE_DEFAULT_CONFIG=/etc/onlyoffice/documentserver/default.json
|
||||||
|
|
||||||
MYSQL_SERVER_HOST=${MYSQL_SERVER_HOST:-"localhost"}
|
JSON="json -q -f ${ONLYOFFICE_DEFAULT_CONFIG}"
|
||||||
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:-""}
|
|
||||||
|
|
||||||
RABBITMQ_SERVER_HOST=${RABBITMQ_SERVER_HOST:-"localhost"}
|
MYSQL_SERVER_HOST=${MYSQL_SERVER_HOST:-$(${JSON} services.CoAuthoring.sql.dbHost)}
|
||||||
RABBITMQ_SERVER_USER=${RABBITMQ_SERVER_USER:-"guest"}
|
MYSQL_SERVER_PORT=${MYSQL_SERVER_PORT:-$(${JSON} services.CoAuthoring.sql.dbPort)}
|
||||||
RABBITMQ_SERVER_PASS=${RABBITMQ_SERVER_PASS:-"guest"}
|
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"}
|
RABBITMQ_SERVER_URL=$(${JSON} rabbitmq.url)
|
||||||
REDIS_SERVER_PORT=${REDIS_SERVER_PORT:-"6379"}
|
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
|
REDIS_SERVER_HOST=${REDIS_SERVER_HOST:-$(${JSON} services.CoAuthoring.redis.host)}
|
||||||
for i in converter docservice spellchecker metrics gc; do
|
REDIS_SERVER_PORT=${REDIS_SERVER_PORT:-$(${JSON} services.CoAuthoring.redis.port)}
|
||||||
mkdir -p "${LOG_DIR}/$i"
|
|
||||||
done
|
|
||||||
|
|
||||||
mkdir -p ${LOG_DIR}-example
|
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
|
||||||
|
}
|
||||||
|
|
||||||
# Set up nginx
|
waiting_for_mysql(){
|
||||||
sed 's/^worker_processes.*/'"worker_processes ${NGINX_WORKER_PROCESSES};"'/' -i ${NGINX_CONFIG_PATH}
|
waiting_for_connection ${MYSQL_SERVER_HOST} ${MYSQL_SERVER_PORT}
|
||||||
sed 's/worker_connections.*/'"worker_connections ${NGINX_WORKER_CONNECTIONS};"'/' -i ${NGINX_CONFIG_PATH}
|
}
|
||||||
sed 's/access_log.*/'"access_log off;"'/' -i ${NGINX_CONFIG_PATH}
|
|
||||||
|
|
||||||
# setup HTTPS
|
waiting_for_rabbitmq(){
|
||||||
if [ -f "${SSL_CERTIFICATE_PATH}" -a -f "${SSL_KEY_PATH}" ]; then
|
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}
|
||||||
|
sed 's/access_log.*/'"access_log off;"'/' -i ${NGINX_CONFIG_PATH}
|
||||||
|
|
||||||
|
# setup HTTPS
|
||||||
|
if [ -f "${SSL_CERTIFICATE_PATH}" -a -f "${SSL_KEY_PATH}" ]; then
|
||||||
cp ${SYSCONF_TEMPLATES_DIR}/nginx/onlyoffice-documentserver-ssl.conf ${NGINX_ONLYOFFICE_PATH}
|
cp ${SYSCONF_TEMPLATES_DIR}/nginx/onlyoffice-documentserver-ssl.conf ${NGINX_ONLYOFFICE_PATH}
|
||||||
|
|
||||||
mkdir ${DATA_DIR}
|
mkdir ${DATA_DIR}
|
||||||
@ -79,61 +126,64 @@ if [ -f "${SSL_CERTIFICATE_PATH}" -a -f "${SSL_KEY_PATH}" ]; then
|
|||||||
else
|
else
|
||||||
sed '/{{ONLYOFFICE_HTTPS_HSTS_MAXAGE}}/d' -i ${NGINX_ONLYOFFICE_PATH}
|
sed '/{{ONLYOFFICE_HTTPS_HSTS_MAXAGE}}/d' -i ${NGINX_ONLYOFFICE_PATH}
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
cp ${SYSCONF_TEMPLATES_DIR}/nginx/onlyoffice-documentserver.conf ${NGINX_ONLYOFFICE_PATH}
|
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
|
fi
|
||||||
|
|
||||||
# Create db on remote server
|
#start service
|
||||||
${MYSQL} -e "CREATE DATABASE IF NOT EXISTS ${MYSQL_SERVER_DB_NAME} CHARACTER SET utf8 COLLATE 'utf8_general_ci';"
|
service nginx start
|
||||||
${MYSQL} "${MYSQL_SERVER_DB_NAME}" < "${APP_DIR}/server/schema/createdb.sql"
|
}
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
|
#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
|
else
|
||||||
|
if [ ${ONLYOFFICE_DATA_CONTAINER} != "true" ]; then
|
||||||
service mysql start
|
service mysql start
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ ${RABBITMQ_SERVER_HOST} != "localhost" ]; then
|
if [ ${RABBITMQ_SERVER_HOST} != "localhost" ]; then
|
||||||
|
update_rabbitmq_setting
|
||||||
# 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
|
else
|
||||||
|
if [ ${ONLYOFFICE_DATA_CONTAINER} != "true" ]; then
|
||||||
service redis-server start
|
service redis-server start
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ ${REDIS_SERVER_HOST} != "localhost" ]; then
|
if [ ${REDIS_SERVER_HOST} != "localhost" ]; then
|
||||||
|
update_redis_settings
|
||||||
# Change redis settings
|
|
||||||
${JSON} -e "this.services.CoAuthoring.redis.host = '${REDIS_SERVER_HOST}'"
|
|
||||||
${JSON} -e "this.services.CoAuthoring.redis.port = '${REDIS_SERVER_PORT}'"
|
|
||||||
|
|
||||||
else
|
else
|
||||||
|
if [ ${ONLYOFFICE_DATA_CONTAINER} != "true" ]; then
|
||||||
service rabbitmq-server start
|
service rabbitmq-server start
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Copy modified supervisor start script
|
if [ ${ONLYOFFICE_DATA_CONTAINER} != "true" ]; then
|
||||||
cp ${SYSCONF_TEMPLATES_DIR}/supervisor/supervisor /etc/init.d/
|
waiting_for_mysql
|
||||||
# Copy modified supervisor config
|
waiting_for_rabbitmq
|
||||||
cp ${SYSCONF_TEMPLATES_DIR}/supervisor/supervisord.conf /etc/supervisor/supervisord.conf
|
waiting_for_redis
|
||||||
|
|
||||||
service nginx start
|
start_nginx
|
||||||
service supervisor start
|
start_supervisor
|
||||||
|
fi
|
||||||
|
|
||||||
# Regenerate the fonts list and the fonts thumbnails
|
# Regenerate the fonts list and the fonts thumbnails
|
||||||
documentserver-generate-allfonts.sh
|
documentserver-generate-allfonts.sh ${ONLYOFFICE_DATA_CONTAINER}
|
Loading…
x
Reference in New Issue
Block a user