diff --git a/Dockerfile b/Dockerfile index a826476..7af0962 100644 --- a/Dockerfile +++ b/Dockerfile @@ -8,6 +8,16 @@ LABEL maintainer Ascensio System SIA ARG BASE_VERSION ARG PG_VERSION=14 +ENV OC_RELEASE_NUM=21 +ENV OC_RU_VER=12 +ENV OC_RU_REVISION_VER=0 +ENV OC_RESERVED_NUM=0 +ENV OC_RU_DATE=0 +ENV OC_PATH=${OC_RELEASE_NUM}${OC_RU_VER}000 +ENV OC_FILE_SUFFIX=${OC_RELEASE_NUM}.${OC_RU_VER}.${OC_RU_REVISION_VER}.${OC_RESERVED_NUM}.${OC_RU_DATE}${OC_FILE_SUFFIX}dbru +ENV OC_VER_DIR=${OC_RELEASE_NUM}_${OC_RU_VER} +ENV OC_DOWNLOAD_URL=https://download.oracle.com/otn_software/linux/instantclient/${OC_PATH} + ENV LANG=en_US.UTF-8 LANGUAGE=en_US:en LC_ALL=en_US.UTF-8 DEBIAN_FRONTEND=noninteractive PG_VERSION=${PG_VERSION} BASE_VERSION=${BASE_VERSION} ARG ONLYOFFICE_VALUE=onlyoffice @@ -57,6 +67,7 @@ RUN echo "#!/bin/sh\nexit 0" > /usr/sbin/policy-rc.d && \ supervisor \ ttf-mscorefonts-installer \ unixodbc-dev \ + unzip \ xvfb \ zlib1g && \ if [ $(ls -l /usr/share/fonts/truetype/msttcorefonts | wc -l) -ne 61 ]; \ @@ -68,6 +79,11 @@ RUN echo "#!/bin/sh\nexit 0" > /usr/sbin/policy-rc.d && \ service postgresql restart && \ sudo -u postgres psql -c "CREATE USER $ONLYOFFICE_VALUE WITH password '$ONLYOFFICE_VALUE';" && \ sudo -u postgres psql -c "CREATE DATABASE $ONLYOFFICE_VALUE OWNER $ONLYOFFICE_VALUE;" && \ + wget -O basic.zip ${OC_DOWNLOAD_URL}/instantclient-basic-linux.x64-${OC_FILE_SUFFIX}.zip && \ + wget -O sqlplus.zip ${OC_DOWNLOAD_URL}/instantclient-sqlplus-linux.x64-${OC_FILE_SUFFIX}.zip && \ + unzip -d /usr/share basic.zip && \ + unzip -d /usr/share sqlplus.zip && \ + mv /usr/share/instantclient_${OC_VER_DIR} /usr/share/instantclient && \ service postgresql stop && \ service redis-server stop && \ service rabbitmq-server stop && \ @@ -78,6 +94,7 @@ RUN echo "#!/bin/sh\nexit 0" > /usr/sbin/policy-rc.d && \ COPY config/supervisor/supervisor /etc/init.d/ COPY config/supervisor/ds/*.conf /etc/supervisor/conf.d/ COPY run-document-server.sh /app/ds/run-document-server.sh +COPY oracle/sqlplus /usr/bin/sqlplus EXPOSE 80 443 @@ -105,6 +122,8 @@ RUN PACKAGE_FILE="${COMPANY_NAME}-${PRODUCT_NAME}${PRODUCT_EDITION}${PACKAGE_VER chmod 755 /app/ds/*.sh && \ printf "\nGO" >> /var/www/onlyoffice/documentserver/server/schema/mssql/createdb.sql && \ printf "\nGO" >> /var/www/onlyoffice/documentserver/server/schema/mssql/removetbl.sql && \ + printf "\nexit" >> /var/www/onlyoffice/documentserver/server/schema/oracle/createdb.sql && \ + printf "\nexit" >> /var/www/onlyoffice/documentserver/server/schema/oracle/removetbl.sql && \ rm -f /tmp/$PACKAGE_FILE && \ rm -rf /var/log/$COMPANY_NAME && \ rm -rf /var/lib/apt/lists/* diff --git a/README.md b/README.md index 07addf2..dc2d4e8 100644 --- a/README.md +++ b/README.md @@ -179,7 +179,7 @@ Below is the complete list of parameters that can be set using environment varia - **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` - **NODE_EXTRA_CA_CERTS**: The [NODE_EXTRA_CA_CERTS](https://nodejs.org/api/cli.html#node_extra_ca_certsfile "Node.js documentation") to extend CAs with the extra certificates for Node.js. Defaults to `/var/www/onlyoffice/Data/certs/extra-ca-certs.pem`. -- **DB_TYPE**: The database type. Supported values are `postgres`, `mariadb`, `mysql` or `mssql`. Defaults to `postgres`. +- **DB_TYPE**: The database type. Supported values are `postgres`, `mariadb`, `mysql`, `mssql` or `oracle`. 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 use. Should be existing on container startup. diff --git a/oracle/sqlplus b/oracle/sqlplus new file mode 100755 index 0000000..3bd1bd5 --- /dev/null +++ b/oracle/sqlplus @@ -0,0 +1,6 @@ +#!/bin/sh + +CLIENTDIR=/usr/share/instantclient +export LD_LIBRARY_PATH=$CLIENTDIR +$CLIENTDIR/sqlplus $@ + diff --git a/run-document-server.sh b/run-document-server.sh index fcefc64..98ffddd 100644 --- a/run-document-server.sh +++ b/run-document-server.sh @@ -180,6 +180,9 @@ read_setting(){ "mssql") DB_PORT=${DB_PORT:-"1433"} ;; + "oracle") + DB_PORT=${DB_PORT:-"1521"} + ;; "") DB_PORT=${DB_PORT:-${POSTGRESQL_SERVER_PORT:-$(${JSON} services.CoAuthoring.sql.dbPort)}} ;; @@ -258,8 +261,31 @@ waiting_for_connection(){ done } +waiting_for_db_ready(){ + case $DB_TYPE in + "oracle") + PDB="XEPDB1" + ORACLE_SQL="sqlplus $DB_USER/$DB_PWD@//$DB_HOST:$DB_PORT/$PDB" + DB_TEST="echo \"SELECT version FROM V\$INSTANCE;\" | $ORACLE_SQL 2>/dev/null | grep \"Connected\" | wc -l" + ;; + *) + return + ;; + esac + + for (( i=1; i <= 10; i++ )); do + RES=$(eval $DB_TEST) + if [ "$RES" -ne "0" ]; then + echo "Database is ready" + break + fi + sleep 5 + done +} + waiting_for_db(){ waiting_for_connection $DB_HOST $DB_PORT + waiting_for_db_ready } waiting_for_amqp(){ @@ -427,6 +453,9 @@ create_db_tbl() { "mssql") create_mssql_tbl ;; + "oracle") + create_oracle_tbl + ;; esac } @@ -441,6 +470,9 @@ upgrade_db_tbl() { "mssql") upgrade_mssql_tbl ;; + "oracle") + upgrade_oracle_tbl + ;; esac } @@ -471,6 +503,14 @@ upgrade_mssql_tbl() { $MSSQL < "$APP_DIR/server/schema/mssql/createdb.sql" >/dev/null 2>&1 } +upgrade_oracle_tbl() { + PDB="XEPDB1" + ORACLE_SQL="sqlplus $DB_USER/$DB_PWD@//$DB_HOST:$DB_PORT/$PDB" + + $ORACLE_SQL @$APP_DIR/server/schema/oracle/removetbl.sql >/dev/null 2>&1 + $ORACLE_SQL @$APP_DIR/server/schema/oracle/createdb.sql >/dev/null 2>&1 +} + create_postgresql_tbl() { if [ -n "$DB_PWD" ]; then export PGPASSWORD=$DB_PWD @@ -499,6 +539,13 @@ create_mssql_tbl() { $MSSQL < "$APP_DIR/server/schema/mssql/createdb.sql" >/dev/null 2>&1 } +create_oracle_tbl() { + PDB="XEPDB1" + ORACLE_SQL="sqlplus $DB_USER/$DB_PWD@//$DB_HOST:$DB_PORT/$PDB" + + $ORACLE_SQL @$APP_DIR/server/schema/oracle/createdb.sql >/dev/null 2>&1 +} + update_welcome_page() { WELCOME_PAGE="${APP_DIR}-example/welcome/docker.html" if [[ -e $WELCOME_PAGE ]]; then diff --git a/tests/oracle/README.md b/tests/oracle/README.md new file mode 100644 index 0000000..f548805 --- /dev/null +++ b/tests/oracle/README.md @@ -0,0 +1,17 @@ +## Stand Documentserver with oracle + +### How it works + +For deploy stand: + +**STEP 1**: Build you own images: + +```bash +sudo docker-compose build +``` + +**STEP 2**: Wait build complete and when: + +```bash +sudo docker-compose up -d +``` diff --git a/tests/oracle/create_db_user.sh b/tests/oracle/create_db_user.sh new file mode 100755 index 0000000..831df42 --- /dev/null +++ b/tests/oracle/create_db_user.sh @@ -0,0 +1,28 @@ +#!/bin/bash + +CONNECTION_STR="sqlplus sys/$ORACLE_PASSWORD@//localhost:1521/$ORACLE_DATABASE as sysdba" + +export ORACLE_PWD=$ORACLE_PASSWORD + +#start db +/opt/oracle/runOracle.sh & + +#wait for db up +for (( i=1; i <= 20; i++ )); do + RES=$(echo "SELECT version FROM V\$INSTANCE;" | $CONNECTION_STR 2>/dev/null | grep "Connected" | wc -l) + if [ "$RES" -ne "0" ]; then + echo "Database is ready" + break + fi + sleep 10 +done + +sleep 1 + +#create new db user +$CONNECTION_STR <