ONLYOFFICE二次开发|编译|ARM编译|移动端|连接数|连接器

ONLYOFFICE开发环境搭建 · 语雀

ONLYOFFICE连接器 · 语雀

ONLYOFFICE编译 · 语雀

注:编译部分所有破解代码都在github仓库中,通过build_tools编译完自动完成,无需关注,如果需要了解可以关注我的github仓库

搭建开发环境其实有两种方式

  • Docker搭建
  • 通过nignx运行再转发到Docker后台

上面两种方式只能开发web-apps和sdkjs,另种方式使用Idea远程开发连接到ubuntu,因为后台依赖ubuntu的运行环境,后续将补充搭建后台开发环境。

1. Docker搭建开发环境

1.1. 下载构建工具到你工作空间

git clone https://github.com/ONLYOFFICE/build_tools.git

1.2. 根据官方镜像进行构建

cd build_tools/develop
docker pull onlyoffice/documentserver
docker build -t documentserver-develop .

1.3. 下载需要开发的模块源码

cd ../..
git clone https://github.com/ONLYOFFICE/sdkjs.git
git clone https://github.com/ONLYOFFICE/web-apps.git

1.4. 外部源码挂载Docker内部运行

1.4.1. 运行在Windows

docker run -i -t -p 80:80 --restart=always \
-e ALLOW_PRIVATE_IP_ADDRESS=true \
-v $pwd/sdkjs:/var/www/onlyoffice/documentserver/sdkjs \
-v $pwd/web-apps:/var/www/onlyoffice/documentserver/web-apps \
documentserver-develop

1.4.2. 运行在Linux或Mac

docker run -i -t -p 80:80 --restart=always \
-e ALLOW_PRIVATE_IP_ADDRESS=true \
-v $(pwd)/sdkjs:/var/www/onlyoffice/documentserver/sdkjs \
-v $(pwd)/web-apps:/var/www/onlyoffice/documentserver/web-apps \
documentserver-develop

2. 常见错误

2.1. npm下载PhantomJS依赖失败

目前知道是arm似乎会失败


Done.
npm WARN old lockfile 
npm WARN old lockfile The package-lock.json file was created with an old version of npm,
npm WARN old lockfile so supplemental metadata must be fetched from the registry.
npm WARN old lockfile 
npm WARN old lockfile This is a one-time fix-up, please be patient...
npm WARN old lockfile 
npm WARN deprecated urix@0.1.0: Please see https://github.com/lydell/urix#deprecated
npm WARN deprecated stable@0.1.8: Modern JS already guarantees Array#sort() is a stable sort, so this library is deprecated. See the compatibility table on MDN: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort#browser_compatibility
npm WARN deprecated source-map-url@0.4.1: See https://github.com/lydell/source-map-url#deprecated
npm WARN deprecated source-map-resolve@0.5.3: See https://github.com/lydell/source-map-resolve#deprecated
npm WARN deprecated resolve-url@0.2.1: https://github.com/lydell/resolve-url#deprecated
npm WARN deprecated uuid@3.4.0: Please upgrade  to version 7 or higher.  Older versions may use Math.random() in certain circumstances, which is known to be problematic.  See https://v8.dev/blog/math-random for details.
npm WARN deprecated har-validator@5.1.5: this library is no longer supported
npm WARN deprecated phantomjs-prebuilt@2.1.16: this package is now deprecated
npm WARN deprecated request@2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142
npm WARN deprecated mkdirp@0.5.1: Legacy versions of mkdirp are no longer supported. Please update to mkdirp 1.x. (Note that the API surface has changed to use Promises in 1.x.)
npm WARN deprecated svgo@1.3.2: This SVGO version is no longer supported. Upgrade to v2.x.x.
npm ERR! code 1
npm ERR! path /var/www/onlyoffice/documentserver/web-apps/build/node_modules/phantomjs-prebuilt
npm ERR! command failed
npm ERR! command sh -c node install.js
npm ERR! PhantomJS not found on PATH
npm ERR! Unexpected platform or architecture: linux/arm64
npm ERR! It seems there is no binary available for your platform/architecture
npm ERR! Try to install PhantomJS globally

npm ERR! A complete log of this run can be found in: /root/.npm/_logs/2023-11-23T03_14_20_496Z-debug-0.log

2.1.1. 手动下载PhantomJS

cd DocumentServer/web-apps/build/  && npm i

2.1.2. 再次运行

docker run -i -t -p 80:80 --restart=always \
-e ALLOW_PRIVATE_IP_ADDRESS=true \
-v $(pwd)/sdkjs:/var/www/onlyoffice/documentserver/sdkjs \
-v $(pwd)/web-apps:/var/www/onlyoffice/documentserver/web-apps \
documentserver-develop

2.2. 下载软件包时失败

2.2.1. 修改Dockerfile镜像源

vim build_tools/develop/Dockerfile
FROM onlyoffice/documentserver:latest
RUN if [ "$(uname -m)" = "aarch64" ]; then \
        echo "deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ jammy main restricted universe multiverse" > /etc/apt/sources.list && \
        echo "deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ jammy-updates main restricted universe multiverse" >> /etc/apt/sources.list && \
        echo "deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ jammy-backports main restricted universe multiverse" >> /etc/apt/sources.list && \
        echo "deb http://ports.ubuntu.com/ubuntu-ports/ jammy-security main restricted universe multiverse" >> /etc/apt/sources.list; \
    else \
        echo "deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy main restricted universe multiverse" > /etc/apt/sources.list && \
        echo "deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-updates main restricted universe multiverse" >> /etc/apt/sources.list && \
        echo "deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-backports main restricted universe multiverse" >> /etc/apt/sources.list && \
        echo "deb http://security.ubuntu.com/ubuntu/ jammy-security main restricted universe multiverse" >> /etc/apt/sources.list; \
    fi
RUN apt-get update -y && \
    apt-get install git -y \
    python3 -y \
    openjdk-11-jdk -y \
    bzip2 -y \
    npm -y
RUN npm install -g grunt grunt-cli -y
RUN ln -s /usr/bin/python3 /usr/bin/python && \
    ln -s /usr/bin/pip3 /usr/bin/pip
RUN git clone --depth 1 https://github.com/ONLYOFFICE/build_tools.git var/www/onlyoffice/documentserver/build_tools
RUN sed -i '/documentserver-static-gzip.sh ${ONLYOFFICE_DATA_CONTAINER}/d' /app/ds/run-document-server.sh
RUN sed -i 's/WARN/ALL/g' /etc/onlyoffice/documentserver/log4js/production.json
RUN if [ -s /etc/supervisor/conf.d/ds-example.conf ] ; then sed -i 's,autostart=false,autostart=true,' /etc/supervisor/conf.d/ds-example.conf; fi
RUN if [ -s /app/ds/setup/config/supervisor/ds/ds-example.conf ] ; then sed -i 's,autostart=false,autostart=true,' /app/ds/setup/config/supervisor/ds/ds-example.conf; fi
RUN rm -rf /var/lib/apt/lists/*
ENTRYPOINT python3 /var/www/onlyoffice/documentserver/build_tools/develop/run_build_js.py /var/www/onlyoffice/documentserver $@ && /bin/sh -c /app/ds/run-document-server.sh

1. 连接器源码

前端源码

后端源码

解释:前端是功能源码,后端是license许可的配置,允许高级api使用

2. 开发者

如果你使用的是编译好的也就是破解好的 请忽略下面步骤

参考ONLYOFFICE开发环境搭建

  • 前端源码 粘入正确位置
  • 后端许可证,如果后台用的是官方社区也就是无License ,连接器API是未开启的

此时只需要在代码位置手动开启(只是为了开发方便)

      this._CoAuthoringApi.onLicense = function(res) {
        res['advancedApi'] = true;
        t.callback_OnLicense(res);
      };

3. 最后

请支持正版,只做沟通交流使用

1. Cloud Linux

购买一个国外ubuntu云服务(阿里云或腾讯云购买按量付费)。

  • 4核及以上
  • 8g
  • 100g disk

买国外服务器是因为每个人环境都不一致(网络、配置)导致出现各种问题,按照我的方式基本不会出现问题。

在熟练以后你可以考虑在自己电脑上用Docker进行编译

1.1. 安装环境
sudo apt-get install -y python
1.2. 克隆build_tools仓库
git clone https://github.com/fernfei/build_tools.git
1.3. 切换目录
cd build_tools/tools/linux
1.4. 开始编译
./automate.py --branch=<your_branch>

arm编译

./automate.py --branch=<your_branch> --platform=linux_arm64

Note: <your_branch>是你自己创建的分支名字,这里如果不存在会默认构建master分支的代码

构建完成后结果将在./out目录

2. Docker

2.1. 交叉编译
  1. 创建构建器实例
docker buildx create --name mybuilder --use --platform linux/amd64,linux/arm64,linux/arm/v8

amd

docker buildx build --platform linux/amd64 --tag onlyoffice-document-editors-builder-amd . --load

arm

docker buildx build --platform linux/arm64 --tag onlyoffice-document-editors-builder-arm . --load
  1. 运行

amd

docker run --platform linux/amd64 -v $PWD/out:/build_tools/out onlyoffice-document-editors-builder-amd

arm

docker run --platform linux/arm64 -v $PWD/out:/build_tools/out onlyoffice-document-editors-builder-arm

3. 基于编译后结果构建Docker镜像

3.1. 克隆document-server-package
git clone https://github.com/ONLYOFFICE/document-server-package.git

Note:document-server-package需要与build_tools在同级目录

3.1.1. 生成deb
cd document-server-package
PRODUCT_VERSION='7.5.1' BUILD_NUMBER='1' make deb

解释

  • PRODUCT_VERSION:版本(版本号随意,最好与分支保持一致方便维护)
  • BUILD_NUMBER:序号

结果将在./deb目录

3.1.2. 上传结果
  • 将deb包到oss或者github都行,目的是为了让Dockerfile下载使用

3.2. 克隆Docker-DocumentServer
git clone -b release/v8.1.0 https://github.com/fernfei/Docker-DocumentServer.git
docker build --build-arg PACKAGE_VERSION=8.0.0 --build-arg PACKAGE_REVISION=3 --build-arg PACKAGE_BASEURL=http://image.hi-hufei.com/onlyoffice/  -t fernfei/documentserver-ee:8.0.0-4 .
  • PACKAGE_VERSION 版本
  • PACKAGE_REVISION 数字
  • PACKAGE_BASEURL deb包下载路径前缀
  • deb包位置
3.2.1. 启动
sudo docker run -i -t -d -p 9500:80 -p 9600:8000 \
    -v /root/onlyoffice/DocumentServer/logs:/var/log/onlyoffice  \
    -v /root/onlyoffice/DocumentServer/data:/var/www/onlyoffice/Data  \
    -v /root/onlyoffice/DocumentServer/lib:/var/lib/onlyoffice \
    -v /root/onlyoffice/DocumentServer/rabbitmq:/var/lib/rabbitmq \
    -v /root/onlyoffice/DocumentServer/redis:/var/lib/redis \
    -v /root/onlyoffice/DocumentServer/db:/var/lib/postgresql  fernfei/documentserver:7.5.1-4

Note: 80前端服务接口,8000后端服务接口

http://ip:port/info

可以查看后端基本信息包括connections

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值