筆記記錄自編譯製作docker版本的onlyoffice映象
一、環境:
1、win11安裝Ubuntu20.04.6.LTS
2、需要開代理
檔案參考:https://helpcenter.onlyoffice.com/installation/docs-community-compile.aspx
二、準備
1、sudo apt-get update
2、sudo apt-get install -y git python openssh-server
3、/etc/profile檔案追加: export ALL_PROXY=socks5://192.168.2.x:7890 export HTTP_PROXY=http://192.168.2.x:7890 export HTTPS_PROXY=http://192.168.2.x:7890
使其生效的命令:source /etc/profile
4、git配置代理 git config --global http.proxy http://192.168.2.x:7890 git config --global https.proxy socks5://192.168.2.x:7890
5、npm配置代理 sudo npm config set proxy http://192.168.2.x:7890 sudo npm config set https-proxy http://192.168.2.x:7890
下載並編譯
git clone https://github.com/ONLYOFFICE/build_tools.git
1、下載完成後先執行deps.py,檢視是否確實依賴環境
python ./tools/linux/deps.py
執行完成會出現packages_complete的檔案
2、還需要改個配置./scripts/base.py
old: # common apps def download(url, dst): return cmd_exe("curl", ["-L", "-o", dst, url])
改後: # common apps def download(url, dst): return cmd_exe("curl", ["-k","-L", "-o", dst, url])
3、進入目錄'./tools/linux/',執行.automate.py server
$ cd build_tools/tools/linux $ ./automate.py server
執行測試
1、sudo apt-get install -y nginx postgresql rabbitmq-server $ sudo -i -u postgres psql -c "CREATE DATABASE onlyoffice;" $ sudo -i -u postgres psql -c "CREATE USER onlyoffice WITH password 'onlyoffice';" $ sudo -i -u postgres psql -c "GRANT ALL privileges ON DATABASE onlyoffice TO onlyoffice;"
執行sql $ psql -hlocalhost -Uonlyoffice -d onlyoffice -f ../../out/linux_64/onlyoffice/documentserver/server/schema/postgresql/createdb.sql
執行測試: $ cd ../../out/linux_64/onlyoffice/documentserver/server/DocService $ NODE_ENV=development-linux NODE_CONFIG_DIR=$PWD/../Common/config ./docservice
瀏覽器訪問:http://192.168.217.183:8000/web-apps/apps/api/documents/api.js
瀏覽器訪問:http://192.168.217.183:8000/info/info.json,可以看到connections的值就是限制訪問的數量。
要修改這個值,
server/Common/constants.js
exports.LICENSE_CONNECTIONS = 100;
編譯prod
$ cd build_tools/tools/linux
$ ./automate.py server PRODUCT_VERSION='8.0.1.0' BUILD_NUMBER='1' NODE_ENV='production'
打包成deb格式
$ # 與目錄build_tools同級
$ sudo apt-get install build-essential m4 npm -y
$ npm install -g pkg
$
$ git clone https://github.com/ONLYOFFICE/document-server-package.git
$
$ cd document-server-package
$ cat << EOF >> Makefile
$ deb_dependencies: \$(DEB_DEPS) #編譯檔案追加dependencies
$ EOF
$ PRODUCT_VERSION='8.0.1.0' BUILD_NUMBER='1' make deb_dependencies
$
$ cd deb/build
$ sudo apt build-dep ./
$ PRODUCT_VERSION='8.0.1.0' BUILD_NUMBER='1' make deb
docker映象
$ # 與目錄build_tools同級
$ git clone https://github.com/ONLYOFFICE/Docker-DocumentServer.git
$ cd ONLYOFFICE/Docker-DocumentServer/
$ # 將生成的deb包copy到當前目錄下的deb資料夾中
$ copy ../document-server-package/deb/xxx.deb ./deb/xxx_amd64.deb
修改後的Dockerfile ARG BASE_IMAGE=ubuntu:22.04 FROM ${BASE_IMAGE} as documentserver LABEL maintainer Ascensio System SIA support@onlyoffice.com 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} 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 && \ locale-gen en_US.UTF-8 && \ echo ttf-mscorefonts-installer msttcorefonts/accepted-mscorefonts-eula select true | debconf-set-selections && \ apt-get -yq install \ adduser \ apt-utils \ bomstrip \ certbot \ cron \ curl \ htop \ libasound2 \ libboost-regex-dev \ libcairo2 \ libcurl3-gnutls \ libcurl4 \ libgtk-3-0 \ libnspr4 \ libnss3 \ libstdc++6 \ libxml2 \ libxss1 \ libxtst6 \ mysql-client \ nano \ net-tools \ netcat-openbsd \ nginx-extras \ postgresql \ postgresql-client \ pwgen \ rabbitmq-server \ redis-server \ software-properties-common \ sudo \ supervisor \ ttf-mscorefonts-installer \ xvfb \ zlib1g && \ if [ $(ls -l /usr/share/fonts/truetype/msttcorefonts | wc -l) -ne 61 ]; \ 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 && \ sed 's|(application/zip.)|\1\n application/wasm wasm;|' -i /etc/nginx/mime.types && \ pg_conftool $PG_VERSION main set listen_addresses 'localhost' && \ 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;" && \ service postgresql stop && \ service redis-server stop && \ service rabbitmq-server stop && \ service supervisor stop && \ service nginx stop && \ rm -rf /var/lib/apt/lists/* ARG PACKAGE_FILE=xxx_amd64.deb 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 deb/$PACKAGE_FILE /tmp/ EXPOSE 80 443 ARG COMPANY_NAME=onlyoffice ARG PRODUCT_NAME=documentserver ARG PRODUCT_EDITION= ARG PACKAGE_VERSION= ARG TARGETARCH ENV COMPANY_NAME=$COMPANY_NAME \ PRODUCT_NAME=$PRODUCT_NAME \ PRODUCT_EDITION=$PRODUCT_EDITION \ DS_DOCKER_INSTALLATION=true RUN chmod 755 /etc/init.d/supervisor && \ sed "s/COMPANY_NAME/${COMPANY_NAME}/g" -i /etc/supervisor/conf.d/.conf && \ service supervisor stop && \ chmod 755 /app/ds/.sh && \ apt-get -yq install /tmp/$PACKAGE_FILE && \ 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 ENTRYPOINT ["/app/ds/run-document-server.sh"]
區別:
構建映象 $ cd Docker-DocumentServer/ $ sudo docker build -t 映象名:tag .
查詢那個檔案包含某個字元 find . -type f -print | xargs grep -li "production"
nodejs除錯
1、進入:/home/mantishell/github/onlyoffice/server/DocService
,執行NODE_ENV=development-linux NODE_CONFIG_DIR=$PWD/../Common/config node sources/server.js
啟動server服務
2、進入:/home/mantishell/github/onlyoffice/server/FileConverter
,執行sudo LD_LIBRARY_PATH=$PWD/bin NODE_ENV=development-linux NODE_CONFIG_DIR=$PWD/../Common/config ./converter
執行檔案轉換服務
3、進入/home/mantishell/github/onlyoffice/document-server-integration/web/documentserver-example/nodejs
,執行NODE_ENV=development-linux NODE_CONFIG_DIR=$PWD/config node ./bin/www
啟動example服務
4、將EditorUIController.isSupportEditFeature的結果返回true,將不會提示Using the free Community version, you can open documents for viewing only. To access mobile web editors, a commercial license is required.