mysql -> postgresql
This commit is contained in:
parent
4859e8f422
commit
b9f9ed6ba5
3 changed files with 54 additions and 46 deletions
13
Dockerfile
13
Dockerfile
|
@ -5,19 +5,22 @@ ENV LANG=en_US.UTF-8 LANGUAGE=en_US:en LC_ALL=en_US.UTF-8 DEBIAN_FRONTEND=nonint
|
|||
|
||||
RUN echo "#!/bin/sh\nexit 0" > /usr/sbin/policy-rc.d && \
|
||||
apt-get -y update && \
|
||||
apt-get --force-yes -yq install apt-transport-https && \
|
||||
apt-get --force-yes -yq install wget apt-transport-https && \
|
||||
apt-key adv --keyserver keyserver.ubuntu.com --recv-keys D9D0BF019CC8AC0D && \
|
||||
apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 1655A0AB68576280 && \
|
||||
wget https://www.postgresql.org/media/keys/ACCC4CF8.asc && \
|
||||
apt-key add ACCC4CF8.asc && \
|
||||
echo "deb http://archive.ubuntu.com/ubuntu precise main universe multiverse" >> /etc/apt/sources.list && \
|
||||
echo "deb https://deb.nodesource.com/node_4.x trusty main" | tee /etc/apt/sources.list.d/nodesource.list && \
|
||||
echo "deb http://apt.postgresql.org/pub/repos/apt/ trusty-pgdg main" | tee /etc/apt/sources.list.d/nodesource.list && \
|
||||
locale-gen en_US.UTF-8 && \
|
||||
apt-get -y update && \
|
||||
echo ttf-mscorefonts-installer msttcorefonts/accepted-mscorefonts-eula select true | debconf-set-selections && \
|
||||
apt-get install --force-yes -yq software-properties-common && \
|
||||
add-apt-repository ppa:ubuntu-toolchain-r/test && \
|
||||
apt-get -y update && \
|
||||
apt-get --force-yes -yq install software-properties-common adduser mysql-server redis-server rabbitmq-server nginx-extras nodejs libstdc++6 libcurl3 libxml2 libboost-regex-dev zlib1g supervisor fonts-dejavu fonts-liberation ttf-mscorefonts-installer fonts-crosextra-carlito fonts-takao-gothic fonts-opensymbol libxss1 libgtkglext1 libcairo2 xvfb libxtst6 libgconf2-4 libasound2 bomstrip libnspr4 libnss3 libnss3-nssdb nano htop && \
|
||||
service mysql stop && \
|
||||
apt-get --force-yes -yq install software-properties-common adduser postgresql redis-server rabbitmq-server nginx-extras nodejs libstdc++6 libcurl3 libxml2 libboost-regex-dev zlib1g supervisor fonts-dejavu fonts-liberation ttf-mscorefonts-installer fonts-crosextra-carlito fonts-takao-gothic fonts-opensymbol libxss1 libgtkglext1 libcairo2 xvfb libxtst6 libgconf2-4 libasound2 bomstrip libnspr4 libnss3 libnss3-nssdb nano htop && \
|
||||
service postgresql stop && \
|
||||
service redis-server stop && \
|
||||
service rabbitmq-server stop && \
|
||||
service supervisor stop && \
|
||||
|
@ -31,9 +34,9 @@ EXPOSE 80 443
|
|||
|
||||
RUN echo "deb http://repo-doc-onlyoffice-com.s3.amazonaws.com/ubuntu/trusty/onlyoffice-documentserver/{{GIT_BRANCH}}/{{PACKAGE_VERSION}}/ repo/" | tee /etc/apt/sources.list.d/onlyoffice.list && \
|
||||
apt-get -y update && \
|
||||
service mysql start && \
|
||||
service postgresql start && \
|
||||
apt-get --force-yes -yq install onlyoffice-documentserver && \
|
||||
service mysql stop && \
|
||||
service postgresql stop && \
|
||||
service supervisor stop && \
|
||||
chmod 755 /app/onlyoffice/*.sh && \
|
||||
rm -rf /var/log/onlyoffice && \
|
||||
|
|
|
@ -5,10 +5,10 @@ services:
|
|||
image: onlyoffice/4testing-documentserver:latest
|
||||
environment:
|
||||
- ONLYOFFICE_DATA_CONTAINER=true
|
||||
- MYSQL_SERVER_HOST=onlyoffice-mysql
|
||||
- MYSQL_SERVER_PORT=3306
|
||||
- MYSQL_SERVER_DB_NAME=onlyoffice
|
||||
- MYSQL_SERVER_USER=root
|
||||
- POSTGRESQL_SERVER_HOST=onlyoffice-postgers
|
||||
- POSTGRESQL_SERVER_PORT=5432
|
||||
- POSTGRESQL_SERVER_DB_NAME=onlyoffice
|
||||
- POSTGRESQL_SERVER_USER=root
|
||||
- RABBITMQ_SERVER_HOST=onlyoffice-rabbitmq
|
||||
- RABBITMQ_SERVER_USER=guest
|
||||
- RABBITMQ_SERVER_PASS=guest
|
||||
|
@ -29,7 +29,7 @@ services:
|
|||
image: onlyoffice/4testing-documentserver:latest
|
||||
depends_on:
|
||||
- onlyoffice-documentserver-data
|
||||
- onlyoffice-mysql
|
||||
- onlyoffice-postgresql
|
||||
- onlyoffice-redis
|
||||
- onlyoffice-rabbitmq
|
||||
environment:
|
||||
|
@ -92,24 +92,23 @@ services:
|
|||
expose:
|
||||
- '5672'
|
||||
|
||||
onlyoffice-mysql:
|
||||
container_name: onlyoffice-mysql
|
||||
image: mysql:5.5
|
||||
onlyoffice-postgresql:
|
||||
container_name: onlyoffice-postgresql
|
||||
image: postgres:9.5
|
||||
environment:
|
||||
- MYSQL_DATABASE=onlyoffice
|
||||
- MYSQL_USER=root
|
||||
- MYSQL_ALLOW_EMPTY_PASSWORD='true'
|
||||
- POSTGRES_DB=onlyoffice
|
||||
- POSTGRES_USER=onlyoffice
|
||||
networks:
|
||||
- onlyoffice
|
||||
restart: always
|
||||
expose:
|
||||
- '3306'
|
||||
- '5432'
|
||||
volumes:
|
||||
- mysql_data:/var/lib/mysql
|
||||
- postgresql_data:/var/lib/postgresql
|
||||
|
||||
networks:
|
||||
onlyoffice:
|
||||
driver: 'bridge'
|
||||
|
||||
volumes:
|
||||
mysql_data:
|
||||
postgresql_data:
|
||||
|
|
|
@ -31,11 +31,11 @@ JSON="json -q -f ${ONLYOFFICE_DEFAULT_CONFIG}"
|
|||
LOCAL_SERVICES=()
|
||||
|
||||
read_setting(){
|
||||
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)}
|
||||
POSTGRESQL_SERVER_HOST=${POSTGRESQL_SERVER_HOST:-$(${JSON} services.CoAuthoring.sql.dbHost)}
|
||||
POSTGRESQL_SERVER_PORT=${POSTGRESQL_SERVER_PORT:-$(${JSON} services.CoAuthoring.sql.dbPort)}
|
||||
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)}
|
||||
|
||||
RABBITMQ_SERVER_URL=$(${JSON} rabbitmq.url)
|
||||
RABBITMQ_SERVER_HOST=${RABBITMQ_SERVER_HOST:-${RABBITMQ_SERVER_URL#'amqp://'}}
|
||||
|
@ -54,8 +54,8 @@ waiting_for_connection(){
|
|||
done
|
||||
}
|
||||
|
||||
waiting_for_mysql(){
|
||||
waiting_for_connection ${MYSQL_SERVER_HOST} ${MYSQL_SERVER_PORT}
|
||||
waiting_for_postgresql(){
|
||||
waiting_for_connection ${POSTGRESQL_SERVER_HOST} ${POSTGRESQL_SERVER_PORT}
|
||||
}
|
||||
|
||||
waiting_for_rabbitmq(){
|
||||
|
@ -68,12 +68,12 @@ waiting_for_redis(){
|
|||
waiting_for_datacontainer(){
|
||||
waiting_for_connection ${ONLYOFFICE_DATA_CONTAINER_HOST} ${ONLYOFFICE_DATA_CONTAINER_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_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_rabbitmq_setting(){
|
||||
|
@ -87,15 +87,21 @@ update_redis_settings(){
|
|||
${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}"
|
||||
create_postgresql_db(){
|
||||
CONNECTION_PARAMS="-h${POSTGRESQL_SERVER_HOST} -U${POSTGRESQL_SERVER_USER} -w"
|
||||
if [ -n "${POSTGRESQL_SERVER_PASS}" ]; then
|
||||
export PGPASSWORD=${POSTGRESQL_SERVER_PASS}
|
||||
fi
|
||||
|
||||
PSQL="psql -q $CONNECTION_PARAMS"
|
||||
CREATEDB="createdb $CONNECTION_PARAMS"
|
||||
|
||||
# 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"
|
||||
if $PSQL -lt | cut -d\| -f 1 | grep -qw | grep 0; then
|
||||
$CREATEDB $DB_NAME
|
||||
fi
|
||||
|
||||
$PSQL -d "${POSTGRESQL_SERVER_DB_NAME}" -f "${APP_DIR}/server/schema/postgresql/createdb.sql"
|
||||
}
|
||||
|
||||
update_nginx_settings(){
|
||||
|
@ -156,12 +162,12 @@ if [ ${ONLYOFFICE_DATA_CONTAINER_HOST} = "localhost" ]; then
|
|||
read_setting
|
||||
|
||||
# update settings by env variables
|
||||
if [ ${MYSQL_SERVER_HOST} != "localhost" ]; then
|
||||
update_mysql_settings
|
||||
waiting_for_mysql
|
||||
create_mysql_db
|
||||
if [ ${POSTGRESQL_SERVER_HOST} != "localhost" ]; then
|
||||
update_postgresql_settings
|
||||
waiting_for_postgresql
|
||||
create_postgresql_db
|
||||
else
|
||||
LOCAL_SERVICES+=("mysql")
|
||||
LOCAL_SERVICES+=("postgresql")
|
||||
fi
|
||||
|
||||
if [ ${RABBITMQ_SERVER_HOST} != "localhost" ]; then
|
||||
|
@ -190,7 +196,7 @@ for i in ${LOCAL_SERVICES[@]}; do
|
|||
done
|
||||
|
||||
if [ ${ONLYOFFICE_DATA_CONTAINER} != "true" ]; then
|
||||
waiting_for_mysql
|
||||
waiting_for_postgresql
|
||||
waiting_for_rabbitmq
|
||||
waiting_for_redis
|
||||
|
||||
|
|
Loading…
Reference in a new issue