Skip to content

Commit

Permalink
Merge branch release/v8.1.0 into master
Browse files Browse the repository at this point in the history
  • Loading branch information
papacarlo committed Jun 19, 2024
2 parents 40efc5b + b2c9221 commit 0d5588d
Show file tree
Hide file tree
Showing 19 changed files with 495 additions and 14 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/stable-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ jobs:
export PRODUCT_EDITION=${{ matrix.edition }}
export PACKAGE_BASEURL=${{ secrets.REPO_BASEURL }}
export DOCKERFILE=Dockerfile
export BASE_IMAGE=ubuntu:20.04
export BASE_VERSION=20.04
export PG_VERSION=12
export TAG=${VERSION%.*}.${RELEASE_NUMBER}
export PACKAGE_VERSION=$( echo ${VERSION} | sed -E 's/(.*)\./\1-/')
Expand Down
36 changes: 33 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,27 +1,44 @@
ARG BASE_IMAGE=ubuntu:22.04
ARG BASE_VERSION=22.04

ARG BASE_IMAGE=ubuntu:$BASE_VERSION

FROM ${BASE_IMAGE} as documentserver
LABEL maintainer Ascensio System SIA <[email protected]>

ARG BASE_VERSION
ARG PG_VERSION=14

ENV LANG=en_US.UTF-8 LANGUAGE=en_US:en LC_ALL=en_US.UTF-8 DEBIAN_FRONTEND=noninteractive PG_VERSION=${PG_VERSION}
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

RUN echo "#!/bin/sh\nexit 0" > /usr/sbin/policy-rc.d && \
apt-get -y update && \
apt-get -yq install wget apt-transport-https gnupg locales lsb-release && \
wget -q -O /etc/apt/sources.list.d/mssql-release.list https://packages.microsoft.com/config/ubuntu/$BASE_VERSION/prod.list && \
wget -q -O - https://packages.microsoft.com/keys/microsoft.asc | apt-key add - && \
apt-get -y update && \
locale-gen en_US.UTF-8 && \
echo ttf-mscorefonts-installer msttcorefonts/accepted-mscorefonts-eula select true | debconf-set-selections && \
apt-get -yq install \
ACCEPT_EULA=Y apt-get -yq install \
adduser \
apt-utils \
bomstrip \
certbot \
cron \
curl \
htop \
libaio1 \
libasound2 \
libboost-regex-dev \
libcairo2 \
Expand All @@ -34,6 +51,7 @@ RUN echo "#!/bin/sh\nexit 0" > /usr/sbin/policy-rc.d && \
libxml2 \
libxss1 \
libxtst6 \
mssql-tools18 \
mysql-client \
nano \
net-tools \
Expand All @@ -48,6 +66,8 @@ RUN echo "#!/bin/sh\nexit 0" > /usr/sbin/policy-rc.d && \
sudo \
supervisor \
ttf-mscorefonts-installer \
unixodbc-dev \
unzip \
xvfb \
zlib1g && \
if [ $(ls -l /usr/share/fonts/truetype/msttcorefonts | wc -l) -ne 61 ]; \
Expand All @@ -59,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 && \
Expand All @@ -69,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

Expand All @@ -94,6 +120,10 @@ RUN PACKAGE_FILE="${COMPANY_NAME}-${PRODUCT_NAME}${PRODUCT_EDITION}${PACKAGE_VER
sed "s/COMPANY_NAME/${COMPANY_NAME}/g" -i /etc/supervisor/conf.d/*.conf && \
service supervisor stop && \
chmod 755 /app/ds/*.sh && \
printf "\nGO" >> /var/www/$COMPANY_NAME/documentserver/server/schema/mssql/createdb.sql && \
printf "\nGO" >> /var/www/$COMPANY_NAME/documentserver/server/schema/mssql/removetbl.sql && \
printf "\nexit" >> /var/www/$COMPANY_NAME/documentserver/server/schema/oracle/createdb.sql && \
printf "\nexit" >> /var/www/$COMPANY_NAME/documentserver/server/schema/oracle/removetbl.sql && \
rm -f /tmp/$PACKAGE_FILE && \
rm -rf /var/log/$COMPANY_NAME && \
rm -rf /var/lib/apt/lists/*
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,8 @@ Below is the complete list of parameters that can be set using environment varia
- **SSL_KEY_PATH**: The path to the SSL certificate's private key. Defaults to `/var/www/onlyoffice/Data/certs/tls.key`.
- **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`
- **DB_TYPE**: The database type. Supported values are `postgres`, `mariadb` or `mysql`. Defaults to `postgres`.
- **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`, `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.
Expand Down
4 changes: 2 additions & 2 deletions config/supervisor/ds/ds-metrics.conf
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ stdout_logfile_maxbytes=0
stderr_logfile=/var/log/COMPANY_NAME/documentserver/metrics/err.log
stderr_logfile_backups=0
stderr_logfile_maxbytes=0
autostart=true
autorestart=true
autostart=false
autorestart=false
4 changes: 2 additions & 2 deletions docker-bake.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ variable "LATEST" {

### ↓ Variables for UCS build ↓

variable "BASE_IMAGE" {
variable "BASE_VERSION" {
default = ""
}

Expand Down Expand Up @@ -130,7 +130,7 @@ target "documentserver-ucs" {
"COMPANY_NAME": "${COMPANY_NAME}"
"PACKAGE_VERSION": "${PACKAGE_VERSION}"
"PACKAGE_BASEURL": "${PACKAGE_BASEURL}"
"BASE_IMAGE": "${BASE_IMAGE}"
"BASE_VERSION": "${BASE_VERSION}"
"PG_VERSION": "${PG_VERSION}"
}
}
Expand Down
6 changes: 6 additions & 0 deletions oracle/sqlplus
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/sh

CLIENTDIR=/usr/share/instantclient
export LD_LIBRARY_PATH=$CLIENTDIR
$CLIENTDIR/sqlplus $@

127 changes: 122 additions & 5 deletions run-document-server.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ DS_LOG_DIR="${LOG_DIR}/documentserver"
LIB_DIR="/var/lib/${COMPANY_NAME}"
DS_LIB_DIR="${LIB_DIR}/documentserver"
CONF_DIR="/etc/${COMPANY_NAME}/documentserver"
SUPERVISOR_CONF_DIR="/etc/supervisor/conf.d"
IS_UPGRADE="false"

ONLYOFFICE_DATA_CONTAINER=${ONLYOFFICE_DATA_CONTAINER:-false}
Expand Down Expand Up @@ -60,6 +61,25 @@ if [[ -z $SSL_KEY_PATH ]] && [[ -f ${SSL_CERTIFICATES_DIR}/${COMPANY_NAME}.key ]
else
SSL_KEY_PATH=${SSL_KEY_PATH:-${SSL_CERTIFICATES_DIR}/tls.key}
fi

#When set, the well known "root" CAs will be extended with the extra certificates in file
NODE_EXTRA_CA_CERTS=${NODE_EXTRA_CA_CERTS:-${SSL_CERTIFICATES_DIR}/extra-ca-certs.pem}
if [[ -f ${NODE_EXTRA_CA_CERTS} ]]; then
NODE_EXTRA_ENVIRONMENT="${NODE_EXTRA_CA_CERTS}"
elif [[ -f ${SSL_CERTIFICATE_PATH} ]]; then
SSL_CERTIFICATE_SUBJECT=$(openssl x509 -subject -noout -in "${SSL_CERTIFICATE_PATH}" | sed 's/subject=//')
SSL_CERTIFICATE_ISSUER=$(openssl x509 -issuer -noout -in "${SSL_CERTIFICATE_PATH}" | sed 's/issuer=//')

#Add self-signed certificate to trusted list for validating Docs requests to the test example
if [[ -n $SSL_CERTIFICATE_SUBJECT && $SSL_CERTIFICATE_SUBJECT == $SSL_CERTIFICATE_ISSUER ]]; then
NODE_EXTRA_ENVIRONMENT="${SSL_CERTIFICATE_PATH}"
fi
fi

if [[ -n $NODE_EXTRA_ENVIRONMENT ]]; then
sed -i "s|^environment=.*$|&,NODE_EXTRA_CA_CERTS=${NODE_EXTRA_ENVIRONMENT}|" /etc/supervisor/conf.d/*.conf
fi

CA_CERTIFICATES_PATH=${CA_CERTIFICATES_PATH:-${SSL_CERTIFICATES_DIR}/ca-certificates.pem}
SSL_DHPARAM_PATH=${SSL_DHPARAM_PATH:-${SSL_CERTIFICATES_DIR}/dhparam.pem}
SSL_VERIFY_CLIENT=${SSL_VERIFY_CLIENT:-off}
Expand Down Expand Up @@ -154,6 +174,15 @@ read_setting(){
"mariadb"|"mysql")
DB_PORT=${DB_PORT:-"3306"}
;;
"dameng")
DB_PORT=${DB_PORT:-"5236"}
;;
"mssql")
DB_PORT=${DB_PORT:-"1433"}
;;
"oracle")
DB_PORT=${DB_PORT:-"1521"}
;;
"")
DB_PORT=${DB_PORT:-${POSTGRESQL_SERVER_PORT:-$(${JSON} services.CoAuthoring.sql.dbPort)}}
;;
Expand Down Expand Up @@ -232,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(){
Expand All @@ -253,6 +305,7 @@ update_statsd_settings(){
${JSON} -I -e "this.statsd.host = '${METRICS_HOST}'"
${JSON} -I -e "this.statsd.port = '${METRICS_PORT}'"
${JSON} -I -e "this.statsd.prefix = '${METRICS_PREFIX}'"
sed -i -E "s/(autostart|autorestart)=.*$/\1=${METRICS_ENABLED}/g" ${SUPERVISOR_CONF_DIR}/ds-metrics.conf
}

update_db_settings(){
Expand Down Expand Up @@ -345,10 +398,24 @@ update_ds_settings(){
${JSON} -I -e "if(this.services.CoAuthoring.requestDefaults.rejectUnauthorized===undefined)this.services.CoAuthoring.requestDefaults.rejectUnauthorized=false"
fi

if [ "${WOPI_ENABLED}" == "true" ]; then
${JSON} -I -e "if(this.wopi===undefined)this.wopi={}"
${JSON} -I -e "this.wopi.enable = true"
fi
WOPI_PRIVATE_KEY="${DATA_DIR}/wopi_private.key"
WOPI_PUBLIC_KEY="${DATA_DIR}/wopi_public.key"

[ ! -f "${WOPI_PRIVATE_KEY}" ] && echo -n "Generating WOPI private key..." && openssl genpkey -algorithm RSA -outform PEM -out "${WOPI_PRIVATE_KEY}" >/dev/null 2>&1 && echo "Done"
[ ! -f "${WOPI_PUBLIC_KEY}" ] && echo -n "Generating WOPI public key..." && openssl rsa -RSAPublicKey_out -in "${WOPI_PRIVATE_KEY}" -outform "MS PUBLICKEYBLOB" -out "${WOPI_PUBLIC_KEY}" >/dev/null 2>&1 && echo "Done"
WOPI_MODULUS=$(openssl rsa -pubin -inform "MS PUBLICKEYBLOB" -modulus -noout -in "${WOPI_PUBLIC_KEY}" | sed 's/Modulus=//')
WOPI_EXPONENT=$(openssl rsa -pubin -inform "MS PUBLICKEYBLOB" -text -noout -in "${WOPI_PUBLIC_KEY}" | grep -oP '(?<=Exponent: )\d+')

${JSON} -I -e "if(this.wopi===undefined)this.wopi={};"
${JSON} -I -e "this.wopi.enable = ${WOPI_ENABLED}"
${JSON} -I -e "this.wopi.privateKey = '$(awk '{printf "%s\\n", $0}' ${WOPI_PRIVATE_KEY})'"
${JSON} -I -e "this.wopi.privateKeyOld = '$(awk '{printf "%s\\n", $0}' ${WOPI_PRIVATE_KEY})'"
${JSON} -I -e "this.wopi.publicKey = '$(openssl base64 -in ${WOPI_PUBLIC_KEY} -A)'"
${JSON} -I -e "this.wopi.publicKeyOld = '$(openssl base64 -in ${WOPI_PUBLIC_KEY} -A)'"
${JSON} -I -e "this.wopi.modulus = '${WOPI_MODULUS}'"
${JSON} -I -e "this.wopi.modulusOld = '${WOPI_MODULUS}'"
${JSON} -I -e "this.wopi.exponent = ${WOPI_EXPONENT}"
${JSON} -I -e "this.wopi.exponentOld = ${WOPI_EXPONENT}"

if [ "${ALLOW_META_IP_ADDRESS}" = "true" ] || [ "${ALLOW_PRIVATE_IP_ADDRESS}" = "true" ]; then
${JSON} -I -e "if(this.services.CoAuthoring['request-filtering-agent']===undefined)this.services.CoAuthoring['request-filtering-agent']={}"
Expand All @@ -373,6 +440,12 @@ create_postgresql_db(){
sudo -u postgres psql -c "CREATE DATABASE $DB_NAME OWNER $DB_USER;"
}

create_mssql_db(){
MSSQL="/opt/mssql-tools18/bin/sqlcmd -S $DB_HOST,$DB_PORT"

$MSSQL -U $DB_USER -P "$DB_PWD" -C -Q "IF NOT EXISTS (SELECT * FROM sys.databases WHERE name = '$DB_NAME') BEGIN CREATE DATABASE $DB_NAME; END"
}

create_db_tbl() {
case $DB_TYPE in
"postgres")
Expand All @@ -381,6 +454,12 @@ create_db_tbl() {
"mariadb"|"mysql")
create_mysql_tbl
;;
"mssql")
create_mssql_tbl
;;
"oracle")
create_oracle_tbl
;;
esac
}

Expand All @@ -392,6 +471,12 @@ upgrade_db_tbl() {
"mariadb"|"mysql")
upgrade_mysql_tbl
;;
"mssql")
upgrade_mssql_tbl
;;
"oracle")
upgrade_oracle_tbl
;;
esac
}

Expand All @@ -414,6 +499,22 @@ upgrade_mysql_tbl() {
$MYSQL $DB_NAME < "$APP_DIR/server/schema/mysql/createdb.sql" >/dev/null 2>&1
}

upgrade_mssql_tbl() {
CONN_PARAMS="-U $DB_USER -P "$DB_PWD" -C"
MSSQL="/opt/mssql-tools18/bin/sqlcmd -S $DB_HOST,$DB_PORT $CONN_PARAMS"

$MSSQL < "$APP_DIR/server/schema/mssql/removetbl.sql" >/dev/null 2>&1
$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
Expand All @@ -433,6 +534,22 @@ create_mysql_tbl() {
$MYSQL $DB_NAME < "$APP_DIR/server/schema/mysql/createdb.sql" >/dev/null 2>&1
}

create_mssql_tbl() {
create_mssql_db

CONN_PARAMS="-U $DB_USER -P "$DB_PWD" -C"
MSSQL="/opt/mssql-tools18/bin/sqlcmd -S $DB_HOST,$DB_PORT $CONN_PARAMS"

$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
Expand Down Expand Up @@ -528,7 +645,7 @@ for i in ${DS_LIB_DIR}/App_Data/cache/files ${DS_LIB_DIR}/App_Data/docbuilder ${
done

# change folder rights
for i in ${LOG_DIR} ${LIB_DIR}; do
for i in ${DS_LOG_DIR} ${DS_LOG_DIR}-example ${LIB_DIR}; do
chown -R ds:ds "$i"
chmod -R 755 "$i"
done
Expand Down
1 change: 1 addition & 0 deletions tests/damengdb/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
VERSION=latest
19 changes: 19 additions & 0 deletions tests/damengdb/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
## Stand Documentserver with damengdb

### How it works

For deploy stand, you need:

**STEP 1**: Build you own images, do it with command:

```bash
docker compose build
```

**STEP 2**: Wait build and when it finish deploy with command:

```bash
docker compose up -d
```

Thats all.
Loading

0 comments on commit 0d5588d

Please sign in to comment.