diff --git a/.gitignore b/.gitignore index 56d9f8e..0948935 100644 --- a/.gitignore +++ b/.gitignore @@ -19,4 +19,6 @@ license.cert /util/cloudstore *.crt /tmp -/web \ No newline at end of file +/web +.DS_Store +/moredoc \ No newline at end of file diff --git a/docker/build.sh b/docker/build.sh new file mode 100644 index 0000000..7e09fb1 --- /dev/null +++ b/docker/build.sh @@ -0,0 +1,8 @@ +#!/bin/bash + +# Build the docker image, from the dockerfile-env +docker build -t moredoc:latest . + +# Run the docker image +docker run -d --name moredoc-mysql --net docker-network -p 127.0.0.1:33060:3306 -e MYSQL_ROOT_PASSWORD=root mysql:8.0.36 +docker run -it --name moredoc-server --net docker-network -p 127.0.0.1:8880:8880 -v $(pwd):/home/moredoc moredoc:latest \ No newline at end of file diff --git a/docker/dockerfile b/docker/dockerfile index 712b141..a8833cf 100644 --- a/docker/dockerfile +++ b/docker/dockerfile @@ -1,59 +1,44 @@ -FROM ubuntu:jammy-20230126 +FROM ubuntu:22.04 ARG uid=1001 ARG gid=1001 -ARG basedir=workspace ARG DEBIAN_FRONTEND=noninteractive EXPOSE 8880 -# install wget -# install libreoffice -# install mupdf -# install supervisor -# install all needed tools -RUN apt-get update \ - && apt-get install -y wget \ - && apt-get install -y python3 \ - && apt-get install -y libreoffice \ - && apt-get install -y mupdf mupdf-tools \ - && apt-get install -y supervisor \ - && apt-get install -y libopengl0 \ - && apt-get install -y xz-utils \ - && apt-get install -y unzip \ - && rm -rf /var/lib/apt/lists/* -RUN apt-get update \ - && apt-get install -y language-pack-zh-hans \ - && apt-get install -y language-pack-ja \ - && apt-get install -y chinese* \ - && apt-get install -y libreoffice-l10n-zh-cn libreoffice-help-zh-cn \ - && apt-get install -y libreoffice-help-ja \ - && rm -rf /var/lib/apt/lists/* -# install calibre -RUN wget -nv -O- https://download.calibre-ebook.com/linux-installer.py | python3 -c "import sys; main=lambda:sys.stderr.write('Download failed\n'); exec(sys.stdin.read()); main()" - -# Add non root user + +# 替换阿里云镜像源 +# amd +RUN sed -i 's/archive.ubuntu.com/mirrors.aliyun.com/g' /etc/apt/sources.list +# arm +RUN sed -i 's/ports.ubuntu.com/mirrors.aliyun.com/g' /etc/apt/sources.list + +# 安装相关软件依赖 +RUN apt update \ + && apt install -y calibre \ + && apt install -y mupdf mupdf-tools \ + && apt install -y libreoffice \ + && apt install -y imagemagick \ + && apt install -y software-properties-common \ + && add-apt-repository -y ppa:inkscape.dev/stable \ + && apt update \ + && apt install -y inkscape + +# 安装中文相关字体。如需外文相关字体,请自行补充和安装 +RUN apt update \ + && apt install -y language-pack-zh* \ + && apt install -y libreoffice-l10n-zh* \ + && apt install -y libreoffice-help-zh* \ + && apt install -y ttf-wqy-zenhei fonts-wqy-microhei + +# 删除缓存 +RUN rm -rf /var/lib/apt/lists/* + +# 必须要用非root用户启动,以避免sandbox的问题 RUN addgroup --gid $gid --system moredoc\ && adduser --uid $uid --disabled-password --system --gid $gid moredoc -# change to moredoc user + +# 换成moredoc用户 USER moredoc + WORKDIR /home/moredoc -ENV VERSION ce_v1.1.0 -# Get and Unpack Tomcat -RUN wget https://github.com/mnt-ltd/moredoc/releases/download/v1.1.0/moredoc_${VERSION}_linux_amd64.zip -O ~/moredoc_${VERSION}_linux_amd64.zip -RUN cd ~/ && \ - mkdir $basedir && \ - unzip -n ~/moredoc_${VERSION}_linux_amd64.zip -d $basedir/ -COPY entrypoint.sh entrypoint.sh -USER root -RUN chmod 777 entrypoint.sh -RUN chmod -R 777 /home/moredoc -USER moredoc -RUN mkdir $basedir/cache -RUN mkdir $basedir/documents -RUN mkdir $basedir/uploads -VOLUME $basedir/cache -VOLUME $basedir/documents -VOLUME $basedir/uploads -ENTRYPOINT ["./entrypoint.sh"] -ENV MYSQL_CONNECTION=dummy -CMD $MYSQL_CONNECTION +CMD ./moredoc syncdb && ./moredoc serve \ No newline at end of file diff --git a/docker/dockerfile-old b/docker/dockerfile-old new file mode 100644 index 0000000..712b141 --- /dev/null +++ b/docker/dockerfile-old @@ -0,0 +1,59 @@ +FROM ubuntu:jammy-20230126 + +ARG uid=1001 +ARG gid=1001 +ARG basedir=workspace +ARG DEBIAN_FRONTEND=noninteractive +EXPOSE 8880 +# install wget +# install libreoffice +# install mupdf +# install supervisor +# install all needed tools +RUN apt-get update \ + && apt-get install -y wget \ + && apt-get install -y python3 \ + && apt-get install -y libreoffice \ + && apt-get install -y mupdf mupdf-tools \ + && apt-get install -y supervisor \ + && apt-get install -y libopengl0 \ + && apt-get install -y xz-utils \ + && apt-get install -y unzip \ + && rm -rf /var/lib/apt/lists/* +RUN apt-get update \ + && apt-get install -y language-pack-zh-hans \ + && apt-get install -y language-pack-ja \ + && apt-get install -y chinese* \ + && apt-get install -y libreoffice-l10n-zh-cn libreoffice-help-zh-cn \ + && apt-get install -y libreoffice-help-ja \ + && rm -rf /var/lib/apt/lists/* +# install calibre +RUN wget -nv -O- https://download.calibre-ebook.com/linux-installer.py | python3 -c "import sys; main=lambda:sys.stderr.write('Download failed\n'); exec(sys.stdin.read()); main()" + +# Add non root user +RUN addgroup --gid $gid --system moredoc\ + && adduser --uid $uid --disabled-password --system --gid $gid moredoc +# change to moredoc user +USER moredoc +WORKDIR /home/moredoc +ENV VERSION ce_v1.1.0 +# Get and Unpack Tomcat +RUN wget https://github.com/mnt-ltd/moredoc/releases/download/v1.1.0/moredoc_${VERSION}_linux_amd64.zip -O ~/moredoc_${VERSION}_linux_amd64.zip +RUN cd ~/ && \ + mkdir $basedir && \ + unzip -n ~/moredoc_${VERSION}_linux_amd64.zip -d $basedir/ +COPY entrypoint.sh entrypoint.sh +USER root +RUN chmod 777 entrypoint.sh +RUN chmod -R 777 /home/moredoc +USER moredoc +RUN mkdir $basedir/cache +RUN mkdir $basedir/documents +RUN mkdir $basedir/uploads +VOLUME $basedir/cache +VOLUME $basedir/documents +VOLUME $basedir/uploads +ENTRYPOINT ["./entrypoint.sh"] +ENV MYSQL_CONNECTION=dummy +CMD $MYSQL_CONNECTION +