diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..084cddc --- /dev/null +++ b/.travis.yml @@ -0,0 +1,131 @@ +language: generic + +dist: trusty + +env: + # community edition + - config: standalone.yml + + # integration edition + - config: standalone.yml + PRODUCT_NAME: documentserver-ie + + + # certificates (default tls if onlyoffice not exists) + - config: certs.yml + ssl: true + + # certificates (default onlyoffice if exists) + - config: certs.yml + ssl: true + private_key: onlyoffice.key + certificate_request: onlyoffice.csr + certificate: onlyoffice.crt + + # custom certificates + - config: certs-customized.yml + ssl: true + private_key: mycert.key + certificate_request: mycert.csr + certificate: mycert.crt + SSL_CERTIFICATE_PATH: /var/www/onlyoffice/Data/certs/mycert.crt + SSL_KEY_PATH: /var/www/onlyoffice/Data/certs/mycert.key + + + # postgresql 12 + - config: postgres.yml + POSTGRES_VERSION: 12 + + # postgresql 11 + - config: postgres.yml + POSTGRES_VERSION: 11 + + # postgresql 10 + - config: postgres.yml + POSTGRES_VERSION: 10 + + # postgresql 9 + - config: postgres.yml + POSTGRES_VERSION: 9 + + # postgresql 9.5 + - config: postgres.yml + + # postgresql custom values + - config: postgres.yml + DB_NAME: mydb + DB_USER: myuser + DB_PWD: password + POSTGRES_DB: mydb + POSTGRES_USER: myuser + + # postgresql deprecated variables + - config: postgres-old.yml + + + # mysql 8 + - config: mysql.yml + MYSQL_VERSION: 8 + + # mysql 5 + - config: mysql.yml + MYSQL_VERSION: 5 + + # mysql 5.7 + - config: mysql.yml + + + # mariadb 10 + - config: mariadb.yml + MARIADB_VERSION: 10 + + # mariadb 10.5 + - config: mariadb.yml + + + - config: activemq.yml + ACTIVEMQ_VERSION: latest + + # activemq 5.14.3 + - config: activemq.yml + + + # rabbitmq latest + - config: rabbitmq.yml + + # rabbitmq 3 + - config: rabbitmq.yml + RABBITMQ_VERSION: 3 + + # rabbitmq old variables + - config: rabbitmq-old.yml + + + # redis latest with community edition + - config: redis.yml + + # redis latest with integraion edition + - config: redis.yml + PRODUCT_NAME: documentserver-ie + + # redis 6 + - config: redis.yml + REDIS_VERSION: 6 + + # redis 5 + - config: redis.yml + REDIS_VERSION: 5 + + + # graphite + - config: graphite.yml + +services: + - docker + +script: + # Go to tests dir + - cd ${PWD}/tests + + # Run test. + - ./test.sh diff --git a/Dockerfile b/Dockerfile index ab28521..69e2e2a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,10 +1,7 @@ -ARG ARCH= -FROM ${ARCH}debian:bullseye +FROM ubuntu:20.04 LABEL maintainer Ascensio System SIA -RUN echo "deb http://deb.debian.org/debian bullseye main contrib non-free\ndeb http://deb.debian.org/debian-security/ bullseye-security main contrib non-free\ndeb http://deb.debian.org/debian bullseye-updates main contrib non-free\ndeb http://deb.debian.org/debian bullseye-backports main" > /etc/apt/sources.list - -ENV LANG=en_US.UTF-8 LANGUAGE=en_US:en LC_ALL=en_US.UTF-8 DEBIAN_FRONTEND=noninteractive PG_VERSION=13 +ENV LANG=en_US.UTF-8 LANGUAGE=en_US:en LC_ALL=en_US.UTF-8 DEBIAN_FRONTEND=noninteractive PG_VERSION=12 ARG ONLYOFFICE_VALUE=onlyoffice @@ -36,7 +33,7 @@ RUN echo "#!/bin/sh\nexit 0" > /usr/sbin/policy-rc.d && \ libxml2 \ libxss1 \ libxtst6 \ - mariadb-client \ + mysql-client \ nano \ net-tools \ netcat-openbsd \ @@ -76,19 +73,19 @@ EXPOSE 80 443 ARG COMPANY_NAME=onlyoffice ARG PRODUCT_NAME=documentserver +ARG PACKAGE_URL="http://download.onlyoffice.com/install/documentserver/linux/${COMPANY_NAME}-${PRODUCT_NAME}_amd64.deb" ENV COMPANY_NAME=$COMPANY_NAME \ PRODUCT_NAME=$PRODUCT_NAME -RUN arch=$(arch | sed s/aarch64/arm64/ | sed s/x86_64/amd64/) && \ - wget -q -P /tmp "http://download.onlyoffice.com/install/documentserver/linux/${COMPANY_NAME}-${PRODUCT_NAME}_${arch}.deb" && \ +RUN wget -q -P /tmp "$PACKAGE_URL" && \ apt-get -y update && \ service postgresql start && \ - apt-get -yq install /tmp/$(basename "${COMPANY_NAME}-${PRODUCT_NAME}_${arch}.deb") && \ + apt-get -yq install /tmp/$(basename "$PACKAGE_URL") && \ service postgresql stop && \ service supervisor stop && \ chmod 755 /app/ds/*.sh && \ - rm -f /tmp/"${COMPANY_NAME}-${PRODUCT_NAME}_${arch}.deb" && \ + rm -f /tmp/$(basename "$PACKAGE_URL") && \ rm -rf /var/log/$COMPANY_NAME && \ rm -rf /var/lib/apt/lists/* diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..f840a15 --- /dev/null +++ b/Makefile @@ -0,0 +1,69 @@ +COMPANY_NAME ?= ONLYOFFICE +GIT_BRANCH ?= develop +PRODUCT_NAME ?= DocumentServer +PRODUCT_VERSION ?= 0.0.0 +BUILD_NUMBER ?= 0 +ONLYOFFICE_VALUE ?= onlyoffice +S3_BUCKET ?= repo-doc-onlyoffice-com +RELEASE_BRANCH ?= unstable + +COMPANY_NAME_LOW = $(shell echo $(COMPANY_NAME) | tr A-Z a-z) +PRODUCT_NAME_LOW = $(shell echo $(PRODUCT_NAME) | tr A-Z a-z) +COMPANY_NAME_LOW_ESCAPED = $(subst -,,$(COMPANY_NAME_LOW)) + +PACKAGE_NAME := $(COMPANY_NAME_LOW)-$(PRODUCT_NAME_LOW) +PACKAGE_VERSION := $(PRODUCT_VERSION)-$(BUILD_NUMBER) +PACKAGE_URL := http://$(S3_BUCKET).s3.amazonaws.com/$(COMPANY_NAME_LOW)/$(RELEASE_BRANCH)/ubuntu/$(PACKAGE_NAME)_$(PACKAGE_VERSION)_amd64.deb + +ifeq ($(RELEASE_BRANCH),$(filter $(RELEASE_BRANCH),unstable testing)) + DOCKER_TAG := $(subst -,.,$(PACKAGE_VERSION)) +else + DOCKER_TAG := $(subst -,.,$(PACKAGE_VERSION))-$(subst /,-,$(GIT_BRANCH)) +endif + +DOCKER_IMAGE := $(subst -,,$(COMPANY_NAME_LOW))/4testing-$(PRODUCT_NAME_LOW) +DOCKER_DUMMY := $(COMPANY_NAME_LOW)-$(PRODUCT_NAME_LOW)__$(DOCKER_TAG).dummy +DOCKER_ARCH := $(COMPANY_NAME_LOW)-$(PRODUCT_NAME_LOW)_$(PACKAGE_VERSION).tar.gz +DOCKER_ARCH_URI := $(COMPANY_NAME_LOW)/$(RELEASE_BRANCH)/docker/$(notdir $(DOCKER_ARCH)) + +.PHONY: all clean clean-docker image deploy docker publish + +$(DOCKER_DUMMY): + docker pull ubuntu:20.04 + docker build \ + --build-arg PACKAGE_URL=$(PACKAGE_URL) \ + --build-arg COMPANY_NAME=$(COMPANY_NAME_LOW) \ + --build-arg PRODUCT_NAME=$(PRODUCT_NAME_LOW) \ + --build-arg ONLYOFFICE_VALUE=$(ONLYOFFICE_VALUE) \ + -t $(DOCKER_IMAGE):$(DOCKER_TAG) . && \ + mkdir -p $$(dirname $@) && \ + echo "Done" > $@ + +$(DOCKER_ARCH): $(DOCKER_DUMMY) + docker save $(DOCKER_IMAGE):$(DOCKER_TAG) | \ + gzip > $@ + +all: image + +clean: + rm -rfv *.dummy *.tar.gz + +clean-docker: + docker rmi -f $$(docker images -q $(COMPANY_NAME_LOW)/*) || exit 0 + +image: $(DOCKER_DUMMY) + +deploy: $(DOCKER_DUMMY) + for i in {1..3}; do \ + docker push $(DOCKER_IMAGE):$(DOCKER_TAG) && break || sleep 1m; \ + done +ifeq ($(RELEASE_BRANCH),unstable) + docker tag $(DOCKER_IMAGE):$(DOCKER_TAG) $(DOCKER_IMAGE):latest + for i in {1..3}; do \ + docker push $(DOCKER_IMAGE):latest && break || sleep 1m; \ + done +endif + +publish: $(DOCKER_ARCH) + aws s3 cp --no-progress --acl public-read \ + $(DOCKER_ARCH) s3://$(S3_BUCKET)/$(DOCKER_ARCH_URI) diff --git a/README.md b/README.md index 4baca2c..18fb96e 100644 --- a/README.md +++ b/README.md @@ -1,146 +1,3 @@ -# NOW WORKING FOR `amd64` and `arm64` natively! - -[![Docker Pulls](https://img.shields.io/docker/pulls/jiriks74/onlyoffice-documentserver.svg?color=94398d&labelColor=555555&logoColor=ffffff&style=for-the-badge&label=pulls&logo=docker)](https://hub.docker.com/r/jiriks74/onlyoffice-documentserver) -[![Docker Stars](https://img.shields.io/docker/stars/jiriks74/onlyoffice-documentserver.svg?color=94398d&labelColor=555555&logoColor=ffffff&style=for-the-badge&label=stars&logo=docker)](https://hub.docker.com/r/jiriks74/onlyoffice-documentserver) -[![Docker Size](https://img.shields.io/docker/image-size/jiriks74/onlyoffice-documentserver/latest.svg?color=94398d&labelColor=555555&logoColor=ffffff&style=for-the-badge&label=Size&logo=docker)](https://hub.docker.com/r/jiriks74/onlyoffice-documentserver) - -[![GitHub Stars](https://img.shields.io/github/stars/jiriks74/Docker-DocumentServer.svg?color=94398d&labelColor=555555&logoColor=ffffff&style=for-the-badge&logo=github)](https://github.com/jiriks74/Docker-DocumentServer) -[![GitHub Forks](https://img.shields.io/github/forks/jiriks74/Docker-DocumentServer?color=94398d&label=Forks&logo=github&logoColor=ffffff&style=for-the-badge)](https://github.com/jiriks74/Docker-DocumentServer) - -#### This repository is based on the official `Dockerfile` and `docker-compose.yml` files with all the needed files as well - -#### To see how I did it, look [at this comment](https://github.com/ONLYOFFICE/DocumentServer/issues/152#issuecomment-1061902836) - I used this method and put it in `Dockerfile` so you don't have to mess aroud with your system in any weird ways (like in the mentioned comment) - -## Usage -#### docker-compose with prebuilt image (recommended) -- Docker will pull the correct architecture automatically -
- -```docker-compose -version: '2' -services: - onlyoffice-documentserver: - image: jiriks74/onlyoffice-documentserver:latest - 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=your_secret_key - #- JWT_HEADER=AuthorizationJwt - #- JWT_IN_BODY=true - ports: - - '88:80' - - '443:443' - stdin_open: true - restart: always - stop_grace_period: 120s - 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 - restart: always - expose: - - '5672' - - onlyoffice-postgresql: - container_name: onlyoffice-postgresql - image: postgres:9.5 - environment: - - POSTGRES_DB=onlyoffice - - POSTGRES_USER=onlyoffice - - POSTGRES_HOST_AUTH_METHOD=trust - restart: always - expose: - - '5432' - volumes: - - postgresql_data:/var/lib/postgresql - -volumes: - postgresql_data: -``` - -
- -### Setup `Secret key`with Nextcloud -1. Uncomment four lines starting with `JWT` in `docker-compose` -2. Set your secret on line `JWT_SECRET=yourSecret` -3. Open Nexcloud's `config.php` (by defauld `/var/www/nextcloud/config/config.php`) -4. Add this to the 2nd last line (before the line with `);`) and paste in your secret (3rd last line) -```php - 'onlyoffice' => - array ( - "jwt_secret" => "yourSecret", - "jwt_header" => "AuthorizationJwt" - ) -``` -5. Go to your Nextcloud settings, navigate to Onlyoffice settings -6. Add your server Address and Secret key -7. Save - -#### Tags used on DockerHub -- `latest` - the latest version of the Documentserver - `amd64` version -- Version tags (eg. `7.0.1-37`) - these tags are equal to the Documentserver version of the `onlyoffice-documentserver` debian package used in the image - -## Building the image yourself (not recommended - may take a lot of time) - -#### 1. Clone the repository (for example to your home directory `cd /home/$USER/`) - - `git clone https://github.com/jiriks74/Docker-DocumentServer.git && cd Docker-DocumentServer` - -#### 2. Build the docker image -##### Building only for the architecture you are building the image on (when building on Raspberry Pi result will be `arm64`, when on pc result will be `amd64`) - `docker-compose build` - -##### Building for all supported architectures (you have to have your environment setup for emulation of arm64 with `qemu`) - `docker buildx build --platform linux/arm64,linux/amd64,linux/386 . - -#### 3. Create and start the container - `docker-compose up -d` - - This will start the server. It is set to be automatically started/restarted so as long you have docker running on startup this will start automatically - -## Updating the image yourself -#### 1. Stop and delete the old container - - `docker-compose down` - -#### 2. (optional) Clear the docker cache -#### - ! This will remove all unused cache images ! (good for saving space, bad if you develop with and need cache, but you understand it at that point) - - `docker rmi $(docker images -f "dangling=true" -q)` - -#### 4. Rebuild the image without cache -##### Building only for the architecture you are building the image on (when building on Raspberry Pi result will be `arm64`, when on pc result will be `amd64`) - `docker-compose build` - -##### Building for all supported architectures (you have to have your environment setup for emulation of arm64 with `qemu`) - `docker buildx build --platform linux/arm64,linux/amd64,linux/386 . - -#### 3. Create and start the new container - - `docker-compose up -d` - ---- - -## The rest of this file is the official [`README.md` from OnlyOffice-Documentserver repository](https://github.com/ONLYOFFICE/Docker-DocumentServer). I will not change anything in it, it may not work, but considering the changes I made, it should be fully compatible (beware that you must change the `docker-compose.yml` from building the image locally to using this repository). If you want to change something, make a issue on my repository and we'll figure it out. - -
- - * [Overview](#overview) * [Functionality](#functionality) * [Recommended System Requirements](#recommended-system-requirements) @@ -480,6 +337,3 @@ If you have any problems with or questions about this image, please visit our of [1]: https://forum.onlyoffice.com [2]: https://stackoverflow.com/questions/tagged/onlyoffice - - -
diff --git a/build_and_push_all_images.py b/build_and_push_all_images.py deleted file mode 100644 index aae069a..0000000 --- a/build_and_push_all_images.py +++ /dev/null @@ -1,18 +0,0 @@ -import requests -import os - -response = requests.get("https://api.github.com/repos/ONLYOFFICE/DocumentServer/releases/latest") - -print('docker buildx build --push --platform linux/arm64,linux/amd64 --tag jiriks74/onlyoffice-documentserver:latest .') -os.system(f'docker buildx build --push --platform linux/arm64,linux/amd64 --tag jiriks74/onlyoffice-documentserver:latest .') -print("///////////////////////////////////////////////////////////////////////////") -print('Build and push ":latest" .........................................finished') -print("///////////////////////////////////////////////////////////////////////////") -print() - -print(f'docker buildx build --push --platform linux/arm64,linux/amd64 --tag jiriks74/onlyoffice-documentserver:{response.json()["name"].replace("ONLYOFFICE-DocumentServer-", "")} .') -os.system(f'docker buildx build --push --platform linux/arm64,linux/amd64 --tag jiriks74/onlyoffice-documentserver:{response.json()["name"].replace("ONLYOFFICE-DocumentServer-", "")} .') -print("///////////////////////////////////////////////////////////////////////////") -print(f'Build and push ":{response.json()["name"].replace("ONLYOFFICE-DocumentServer-", "")}".........................................finished') -print("///////////////////////////////////////////////////////////////////////////") - diff --git a/cluster.yml b/cluster.yml new file mode 100644 index 0000000..0cb07c1 --- /dev/null +++ b/cluster.yml @@ -0,0 +1,108 @@ +version: '2.1' + +x-ds-image: + &ds-image + ${COMPANY_NAME:-onlyoffice}/${PRODUCT_NAME:-documentserver-de}:${PRODUCT_VERSION:-latest} + +services: + onlyoffice-documentserver-data: + container_name: onlyoffice-documentserver-data + image: *ds-image + environment: + - ONLYOFFICE_DATA_CONTAINER=true + - DB_HOST=onlyoffice-postgresql + - DB_PORT=5432 + - DB_NAME=onlyoffice + - DB_USER=onlyoffice + - AMQP_URI=amqp://guest:guest@onlyoffice-rabbitmq + - REDIS_SERVER_HOST=onlyoffice-redis + - REDIS_SERVER_PORT=6379 + # Uncomment strings below to enable the JSON Web Token validation. + #- JWT_ENABLED=true + #- JWT_SECRET=secret + #- JWT_HEADER=Authorization + #- JWT_IN_BODY=true + stdin_open: true + restart: always + volumes: + - /etc/onlyoffice + - /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-documentserver: + image: *ds-image + depends_on: + - onlyoffice-documentserver-data + - onlyoffice-postgresql + - onlyoffice-redis + - onlyoffice-rabbitmq + environment: + - ONLYOFFICE_DATA_CONTAINER_HOST=onlyoffice-documentserver-data + - BALANCE=uri depth 3 + - EXCLUDE_PORTS=443 + - HTTP_CHECK=GET /healthcheck + - EXTRA_SETTINGS=http-check expect string true + # Uncomment the string below to redirect HTTP request to HTTPS request. + #- FORCE_SSL=true + stdin_open: true + restart: always + expose: + - '80' + volumes_from: + - onlyoffice-documentserver-data + + onlyoffice-haproxy: + container_name: onlyoffice-haproxy + image: dockercloud/haproxy:1.5.1 + depends_on: + - onlyoffice-documentserver + environment: + - MODE=http + # Uncomment the string below to specify the path of ssl certificates + #- CERT_FOLDER=/certs/ + stdin_open: true + links: + - onlyoffice-documentserver + volumes: + - /var/run/docker.sock:/var/run/docker.sock + # Uncomment the string below to map a ssl certificate from host + # to the proxy container + #- /app/onlyoffice/DocumentServer/data/certs/onlyoffice.pem:/certs/cert1.pem + restart: always + ports: + - '80:80' + - '443:443' + - '1936:1936' + + onlyoffice-redis: + container_name: onlyoffice-redis + image: redis + restart: always + expose: + - '6379' + + onlyoffice-rabbitmq: + container_name: onlyoffice-rabbitmq + image: rabbitmq + restart: always + expose: + - '5672' + + onlyoffice-postgresql: + container_name: onlyoffice-postgresql + image: postgres:9.5 + environment: + - POSTGRES_DB=onlyoffice + - POSTGRES_USER=onlyoffice + - POSTGRES_HOST_AUTH_METHOD=trust + restart: always + expose: + - '5432' + volumes: + - postgresql_data:/var/lib/postgresql + +volumes: + postgresql_data: diff --git a/docker-compose.yml b/docker-compose.yml index 91863c7..51fafb2 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -17,14 +17,14 @@ services: # Uncomment strings below to enable the JSON Web Token validation. #- JWT_ENABLED=true #- JWT_SECRET=secret - #- JWT_HEADER=AuthorizationJwt + #- JWT_HEADER=Authorization #- JWT_IN_BODY=true ports: - '80:80' - '443:443' stdin_open: true restart: always - stop_grace_period: 120s + stop_grace_period: 60s volumes: - /var/www/onlyoffice/Data - /var/log/onlyoffice diff --git a/run-document-server.sh b/run-document-server.sh index 2bcdcc2..c8dcf39 100755 --- a/run-document-server.sh +++ b/run-document-server.sh @@ -38,13 +38,13 @@ if [ "${RELEASE_DATE}" != "${PREV_RELEASE_DATE}" ]; then fi SSL_CERTIFICATES_DIR="${DATA_DIR}/certs" -if [[ -z $SSL_CERTIFICATE_PATH ]] && [[ -f ${SSL_CERTIFICATES_DIR}/onlyoffice.crt ]]; then - SSL_CERTIFICATE_PATH=${SSL_CERTIFICATES_DIR}/onlyoffice.crt +if [[ -z $SSL_CERTIFICATE_PATH ]] && [[ -f ${SSL_CERTIFICATES_DIR}/${COMPANY_NAME}.crt ]]; then + SSL_CERTIFICATE_PATH=${SSL_CERTIFICATES_DIR}/${COMPANY_NAME}.crt else SSL_CERTIFICATE_PATH=${SSL_CERTIFICATE_PATH:-${SSL_CERTIFICATES_DIR}/tls.crt} fi -if [[ -z $SSL_KEY_PATH ]] && [[ -f ${SSL_CERTIFICATES_DIR}/onlyoffice.key ]]; then - SSL_KEY_PATH=${SSL_CERTIFICATES_DIR}/onlyoffice.key +if [[ -z $SSL_KEY_PATH ]] && [[ -f ${SSL_CERTIFICATES_DIR}/${COMPANY_NAME}.key ]]; then + SSL_KEY_PATH=${SSL_CERTIFICATES_DIR}/${COMPANY_NAME}.key else SSL_KEY_PATH=${SSL_KEY_PATH:-${SSL_CERTIFICATES_DIR}/tls.key} fi @@ -67,6 +67,14 @@ NGINX_WORKER_PROCESSES=${NGINX_WORKER_PROCESSES:-1} NGINX_WORKER_CONNECTIONS=${NGINX_WORKER_CONNECTIONS:-$(ulimit -n)} JWT_ENABLED=${JWT_ENABLED:-false} + +# validate user's vars before usinig in json +if [ "${JWT_ENABLED}" == "true" ]; then + JWT_ENABLED="true" +else + JWT_ENABLED="false" +fi + JWT_SECRET=${JWT_SECRET:-secret} JWT_HEADER=${JWT_HEADER:-Authorization} JWT_IN_BODY=${JWT_IN_BODY:-false} @@ -284,33 +292,32 @@ update_rabbitmq_setting(){ } update_redis_settings(){ + ${JSON} -I -e "if(this.services.CoAuthoring.redis===undefined)this.services.CoAuthoring.redis={};" ${JSON} -I -e "this.services.CoAuthoring.redis.host = '${REDIS_SERVER_HOST}'" ${JSON} -I -e "this.services.CoAuthoring.redis.port = '${REDIS_SERVER_PORT}'" } update_ds_settings(){ - if [ "${JWT_ENABLED}" == "true" ]; then - ${JSON} -I -e "this.services.CoAuthoring.token.enable.browser = ${JWT_ENABLED}" - ${JSON} -I -e "this.services.CoAuthoring.token.enable.request.inbox = ${JWT_ENABLED}" - ${JSON} -I -e "this.services.CoAuthoring.token.enable.request.outbox = ${JWT_ENABLED}" + ${JSON} -I -e "this.services.CoAuthoring.token.enable.browser = ${JWT_ENABLED}" + ${JSON} -I -e "this.services.CoAuthoring.token.enable.request.inbox = ${JWT_ENABLED}" + ${JSON} -I -e "this.services.CoAuthoring.token.enable.request.outbox = ${JWT_ENABLED}" - ${JSON} -I -e "this.services.CoAuthoring.secret.inbox.string = '${JWT_SECRET}'" - ${JSON} -I -e "this.services.CoAuthoring.secret.outbox.string = '${JWT_SECRET}'" - ${JSON} -I -e "this.services.CoAuthoring.secret.session.string = '${JWT_SECRET}'" + ${JSON} -I -e "this.services.CoAuthoring.secret.inbox.string = '${JWT_SECRET}'" + ${JSON} -I -e "this.services.CoAuthoring.secret.outbox.string = '${JWT_SECRET}'" + ${JSON} -I -e "this.services.CoAuthoring.secret.session.string = '${JWT_SECRET}'" - ${JSON} -I -e "this.services.CoAuthoring.token.inbox.header = '${JWT_HEADER}'" - ${JSON} -I -e "this.services.CoAuthoring.token.outbox.header = '${JWT_HEADER}'" + ${JSON} -I -e "this.services.CoAuthoring.token.inbox.header = '${JWT_HEADER}'" + ${JSON} -I -e "this.services.CoAuthoring.token.outbox.header = '${JWT_HEADER}'" - ${JSON} -I -e "this.services.CoAuthoring.token.inbox.inBody = ${JWT_IN_BODY}" - ${JSON} -I -e "this.services.CoAuthoring.token.outbox.inBody = ${JWT_IN_BODY}" + ${JSON} -I -e "this.services.CoAuthoring.token.inbox.inBody = ${JWT_IN_BODY}" + ${JSON} -I -e "this.services.CoAuthoring.token.outbox.inBody = ${JWT_IN_BODY}" - if [ -f "${ONLYOFFICE_EXAMPLE_CONFIG}" ] && [ "${JWT_ENABLED}" == "true" ]; then - ${JSON_EXAMPLE} -I -e "this.server.token.enable = ${JWT_ENABLED}" - ${JSON_EXAMPLE} -I -e "this.server.token.secret = '${JWT_SECRET}'" - ${JSON_EXAMPLE} -I -e "this.server.token.authorizationHeader = '${JWT_HEADER}'" - fi + if [ -f "${ONLYOFFICE_EXAMPLE_CONFIG}" ]; then + ${JSON_EXAMPLE} -I -e "this.server.token.enable = ${JWT_ENABLED}" + ${JSON_EXAMPLE} -I -e "this.server.token.secret = '${JWT_SECRET}'" + ${JSON_EXAMPLE} -I -e "this.server.token.authorizationHeader = '${JWT_HEADER}'" fi - + if [ "${USE_UNAUTHORIZED_STORAGE}" == "true" ]; then ${JSON} -I -e "if(this.services.CoAuthoring.requestDefaults===undefined)this.services.CoAuthoring.requestDefaults={}" ${JSON} -I -e "if(this.services.CoAuthoring.requestDefaults.rejectUnauthorized===undefined)this.services.CoAuthoring.requestDefaults.rejectUnauthorized=false" @@ -403,11 +410,13 @@ update_welcome_page() { WELCOME_PAGE="${APP_DIR}-example/welcome/docker.html" if [[ -e $WELCOME_PAGE ]]; then DOCKER_CONTAINER_ID=$(basename $(cat /proc/1/cpuset)) - if [[ -x $(command -v docker) ]]; then - DOCKER_CONTAINER_NAME=$(docker inspect --format="{{.Name}}" $DOCKER_CONTAINER_ID) - sed 's/$(sudo docker ps -q)/'"${DOCKER_CONTAINER_NAME#/}"'/' -i $WELCOME_PAGE - else - sed 's/$(sudo docker ps -q)/'"${DOCKER_CONTAINER_ID::12}"'/' -i $WELCOME_PAGE + if (( ${#DOCKER_CONTAINER_ID} >= 12 )); then + if [[ -x $(command -v docker) ]]; then + DOCKER_CONTAINER_NAME=$(docker inspect --format="{{.Name}}" $DOCKER_CONTAINER_ID) + sed 's/$(sudo docker ps -q)/'"${DOCKER_CONTAINER_NAME#/}"'/' -i $WELCOME_PAGE + else + sed 's/$(sudo docker ps -q)/'"${DOCKER_CONTAINER_ID::12}"'/' -i $WELCOME_PAGE + fi fi fi } diff --git a/tests/activemq.yml b/tests/activemq.yml new file mode 100644 index 0000000..5781c64 --- /dev/null +++ b/tests/activemq.yml @@ -0,0 +1,32 @@ +version: '2.1' +services: + onlyoffice-documentserver: + container_name: onlyoffice-documentserver + build: + context: ../. + environment: + - AMQP_TYPE=${AMQP_TYPE:-activemq} + - AMQP_URI=${AMQP_URI:-amqp://guest:guest@onlyoffice-activemq} + stdin_open: true + restart: always + ports: + - '80:80' + - '443:443' + networks: + - onlyoffice + + onlyoffice-activemq: + container_name: onlyoffice-activemq + image: webcenter/activemq:${ACTIVEMQ_VERSION:-5.14.3} + environment: + - ACTIVEMQ_USERS_guest=${ACTIVEMQ_USERS_guest:-guest} + - ACTIVEMQ_GROUPS_owners=${ACTIVEMQ_GROUPS_owners:-guest} + restart: always + networks: + - onlyoffice + expose: + - '5672' + +networks: + onlyoffice: + driver: 'bridge' diff --git a/tests/certs-customized.yml b/tests/certs-customized.yml new file mode 100644 index 0000000..af73081 --- /dev/null +++ b/tests/certs-customized.yml @@ -0,0 +1,18 @@ +version: '2.1' +services: + onlyoffice-documentserver: + container_name: onlyoffice-documentserver + build: + context: ../. + environment: + - SSL_CERTIFICATE_PATH=${SSL_CERTIFICATE_PATH:-/var/www/onlyoffice/Data/certs/tls.crt} + - SSL_KEY_PATH=${SSL_KEY_PATH:-/var/www/onlyoffice/Data/certs/tls.key} + - CA_CERTIFICATES_PATH=${CA_CERTIFICATES_PATH:-/var/www/onlyoffice/Data/certs/ca-certificates.pem} + - SSL_DHPARAM_PATH=${SSL_DHPARAM_PATH:-/var/www/onlyoffice/Data/certs/dhparam.pem} + stdin_open: true + restart: always + ports: + - '80:80' + - '443:443' + volumes: + - ./data:/var/www/onlyoffice/Data diff --git a/tests/certs.yml b/tests/certs.yml new file mode 100644 index 0000000..77d37ce --- /dev/null +++ b/tests/certs.yml @@ -0,0 +1,13 @@ +version: '2.1' +services: + onlyoffice-documentserver: + container_name: onlyoffice-documentserver + build: + context: ../. + stdin_open: true + restart: always + ports: + - '80:80' + - '443:443' + volumes: + - ./data:/var/www/onlyoffice/Data diff --git a/tests/graphite.yml b/tests/graphite.yml new file mode 100644 index 0000000..2bc4694 --- /dev/null +++ b/tests/graphite.yml @@ -0,0 +1,32 @@ +version: '2.1' +services: + onlyoffice-documentserver: + container_name: onlyoffice-documentserver + build: + context: ../. + depends_on: + - onlyoffice-graphite + environment: + - METRICS_ENABLED=${METRICS_ENABLED:-true} + - METRICS_HOST=${METRICS_HOST:-localhost} + - METRICS_PORT=${METRICS_PORT:-8125} + - METRICS_PREFIX=${METRICS_PREFIX:-ds.} + stdin_open: true + restart: always + expose: + - '2003' + ports: + - '80:80' + volumes: + - ./graphite/statsd:/var/www/onlyoffice/documentserver/server/Metrics/config + + onlyoffice-graphite: + container_name: onlyoffice-graphite + image: graphiteapp/graphite-statsd + environment: + - GRAPHITE_STATSD_HOST=${GRAPHITE_STATSD_HOST:-onlyoffice-documentserver} + - GRAPHITE_TIME_ZONE=${GRAPHITE_TIME_ZONE:-Etc/UTC} + ports: + - '8888:80' + stdin_open: true + restart: always diff --git a/tests/graphite/statsd/config.js b/tests/graphite/statsd/config.js new file mode 100644 index 0000000..2ebffe6 --- /dev/null +++ b/tests/graphite/statsd/config.js @@ -0,0 +1,7 @@ +{ + "graphiteHost": "onlyoffice-graphite", + "graphitePort": 2003, + "port": 8125, + "flushInterval": 60000, + "backends": [ "./backends/graphite.js" ] +} diff --git a/tests/mariadb.yml b/tests/mariadb.yml new file mode 100644 index 0000000..4bb8de5 --- /dev/null +++ b/tests/mariadb.yml @@ -0,0 +1,36 @@ +version: '2.1' +services: + ds: + container_name: ds + build: + context: ../. + depends_on: + - onlyoffice-mariadb + environment: + - DB_TYPE=${DB_TYPE:-mysql} + - DB_HOST=${DB_HOST:-onlyoffice-mariadb} + - DB_PORT=${DB_PORT:-3306} + - DB_NAME=${DB_NAME:-onlyoffice} + - DB_USER=${DB_USER:-onlyoffice} + - DB_PWD=${DB_PWD:-onlyoffice} + stdin_open: true + restart: always + ports: + - '80:80' + + onlyoffice-mariadb: + container_name: onlyoffice-mariadb + image: mariadb:${MARIADB_VERSION:-10.5} + environment: + - MYSQL_DATABASE=${MYSQL_DATABASE:-onlyoffice} + - MYSQL_USER=${MYSQL_USER:-onlyoffice} + - MYSQL_PASSWORD=${MYSQL_PASSWORD:-onlyoffice} + - MYSQL_ALLOW_EMPTY_PASSWORD=${MYSQL_ALLOW_EMPTY_PASSWORD:-yes} + restart: always + volumes: + - mysql_data:/var/lib/mysql + expose: + - '3306' + +volumes: + mysql_data: diff --git a/tests/mysql.yml b/tests/mysql.yml new file mode 100644 index 0000000..20fcd70 --- /dev/null +++ b/tests/mysql.yml @@ -0,0 +1,37 @@ +version: '2.1' +services: + onlyoffice-documentserver: + container_name: onlyoffice-documentserver + build: + context: ../. + depends_on: + - onlyoffice-mysql + environment: + - DB_TYPE=${DB_TYPE:-mysql} + - DB_HOST=${DB_HOST:-onlyoffice-mysql} + - DB_PORT=${DB_PORT:-3306} + - DB_NAME=${DB_NAME:-onlyoffice} + - DB_USER=${DB_USER:-onlyoffice} + - DB_PWD=${DB_PWD:-onlyoffice} + stdin_open: true + restart: always + ports: + - '80:80' + + onlyoffice-mysql: + container_name: onlyoffice-mysql + image: mysql:${MYSQL_VERSION:-5.7} + command: --default-authentication-plugin=mysql_native_password + environment: + - MYSQL_DATABASE=${MYSQL_DATABASE:-onlyoffice} + - MYSQL_USER=${MYSQL_USER:-onlyoffice} + - MYSQL_PASSWORD=${MYSQL_PASSWORD:-onlyoffice} + - MYSQL_ALLOW_EMPTY_PASSWORD=${MYSQL_ALLOW_EMPTY_PASSWORD:-yes} + restart: always + volumes: + - mysql_data:/var/lib/mysql + expose: + - '3306' + +volumes: + mysql_data: diff --git a/tests/postgres-old.yml b/tests/postgres-old.yml new file mode 100644 index 0000000..237246c --- /dev/null +++ b/tests/postgres-old.yml @@ -0,0 +1,34 @@ +version: '2.1' +services: + onlyoffice-documentserver: + container_name: onlyoffice-documentserver + build: + context: ../. + depends_on: + - onlyoffice-postgresql + environment: + - POSTGRESQL_SERVER_HOST=${DB_HOST:-onlyoffice-postgresql} + - POSTGRESQL_SERVER_PORT=${DB_PORT:-5432} + - POSTGRESQL_SERVER_DB_NAME=${DB_NAME:-onlyoffice} + - POSTGRESQL_SERVER_USER=${DB_USER:-onlyoffice} + - POSTGRESQL_SERVER_PASS=${DB_PWD:-onlyoffice} + stdin_open: true + restart: always + ports: + - '80:80' + + onlyoffice-postgresql: + container_name: onlyoffice-postgresql + image: postgres:9.5 + environment: + - POSTGRES_DB=${POSTGRES_DB:-onlyoffice} + - POSTGRES_USER=${POSTGRES_USER:-onlyoffice} + - POSTGRES_HOST_AUTH_METHOD=${POSTGRES_HOST_AUTH_METHOD:-trust} + restart: always + expose: + - '5432' + volumes: + - postgresql_data:/var/lib/postgresql + +volumes: + postgresql_data: diff --git a/tests/postgres.yml b/tests/postgres.yml new file mode 100644 index 0000000..8333b10 --- /dev/null +++ b/tests/postgres.yml @@ -0,0 +1,35 @@ +version: '2.1' +services: + onlyoffice-documentserver: + container_name: onlyoffice-documentserver + build: + context: ../. + depends_on: + - onlyoffice-postgresql + environment: + - DB_TYPE=${DB_TYPE:-postgres} + - DB_HOST=${DB_HOST:-onlyoffice-postgresql} + - DB_PORT=${DB_PORT:-5432} + - DB_NAME=${DB_NAME:-onlyoffice} + - DB_USER=${DB_USER:-onlyoffice} + - DB_PWD=${DB_PWD:-onlyoffice} + stdin_open: true + restart: always + ports: + - '80:80' + + onlyoffice-postgresql: + container_name: onlyoffice-postgresql + image: postgres:${POSTGRES_VERSION:-9.5} + environment: + - POSTGRES_DB=${POSTGRES_DB:-onlyoffice} + - POSTGRES_USER=${POSTGRES_USER:-onlyoffice} + - POSTGRES_HOST_AUTH_METHOD=${POSTGRES_HOST_AUTH_METHOD:-trust} + restart: always + expose: + - '5432' + volumes: + - postgresql_data:/var/lib/postgresql + +volumes: + postgresql_data: diff --git a/tests/rabbitmq-old.yml b/tests/rabbitmq-old.yml new file mode 100644 index 0000000..ce18691 --- /dev/null +++ b/tests/rabbitmq-old.yml @@ -0,0 +1,29 @@ +version: '2.1' +services: + onlyoffice-documentserver: + container_name: onlyoffice-documentserver + build: + context: ../. + environment: + - AMQP_SERVER_TYPE=${AMQP_SERVER_TYPE:-rabbitmq} + - AMQP_SERVER_URL=${AMQP_SERVER_URL:-amqp://guest:guest@onlyoffice-rabbitmq} + stdin_open: true + restart: always + ports: + - '80:80' + - '443:443' + networks: + - onlyoffice + + onlyoffice-rabbitmq: + container_name: onlyoffice-rabbitmq + image: rabbitmq + restart: always + networks: + - onlyoffice + expose: + - '5672' + +networks: + onlyoffice: + driver: 'bridge' diff --git a/tests/rabbitmq.yml b/tests/rabbitmq.yml new file mode 100644 index 0000000..293045c --- /dev/null +++ b/tests/rabbitmq.yml @@ -0,0 +1,29 @@ +version: '2.1' +services: + onlyoffice-documentserver: + container_name: onlyoffice-documentserver + build: + context: ../. + environment: + - AMQP_TYPE=${AMQP_TYPE:-rabbitmq} + - AMQP_URI=${AMQP_URI:-amqp://guest:guest@onlyoffice-rabbitmq} + stdin_open: true + restart: always + ports: + - '80:80' + - '443:443' + networks: + - onlyoffice + + onlyoffice-rabbitmq: + container_name: onlyoffice-rabbitmq + image: rabbitmq:${RABBITMQ_VERSION:-latest} + restart: always + networks: + - onlyoffice + expose: + - '5672' + +networks: + onlyoffice: + driver: 'bridge' diff --git a/tests/redis.yml b/tests/redis.yml new file mode 100644 index 0000000..849be16 --- /dev/null +++ b/tests/redis.yml @@ -0,0 +1,31 @@ +version: '2.1' +services: + onlyoffice-documentserver: + container_name: onlyoffice-documentserver + build: + context: ../. + args: + - PRODUCT_NAME=${PRODUCT_NAME:-documentserver} + environment: + - REDIS_SERVER_HOST=${REDIS_SERVER_HOST:-onlyoffice-redis} + - REDIS_SERVER_PORT=${REDIS_SERVER_PORT:-6379} + stdin_open: true + restart: always + ports: + - '80:80' + - '443:443' + networks: + - onlyoffice + + onlyoffice-redis: + container_name: onlyoffice-redis + image: redis:${REDIS_VERSION:-latest} + restart: always + networks: + - onlyoffice + expose: + - '6379' + +networks: + onlyoffice: + driver: 'bridge' diff --git a/tests/standalone.yml b/tests/standalone.yml new file mode 100644 index 0000000..f3de32f --- /dev/null +++ b/tests/standalone.yml @@ -0,0 +1,12 @@ +version: '2.1' +services: + onlyoffice-documentserver: + container_name: onlyoffice-documentserver + build: + context: ../. + args: + - PRODUCT_NAME=${PRODUCT_NAME:-documentserver} + stdin_open: true + restart: always + ports: + - '80:80' diff --git a/tests/test.sh b/tests/test.sh new file mode 100755 index 0000000..535003a --- /dev/null +++ b/tests/test.sh @@ -0,0 +1,54 @@ +#!/bin/bash + +ssl=${ssl:-false} +private_key=${private_key:-tls.key} +certificate_request=${certificate_request:-tls.csr} +certificate=${certificate:-tls.crt} + +# Generate certificate +if [[ $ssl == "true" ]]; then + url=${url:-"https://localhost"} + + mkdir -p data/certs + pushd data/certs + + openssl genrsa -out ${private_key} 2048 + openssl req \ + -new \ + -subj "/C=US/ST=Denial/L=Springfield/O=Dis/CN=www.example.com" \ + -key ${private_key} \ + -out ${certificate_request} + openssl x509 -req -days 365 -in ${certificate_request} -signkey ${private_key} -out ${certificate} + openssl dhparam -out dhparam.pem 2048 + chmod 400 ${private_key} + + popd +else + url=${url:-"http://localhost"} +fi + +# Check if the yml exists +if [[ ! -f $config ]]; then + echo "File $config doesn't exist!" + exit 1 +fi + +# Run test environment +docker-compose -p ds -f $config up -d + +wakeup_timeout=90 + +# Get documentserver healthcheck status +echo "Wait for service wake up" +sleep $wakeup_timeout +healthcheck_res=$(wget --no-check-certificate -qO - ${url}/healthcheck) + +# Fail if it isn't true +if [[ $healthcheck_res == "true" ]]; then + echo "Healthcheck passed." +else + echo "Healthcheck failed!" + exit 1 +fi + +docker-compose -p ds -f $config down