笔记记录自编译制作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 [email protected] 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.