mirror of
https://github.com/ONLYOFFICE/Docker-DocumentServer.git
synced 2026-02-10 20:45:40 +08:00
Add ORACLE support (#734)
This commit is contained in:
19
Dockerfile
19
Dockerfile
@ -8,6 +8,16 @@ LABEL maintainer Ascensio System SIA <support@onlyoffice.com>
|
||||
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/*
|
||||
|
||||
@ -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.
|
||||
|
||||
6
oracle/sqlplus
Executable file
6
oracle/sqlplus
Executable file
@ -0,0 +1,6 @@
|
||||
#!/bin/sh
|
||||
|
||||
CLIENTDIR=/usr/share/instantclient
|
||||
export LD_LIBRARY_PATH=$CLIENTDIR
|
||||
$CLIENTDIR/sqlplus $@
|
||||
|
||||
@ -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
|
||||
|
||||
17
tests/oracle/README.md
Normal file
17
tests/oracle/README.md
Normal file
@ -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
|
||||
```
|
||||
28
tests/oracle/create_db_user.sh
Executable file
28
tests/oracle/create_db_user.sh
Executable file
@ -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 <<EOF
|
||||
CREATE USER $ORACLE_USER IDENTIFIED BY $ORACLE_PASSWORD;
|
||||
GRANT CREATE SESSION TO $ORACLE_USER;
|
||||
GRANT CREATE TABLE TO $ORACLE_USER;
|
||||
ALTER USER $ORACLE_USER quota unlimited on USERS;
|
||||
EOF
|
||||
38
tests/oracle/docker-compose.yml
Normal file
38
tests/oracle/docker-compose.yml
Normal file
@ -0,0 +1,38 @@
|
||||
version: '2.1'
|
||||
services:
|
||||
onlyoffice-documentserver:
|
||||
container_name: onlyoffice-documentserver
|
||||
build:
|
||||
context: ../../.
|
||||
dockerfile: Dockerfile
|
||||
depends_on:
|
||||
- onlyoffice-oracle
|
||||
environment:
|
||||
- DB_TYPE=${DB_TYPE:-oracle}
|
||||
- DB_HOST=${DB_HOST:-onlyoffice-oracle}
|
||||
- DB_PORT=${DB_PORT:-1521}
|
||||
- DB_NAME=${DB_NAME:-xepdb1}
|
||||
- DB_USER=${DB_USER:-onlyoffice}
|
||||
- DB_PWD=${DB_PWD:-onlyoffice}
|
||||
stdin_open: true
|
||||
restart: always
|
||||
ports:
|
||||
- '80:80'
|
||||
|
||||
onlyoffice-oracle:
|
||||
container_name: onlyoffice-oracle
|
||||
build:
|
||||
context: .
|
||||
dockerfile: oracle.Dockerfile
|
||||
args:
|
||||
- ORACLE_DATABASE=${DB_NAME:-xepdb1}
|
||||
- ORACLE_USER=${DB_USER:-onlyoffice}
|
||||
- ORACLE_PASSWORD=${DB_PWD:-onlyoffice}
|
||||
restart: always
|
||||
volumes:
|
||||
- oracle_data:/opt/oracle/oradata
|
||||
expose:
|
||||
- '1521'
|
||||
|
||||
volumes:
|
||||
oracle_data:
|
||||
15
tests/oracle/oracle.Dockerfile
Normal file
15
tests/oracle/oracle.Dockerfile
Normal file
@ -0,0 +1,15 @@
|
||||
FROM container-registry.oracle.com/database/express:21.3.0-xe as onlyoffice-oracle
|
||||
|
||||
ARG ORACLE_DATABASE=
|
||||
ARG ORACLE_PASSWORD=
|
||||
ARG ORACLE_USER=
|
||||
|
||||
ENV ORACLE_DATABASE=$ORACLE_DATABASE \
|
||||
ORACLE_PASSWORD=$ORACLE_PASSWORD \
|
||||
ORACLE_USER=$ORACLE_USER
|
||||
|
||||
SHELL ["/bin/bash", "-c"]
|
||||
|
||||
COPY create_db_user.sh /tmp/create_db_user.sh
|
||||
|
||||
RUN bash /tmp/create_db_user.sh
|
||||
Reference in New Issue
Block a user