ws-office/Dockerfile

100 lines
4.0 KiB
Docker

ARG product_version=8.2.2
ARG build_number=1
ARG oo_root='/var/www/onlyoffice/documentserver'
## Setup
FROM onlyoffice/documentserver:${product_version}.${build_number} as setup-stage
ARG product_version
ARG build_number
ARG oo_root
# package version to get that value using the command inside a base onlyoffice/documentserver container
# dpkg -s onlyoffice-documentserver | grep '^Version:' | cut -d' ' -f2 | cut -d'-' -f2
ENV PRODUCT_VERSION=${product_version}
ENV BUILD_NUMBER=22
ARG build_deps="git make g++ nodejs bzip2"
RUN apt-get update && \
apt-get install -y ca-certificates curl gnupg && \
mkdir -p /etc/apt/keyrings && \
curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg && \
NODE_MAJOR=18 && \
echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_$NODE_MAJOR.x nodistro main" | tee /etc/apt/sources.list.d/nodesource.list && \
apt-get update && \
apt-get install -y ${build_deps} && \
npm install -g pkg grunt grunt-cli && \
apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
RUN node -v
RUN npm -v
WORKDIR /build
## Clone
FROM setup-stage as clone-stage
ARG tag=v${PRODUCT_VERSION}.${BUILD_NUMBER}
RUN git config --global advice.detachedHead false && \
git clone --quiet --branch ${tag} --depth 1 https://github.com/ONLYOFFICE/build_tools.git /build/build_tools && \
git clone --quiet --branch ${tag} --depth 1 https://github.com/ONLYOFFICE/server.git /build/server && \
git clone --quiet --branch ${tag} --depth 1 https://github.com/ONLYOFFICE/sdkjs.git /build/sdkjs && \
git clone --quiet --branch ${tag} --depth 1 https://github.com/ONLYOFFICE/web-apps.git /build/web-apps
# Patch Server
COPY patches/server /build/server/patches
# Needs a fake author to allow commits
RUN git config --global user.email "contact@workstreams.ch" && \
git config --global user.name "WS-Bot" && \
cd /build/server && \
git am --ignore-whitespace patches/*.patch && \
make
## Build
FROM clone-stage as build-stage
# build server with license checks patched
WORKDIR /build/server
RUN make && \
pkg /build/build_tools/out/linux_64/onlyoffice/documentserver/server/FileConverter --targets=node16-linux -o /build/converter && \
pkg /build/build_tools/out/linux_64/onlyoffice/documentserver/server/DocService --targets=node16-linux --options max_old_space_size=4096 -o /build/docservice
# build web-apps with mobile editing
RUN cd /build/web-apps/build && npm install
#COPY patches/web-apps /build/web-apps/patches
COPY patches/web-apps-mobile /build/web-apps-mobile
RUN cd /build/web-apps/build && grunt --addon=web-apps-mobile
#cd /build/web-apps && \
# git am --ignore-whitespace patches/*.patch && \
## Final image
FROM onlyoffice/documentserver:${product_version}.${build_number}
ARG oo_root
ARG COMPANY_NAME=onlyoffice
ARG PRODUCT_NAME=documentserver
ARG DS_SUPERVISOR_CONF=/etc/supervisor/conf.d/ds.conf
# Remove all documentserver-example data
RUN rm -rf /var/www/$COMPANY_NAME/$PRODUCT_NAME-example \
&& rm -rf /etc/$COMPANY_NAME/$PRODUCT_NAME-example \
&& rm -f $DS_SUPERVISOR_CONF \
&& rm -f /etc/nginx/includes/ds-example.conf \
&& ln -s /etc/$COMPANY_NAME/$PRODUCT_NAME/supervisor/ds.conf $DS_SUPERVISOR_CONF
# server
COPY --from=build-stage --chown=ds:ds /build/converter ${oo_root}/server/FileConverter/converter
COPY --from=build-stage --chown=ds:ds /build/docservice ${oo_root}/server/DocService/docservice
# web-apps
COPY --from=build-stage --chown=ds:ds /build/web-apps/deploy/web-apps/apps/documenteditor/mobile ${oo_root}/web-apps/apps/documenteditor/mobile
COPY --from=build-stage --chown=ds:ds /build/web-apps/deploy/web-apps/apps/presentationeditor/mobile ${oo_root}/web-apps/apps/presentationeditor/mobile
COPY --from=build-stage --chown=ds:ds /build/web-apps/deploy/web-apps/apps/spreadsheeteditor/mobile ${oo_root}/web-apps/apps/spreadsheeteditor/mobile
COPY local-production-linux.json /etc/onlyoffice/documentserver/local-production-linux.json