diff --git a/CLAUDE.md b/CLAUDE.md index 4f03f03..27553ce 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -11,7 +11,9 @@ Docker, Docker BuildX, Bash, Nginx, Supervisor, PostgreSQL/MySQL/MariaDB/MSSQL/O ``` Dockerfile — Main image (Ubuntu 24.04 base) production.dockerfile — Stable/release image builder -docker-compose.yml — Local dev (documentserver + postgres + rabbitmq) +docker-compose.yml — Local dev CE (documentserver only, no bundled services) +docker-compose.enterprise.yml — Local dev EE (with postgres, rabbitmq, redis) +docker-compose.developer.yml — Local dev DE (with postgres, rabbitmq, redis) docker-bake.hcl — BuildX multi-platform config Makefile — Build system (image, deploy, clean targets) run-document-server.sh — Main entrypoint script (842 lines) @@ -34,9 +36,12 @@ docker build -t onlyoffice/documentserver . # Run docker run -i -t -d -p 80:80 onlyoffice/documentserver -# Docker Compose (with postgres + rabbitmq) +# Docker Compose Community Edition docker-compose up -d +# Docker Compose Enterprise Edition +docker compose -f docker-compose.enterprise.yml up -d + # Run tests cd tests && ./test.sh ``` diff --git a/Dockerfile b/Dockerfile index 6b53dc0..a69d903 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,7 +2,7 @@ ARG BASE_VERSION=24.04 ARG BASE_IMAGE=ubuntu:$BASE_VERSION -FROM ${BASE_IMAGE} AS documentserver +FROM ${BASE_IMAGE} AS documentserver-base LABEL maintainer="Ascensio System SIA " ARG BASE_VERSION @@ -61,11 +61,7 @@ RUN echo "#!/bin/sh\nexit 101" > /usr/sbin/policy-rc.d && \ net-tools \ netcat-openbsd \ nginx-extras \ - postgresql \ - postgresql-client \ pwgen \ - rabbitmq-server=3.12.1-1ubuntu1.2 \ - redis-server \ sudo \ supervisor \ ttf-mscorefonts-installer \ @@ -73,16 +69,9 @@ RUN echo "#!/bin/sh\nexit 101" > /usr/sbin/policy-rc.d && \ unzip \ xvfb \ xxd \ - zlib1g || dpkg --configure -a && \ - # Added dpkg --configure -a to handle installation issues with rabbitmq-server on arm64 architecture + zlib1g && \ if [ $(find /usr/share/fonts/truetype/msttcorefonts -maxdepth 1 -type f -iname '*.ttf' | wc -l) -lt 30 ]; \ then echo 'msttcorefonts failed to download'; exit 1; fi && \ - echo "SERVER_ADDITIONAL_ERL_ARGS=\"+S 1:1\"" | tee -a /etc/rabbitmq/rabbitmq-env.conf && \ - sed -i "s/bind .*/bind 127.0.0.1/g" /etc/redis/redis.conf && \ - pg_conftool $PG_VERSION main set listen_addresses 'localhost' && \ - service postgresql start && \ - 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.$(dpkg --print-architecture | sed 's/amd64/x64/')-${OC_FILE_SUFFIX}.zip && \ wget -O sqlplus.zip ${OC_DOWNLOAD_URL}/instantclient-sqlplus-linux.$(dpkg --print-architecture | sed 's/amd64/x64/')-${OC_FILE_SUFFIX}.zip && \ unzip -o basic.zip -d /usr/share && \ @@ -90,7 +79,6 @@ RUN echo "#!/bin/sh\nexit 101" > /usr/sbin/policy-rc.d && \ rm -f basic.zip sqlplus.zip && \ mv /usr/share/instantclient_${OC_VER_DIR} /usr/share/instantclient && \ find /usr/lib /lib -name "libaio.so.1$PACKAGE_SUFFIX" -exec bash -c 'ln -sf "$0" "$(dirname "$0")/libaio.so.1"' {} \; && \ - service postgresql stop && \ rm -rf /var/lib/apt/lists/* COPY config/supervisor/supervisor /etc/init.d/ @@ -113,15 +101,35 @@ ENV COMPANY_NAME=$COMPANY_NAME \ DS_PLUGIN_INSTALLATION=false \ DS_DOCKER_INSTALLATION=true +RUN if [ -n "${PRODUCT_EDITION}" ]; then \ + apt-get -y update && \ + ACCEPT_EULA=Y apt-get -yq install \ + redis-server \ + postgresql postgresql-client \ + rabbitmq-server && \ + dpkg --configure -a && \ + sed -i "s/bind .*/bind 127.0.0.1/g" /etc/redis/redis.conf && \ + echo "SERVER_ADDITIONAL_ERL_ARGS=\"+S 1:1\"" | tee -a /etc/rabbitmq/rabbitmq-env.conf && \ + pg_conftool $PG_VERSION main set listen_addresses 'localhost' && \ + service postgresql start && \ + 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;" && \ + service postgresql stop && \ + rm -rf /var/lib/apt/lists/*; fi + RUN PACKAGE_FILE="${COMPANY_NAME}-${PRODUCT_NAME}${PRODUCT_EDITION}${PACKAGE_VERSION:+_$PACKAGE_VERSION}_${TARGETARCH:-$(dpkg --print-architecture)}.deb" && \ wget -q -P /tmp "$PACKAGE_BASEURL/$PACKAGE_FILE" && \ apt-get -y update && \ - service postgresql start && \ + [ -n "${PRODUCT_EDITION}" ] && service postgresql start || true && \ apt-get -yq install /tmp/$PACKAGE_FILE && \ - if [ "${PRODUCT_EDITION}" != "-ee" ] && [ "${PRODUCT_EDITION}" != "-de" ]; then rm -f /etc/supervisor/conf.d/ds-adminpanel.conf && sed -i 's/,adminpanel//' /etc/supervisor/conf.d/ds.conf; fi && \ - PGPASSWORD=$ONLYOFFICE_VALUE dropdb -h localhost -p 5432 -U $ONLYOFFICE_VALUE $ONLYOFFICE_VALUE && \ - sudo -u postgres psql -c "DROP ROLE onlyoffice;" && \ - service postgresql stop && \ + if [ -n "${PRODUCT_EDITION}" ]; then \ + PGPASSWORD=$ONLYOFFICE_VALUE dropdb -h localhost -p 5432 -U $ONLYOFFICE_VALUE $ONLYOFFICE_VALUE && \ + sudo -u postgres psql -c "DROP ROLE onlyoffice;" && \ + service postgresql stop; \ + else \ + rm -f /etc/supervisor/conf.d/ds-adminpanel.conf && \ + sed -i 's/,adminpanel//' /etc/supervisor/conf.d/ds.conf; \ + fi && \ chmod 755 /etc/init.d/supervisor && \ sed "s/COMPANY_NAME/${COMPANY_NAME}/g" -i /etc/supervisor/conf.d/*.conf && \ service supervisor stop && \ @@ -134,6 +142,10 @@ RUN PACKAGE_FILE="${COMPANY_NAME}-${PRODUCT_NAME}${PRODUCT_EDITION}${PACKAGE_VER rm -rf /var/log/$COMPANY_NAME && \ rm -rf /var/lib/apt/lists/* -VOLUME /var/log/$COMPANY_NAME /var/lib/$COMPANY_NAME /var/www/$COMPANY_NAME/Data /var/lib/postgresql /var/lib/rabbitmq /var/lib/redis /usr/share/fonts/truetype/custom - +FROM documentserver-base AS documentserver-community +VOLUME /var/log/$COMPANY_NAME /var/lib/$COMPANY_NAME /var/www/$COMPANY_NAME/Data /usr/share/fonts/truetype/custom +ENTRYPOINT ["/app/ds/run-document-server.sh"] + +FROM documentserver-base AS documentserver-enterprise +VOLUME /var/log/$COMPANY_NAME /var/lib/$COMPANY_NAME /var/www/$COMPANY_NAME/Data /var/lib/postgresql /var/lib/rabbitmq /var/lib/redis /usr/share/fonts/truetype/custom ENTRYPOINT ["/app/ds/run-document-server.sh"] diff --git a/README.md b/README.md index f268ce3..16356ef 100644 --- a/README.md +++ b/README.md @@ -75,16 +75,33 @@ All the data are stored in the specially-designated directories, **data volumes* * **/var/www/onlyoffice/Data** for certificates * **/var/lib/onlyoffice** for file cache * **/var/lib/postgresql** for database +* **/var/lib/rabbitmq** for message broker +* **/var/lib/redis** for cache To get access to your data from outside the container, you need to mount the volumes. It can be done by specifying the '-v' option in the docker run command. +**Community Edition:** + +```bash sudo docker run -i -t -d -p 80:80 \ -v /app/onlyoffice/DocumentServer/logs:/var/log/onlyoffice \ -v /app/onlyoffice/DocumentServer/data:/var/www/onlyoffice/Data \ -v /app/onlyoffice/DocumentServer/lib:/var/lib/onlyoffice \ + onlyoffice/documentserver +``` + +**Enterprise/Developer Edition** — PostgreSQL, RabbitMQ and Redis are bundled in the image: + +```bash + sudo docker run -i -t -d -p 80:80 \ + -v /app/onlyoffice/DocumentServer/logs:/var/log/onlyoffice \ + -v /app/onlyoffice/DocumentServer/data:/var/www/onlyoffice/Data \ + -v /app/onlyoffice/DocumentServer/lib:/var/lib/onlyoffice \ + -v /app/onlyoffice/DocumentServer/db:/var/lib/postgresql \ -v /app/onlyoffice/DocumentServer/rabbitmq:/var/lib/rabbitmq \ -v /app/onlyoffice/DocumentServer/redis:/var/lib/redis \ - -v /app/onlyoffice/DocumentServer/db:/var/lib/postgresql onlyoffice/documentserver + onlyoffice/documentserver-ee # or onlyoffice/documentserver-de for Developer Edition +``` Normally, you do not need to store container data because the container's operation does not depend on its state. Saving data will be useful: * For easy access to container data, such as logs @@ -245,10 +262,24 @@ cd Docker-DocumentServer After that, assuming you have docker-compose installed, execute the following command: +**Community Edition**: + ```bash docker-compose up -d ``` +**Enterprise Edition**: + +```bash +docker compose -f docker-compose.enterprise.yml up -d +``` + +**Developer Edition**: + +```bash +docker compose -f docker-compose.developer.yml up -d +``` + ## Installing ONLYOFFICE Document Server as a part of ONLYOFFICE Workspace ONLYOFFICE Document Server is a part of ONLYOFFICE Workspace that comprises also Community Server, Mail Server, and Control Panel. To install them, follow these easy steps: @@ -281,7 +312,6 @@ sudo docker run --net onlyoffice -i -t -d --restart=always --name onlyoffice-doc -v /app/onlyoffice/DocumentServer/logs:/var/log/onlyoffice \ -v /app/onlyoffice/DocumentServer/data:/var/www/onlyoffice/Data \ -v /app/onlyoffice/DocumentServer/lib:/var/lib/onlyoffice \ - -v /app/onlyoffice/DocumentServer/db:/var/lib/postgresql \ onlyoffice/documentserver ``` diff --git a/docker-bake.hcl b/docker-bake.hcl index 3668923..7b1c278 100644 --- a/docker-bake.hcl +++ b/docker-bake.hcl @@ -87,7 +87,7 @@ variable "UCS_PREFIX" { ### ↑ Variables for UCS build ↑ target "documentserver" { - target = "documentserver" + target = PRODUCT_EDITION == "" ? "documentserver-community" : "documentserver-enterprise" dockerfile = "${DOCKERFILE}" tags = [ "docker.io/${COMPANY_NAME}/${PREFIX_NAME}${PRODUCT_NAME}${PRODUCT_EDITION}:${TAG}" @@ -120,7 +120,7 @@ target "documentserver-stable" { } target "documentserver-ucs" { - target = "documentserver" + target = PRODUCT_EDITION == "" ? "documentserver-community" : "documentserver-enterprise" dockerfile = "${DOCKERFILE}" tags = [ "docker.io/${COMPANY_NAME}/${PRODUCT_NAME}${PRODUCT_EDITION}-ucs:${TAG}" diff --git a/docker-compose.developer.yml b/docker-compose.developer.yml new file mode 100644 index 0000000..a013bd0 --- /dev/null +++ b/docker-compose.developer.yml @@ -0,0 +1,93 @@ +services: + onlyoffice-documentserver: + build: + context: . + target: documentserver-enterprise + args: + - PRODUCT_EDITION=-de + image: onlyoffice/documentserver-de + container_name: onlyoffice-documentserver + depends_on: + - onlyoffice-postgresql + - onlyoffice-rabbitmq + - onlyoffice-redis + environment: + - DB_TYPE=postgres + - DB_HOST=onlyoffice-postgresql + - DB_PORT=5432 + - DB_NAME=onlyoffice + - DB_USER=onlyoffice + - DB_PWD=onlyoffice + - AMQP_URI=amqp://guest:guest@onlyoffice-rabbitmq + - REDIS_SERVER_HOST=onlyoffice-redis + # Uncomment strings below to enable the JSON Web Token validation. + #- JWT_ENABLED=true + #- JWT_SECRET=secret + #- JWT_HEADER=Authorization + #- JWT_IN_BODY=true + ports: + - '80:80' + - '443:443' + healthcheck: + test: ["CMD", "curl", "-f", "http://localhost:8000/info/info.json"] + interval: 30s + retries: 5 + start_period: 60s + timeout: 10s + stdin_open: true + restart: always + stop_grace_period: 60s + 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-rabbitmq: + container_name: onlyoffice-rabbitmq + image: rabbitmq:3 + restart: always + expose: + - '5672' + healthcheck: + test: ["CMD", "rabbitmq-diagnostics", "status"] + interval: 10s + retries: 3 + start_period: 10s + timeout: 10s + + onlyoffice-redis: + container_name: onlyoffice-redis + image: redis:7 + restart: always + expose: + - '6379' + healthcheck: + test: ["CMD", "redis-cli", "ping"] + interval: 10s + retries: 3 + start_period: 10s + timeout: 10s + + onlyoffice-postgresql: + container_name: onlyoffice-postgresql + image: postgres:15 + environment: + - POSTGRES_DB=onlyoffice + - POSTGRES_USER=onlyoffice + - POSTGRES_PASSWORD=onlyoffice + restart: always + expose: + - '5432' + volumes: + - postgresql_data:/var/lib/postgresql + healthcheck: + test: ["CMD-SHELL", "pg_isready -U onlyoffice"] + interval: 10s + retries: 3 + start_period: 10s + timeout: 10s + +volumes: + postgresql_data: diff --git a/docker-compose.enterprise.yml b/docker-compose.enterprise.yml new file mode 100644 index 0000000..1460e20 --- /dev/null +++ b/docker-compose.enterprise.yml @@ -0,0 +1,93 @@ +services: + onlyoffice-documentserver: + build: + context: . + target: documentserver-enterprise + args: + - PRODUCT_EDITION=-ee + image: onlyoffice/documentserver-ee + container_name: onlyoffice-documentserver + depends_on: + - onlyoffice-postgresql + - onlyoffice-rabbitmq + - onlyoffice-redis + environment: + - DB_TYPE=postgres + - DB_HOST=onlyoffice-postgresql + - DB_PORT=5432 + - DB_NAME=onlyoffice + - DB_USER=onlyoffice + - DB_PWD=onlyoffice + - AMQP_URI=amqp://guest:guest@onlyoffice-rabbitmq + - REDIS_SERVER_HOST=onlyoffice-redis + # Uncomment strings below to enable the JSON Web Token validation. + #- JWT_ENABLED=true + #- JWT_SECRET=secret + #- JWT_HEADER=Authorization + #- JWT_IN_BODY=true + ports: + - '80:80' + - '443:443' + healthcheck: + test: ["CMD", "curl", "-f", "http://localhost:8000/info/info.json"] + interval: 30s + retries: 5 + start_period: 60s + timeout: 10s + stdin_open: true + restart: always + stop_grace_period: 60s + 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-rabbitmq: + container_name: onlyoffice-rabbitmq + image: rabbitmq:3 + restart: always + expose: + - '5672' + healthcheck: + test: ["CMD", "rabbitmq-diagnostics", "status"] + interval: 10s + retries: 3 + start_period: 10s + timeout: 10s + + onlyoffice-redis: + container_name: onlyoffice-redis + image: redis:7 + restart: always + expose: + - '6379' + healthcheck: + test: ["CMD", "redis-cli", "ping"] + interval: 10s + retries: 3 + start_period: 10s + timeout: 10s + + onlyoffice-postgresql: + container_name: onlyoffice-postgresql + image: postgres:15 + environment: + - POSTGRES_DB=onlyoffice + - POSTGRES_USER=onlyoffice + - POSTGRES_PASSWORD=onlyoffice + restart: always + expose: + - '5432' + volumes: + - postgresql_data:/var/lib/postgresql + healthcheck: + test: ["CMD-SHELL", "pg_isready -U onlyoffice"] + interval: 10s + retries: 3 + start_period: 10s + timeout: 10s + +volumes: + postgresql_data: diff --git a/docker-compose.yml b/docker-compose.yml index 276f8cc..a77a3f6 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -2,18 +2,10 @@ services: onlyoffice-documentserver: build: context: . - image: onlyoffice/documentserver #[-de,-ee] + target: documentserver-community + image: onlyoffice/documentserver container_name: onlyoffice-documentserver - depends_on: - - onlyoffice-postgresql - - onlyoffice-rabbitmq environment: - - DB_TYPE=postgres - - DB_HOST=onlyoffice-postgresql - - DB_PORT=5432 - - DB_NAME=onlyoffice - - DB_USER=onlyoffice - - AMQP_URI=amqp://guest:guest@onlyoffice-rabbitmq # Uncomment strings below to enable the JSON Web Token validation. #- JWT_ENABLED=true #- JWT_SECRET=secret @@ -37,38 +29,3 @@ services: - /var/lib/onlyoffice/documentserver/App_Data/cache/files - /var/www/onlyoffice/documentserver-example/public/files - /usr/share/fonts - - onlyoffice-rabbitmq: - container_name: onlyoffice-rabbitmq - image: rabbitmq:3 - restart: always - expose: - - '5672' - healthcheck: - test: ["CMD", "rabbitmq-diagnostics", "status"] - interval: 10s - retries: 3 - start_period: 10s - timeout: 10s - - onlyoffice-postgresql: - container_name: onlyoffice-postgresql - image: postgres:15 - environment: - - POSTGRES_DB=onlyoffice - - POSTGRES_USER=onlyoffice - - POSTGRES_HOST_AUTH_METHOD=trust - restart: always - expose: - - '5432' - volumes: - - postgresql_data:/var/lib/postgresql - healthcheck: - test: ["CMD-SHELL", "pg_isready -U onlyoffice"] - interval: 10s - retries: 3 - start_period: 10s - timeout: 10s - -volumes: - postgresql_data: diff --git a/run-document-server.sh b/run-document-server.sh index 326b891..ec4cb7f 100644 --- a/run-document-server.sh +++ b/run-document-server.sh @@ -128,13 +128,8 @@ ALLOW_PRIVATE_IP_ADDRESS=${ALLOW_PRIVATE_IP_ADDRESS:-false} GENERATE_FONTS=${GENERATE_FONTS:-true} -if [[ ${PRODUCT_NAME}${PRODUCT_EDITION} == "documentserver" ]]; then - REDIS_ENABLED=false -else - REDIS_ENABLED=true -fi - -[[ "${PRODUCT_EDITION}" =~ ^-(ee|de)$ ]] && ADMINPANEL_AVAILABLE=true || ADMINPANEL_AVAILABLE=false +[ -n "${PRODUCT_EDITION}" ] && _is_commercial=true || _is_commercial=false +REDIS_AVAILABLE=${_is_commercial} RABBITMQ_AVAILABLE=${_is_commercial} PG_AVAILABLE=${_is_commercial} ADMINPANEL_AVAILABLE=${_is_commercial} ONLYOFFICE_DEFAULT_CONFIG=${CONF_DIR}/local.json ONLYOFFICE_LOG4JS_CONFIG=${CONF_DIR}/log4js/production.json @@ -161,57 +156,62 @@ if [ "${LETS_ENCRYPT_DOMAIN}" != "" -a "${LETS_ENCRYPT_MAIL}" != "" ]; then fi read_setting(){ - deprecated_var POSTGRESQL_SERVER_HOST DB_HOST - deprecated_var POSTGRESQL_SERVER_PORT DB_PORT - deprecated_var POSTGRESQL_SERVER_DB_NAME DB_NAME - deprecated_var POSTGRESQL_SERVER_USER DB_USER - deprecated_var POSTGRESQL_SERVER_PASS DB_PWD - deprecated_var RABBITMQ_SERVER_URL AMQP_URI - deprecated_var AMQP_SERVER_URL AMQP_URI - deprecated_var AMQP_SERVER_TYPE AMQP_TYPE - METRICS_ENABLED="${METRICS_ENABLED:-false}" METRICS_HOST="${METRICS_HOST:-localhost}" METRICS_PORT="${METRICS_PORT:-8125}" METRICS_PREFIX="${METRICS_PREFIX:-.ds}" - DB_HOST=${DB_HOST:-${POSTGRESQL_SERVER_HOST:-$(${JSON} services.CoAuthoring.sql.dbHost)}} - DB_TYPE=${DB_TYPE:-$(${JSON} services.CoAuthoring.sql.type)} - case $DB_TYPE in - "postgres") - DB_PORT=${DB_PORT:-"5432"} - ;; - "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)}} - ;; - *) - echo "ERROR: unknown database type" - exit 1 - ;; - esac - DB_NAME=${DB_NAME:-${POSTGRESQL_SERVER_DB_NAME:-$(${JSON} services.CoAuthoring.sql.dbName)}} - DB_USER=${DB_USER:-${POSTGRESQL_SERVER_USER:-$(${JSON} services.CoAuthoring.sql.dbUser)}} - DB_PWD=${DB_PWD:-${POSTGRESQL_SERVER_PASS:-$(${JSON} services.CoAuthoring.sql.dbPass)}} + if [ ${PG_AVAILABLE} = "true" ]; then + deprecated_var POSTGRESQL_SERVER_HOST DB_HOST + deprecated_var POSTGRESQL_SERVER_PORT DB_PORT + deprecated_var POSTGRESQL_SERVER_DB_NAME DB_NAME + deprecated_var POSTGRESQL_SERVER_USER DB_USER + deprecated_var POSTGRESQL_SERVER_PASS DB_PWD + DB_HOST=${DB_HOST:-${POSTGRESQL_SERVER_HOST:-$(${JSON} services.CoAuthoring.sql.dbHost)}} + DB_TYPE=${DB_TYPE:-$(${JSON} services.CoAuthoring.sql.type)} + case $DB_TYPE in + "postgres") + DB_PORT=${DB_PORT:-"5432"} + ;; + "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)}} + ;; + *) + echo "ERROR: unknown database type" + exit 1 + ;; + esac + DB_NAME=${DB_NAME:-${POSTGRESQL_SERVER_DB_NAME:-$(${JSON} services.CoAuthoring.sql.dbName)}} + DB_USER=${DB_USER:-${POSTGRESQL_SERVER_USER:-$(${JSON} services.CoAuthoring.sql.dbUser)}} + DB_PWD=${DB_PWD:-${POSTGRESQL_SERVER_PASS:-$(${JSON} services.CoAuthoring.sql.dbPass)}} + fi - RABBITMQ_SERVER_URL=${RABBITMQ_SERVER_URL:-$(${JSON} rabbitmq.url)} - AMQP_URI=${AMQP_URI:-${AMQP_SERVER_URL:-${RABBITMQ_SERVER_URL}}} - AMQP_TYPE=${AMQP_TYPE:-${AMQP_SERVER_TYPE:-rabbitmq}} - parse_rabbitmq_url ${AMQP_URI} + if [ ${RABBITMQ_AVAILABLE} = "true" ]; then + deprecated_var RABBITMQ_SERVER_URL AMQP_URI + deprecated_var AMQP_SERVER_URL AMQP_URI + deprecated_var AMQP_SERVER_TYPE AMQP_TYPE + RABBITMQ_SERVER_URL=${RABBITMQ_SERVER_URL:-$(${JSON} rabbitmq.url)} + AMQP_URI=${AMQP_URI:-${AMQP_SERVER_URL:-${RABBITMQ_SERVER_URL}}} + AMQP_TYPE=${AMQP_TYPE:-${AMQP_SERVER_TYPE:-rabbitmq}} + parse_rabbitmq_url ${AMQP_URI} + fi - REDIS_SERVER_HOST=${REDIS_SERVER_HOST:-$(${JSON} services.CoAuthoring.redis.host)} - REDIS_SERVER_PORT=${REDIS_SERVER_PORT:-6379} + if [ ${REDIS_AVAILABLE} = "true" ]; then + REDIS_SERVER_HOST=${REDIS_SERVER_HOST:-$(${JSON} services.CoAuthoring.redis.host)} + REDIS_SERVER_PORT=${REDIS_SERVER_PORT:-6379} + fi DS_LOG_LEVEL=${DS_LOG_LEVEL:-$(${JSON_LOG} categories.default.level)} } @@ -717,50 +717,47 @@ if [ ${ONLYOFFICE_DATA_CONTAINER_HOST} = "localhost" ]; then update_ds_settings - # update settings by env variables - if [ $DB_HOST != "localhost" ]; then - update_db_settings - waiting_for_db - create_db_tbl - else - # change rights for postgres directory - chown -R postgres:postgres ${PG_ROOT} - chmod -R 700 ${PG_ROOT} + if [ ${PG_AVAILABLE} = "true" ]; then + if [ $DB_HOST != "localhost" ]; then + update_db_settings + waiting_for_db + create_db_tbl + else + chown -R postgres:postgres ${PG_ROOT} + chmod -R 700 ${PG_ROOT} - # create new db if it isn't exist - if [ ! -d ${PGDATA} ]; then - create_postgresql_cluster - PG_NEW_CLUSTER=true + if [ ! -d ${PGDATA} ]; then + create_postgresql_cluster + PG_NEW_CLUSTER=true + fi + LOCAL_SERVICES+=("postgresql") fi - LOCAL_SERVICES+=("postgresql") fi - if [ ${AMQP_SERVER_HOST} != "localhost" ]; then - update_rabbitmq_setting - else - # change rights for rabbitmq directory - chown -R rabbitmq:rabbitmq ${RABBITMQ_DATA} - chmod -R go=rX,u=rwX ${RABBITMQ_DATA} - if [ -f ${RABBITMQ_DATA}/.erlang.cookie ]; then - chmod 400 ${RABBITMQ_DATA}/.erlang.cookie + if [ ${RABBITMQ_AVAILABLE} = "true" ]; then + if [ ${AMQP_SERVER_HOST} != "localhost" ]; then + update_rabbitmq_setting + else + chown -R rabbitmq:rabbitmq ${RABBITMQ_DATA} + chmod -R go=rX,u=rwX ${RABBITMQ_DATA} + if [ -f ${RABBITMQ_DATA}/.erlang.cookie ]; then + chmod 400 ${RABBITMQ_DATA}/.erlang.cookie + fi + + sed -i '/^[[:space:]]*ulimit[[:space:]]\+-n[[:space:]]\+/d' /etc/default/rabbitmq-server + printf 'ulimit -n %s\n' "${RABBIT_CONNECTIONS}" >> /etc/default/rabbitmq-server + + LOCAL_SERVICES+=("rabbitmq-server") + rm -rf /var/run/rabbitmq fi - - sed -i '/^[[:space:]]*ulimit[[:space:]]\+-n[[:space:]]\+/d' /etc/default/rabbitmq-server - printf 'ulimit -n %s\n' "${RABBIT_CONNECTIONS}" >> /etc/default/rabbitmq-server - - LOCAL_SERVICES+=("rabbitmq-server") - # allow Rabbitmq startup after container kill - rm -rf /var/run/rabbitmq fi - if [ ${REDIS_ENABLED} = "true" ]; then + if [ ${REDIS_AVAILABLE} = "true" ]; then if [ ${REDIS_SERVER_HOST} != "localhost" ]; then update_redis_settings else - # change rights for redis directory chown -R redis:redis ${REDIS_DATA} chmod -R 750 ${REDIS_DATA} - LOCAL_SERVICES+=("redis-server") fi fi @@ -782,7 +779,7 @@ for i in ${LOCAL_SERVICES[@]}; do service $i start done -if [ "${DB_TYPE}" = "postgres" ]; then +if [ ${PG_AVAILABLE} = "true" ] && [ "${DB_TYPE}" = "postgres" ]; then PG_DB_EXISTS=$(PGPASSWORD="$DB_PWD" psql -h ${DB_HOST} -p${DB_PORT} -U "${DB_USER}" -tAc "SELECT 1 FROM pg_database WHERE datname='${DB_NAME}';" 2>/dev/null) if [ ${PG_NEW_CLUSTER} = "true" ] || [ "${PG_DB_EXISTS}" != "1" ]; then create_postgresql_db @@ -791,11 +788,9 @@ if [ "${DB_TYPE}" = "postgres" ]; then fi if [ ${ONLYOFFICE_DATA_CONTAINER} != "true" ]; then - waiting_for_db - waiting_for_amqp - if [ ${REDIS_ENABLED} = "true" ]; then - waiting_for_redis - fi + [ ${PG_AVAILABLE} = "true" ] && waiting_for_db + [ ${RABBITMQ_AVAILABLE} = "true" ] && waiting_for_amqp + [ ${REDIS_AVAILABLE} = "true" ] && waiting_for_redis if [ "${IS_UPGRADE}" = "true" ]; then upgrade_db_tbl