Skip to content

Commit

Permalink
dockerfile
Browse files Browse the repository at this point in the history
  • Loading branch information
TruthHun committed Jan 22, 2024
1 parent 67bd439 commit 35d26e8
Show file tree
Hide file tree
Showing 4 changed files with 104 additions and 50 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,6 @@ license.cert
/util/cloudstore
*.crt
/tmp
/web
/web
.DS_Store
/moredoc
8 changes: 8 additions & 0 deletions docker/build.sh
Original file line number Diff line number Diff line change
@@ -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
83 changes: 34 additions & 49 deletions docker/dockerfile
Original file line number Diff line number Diff line change
@@ -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
59 changes: 59 additions & 0 deletions docker/dockerfile-old
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 35d26e8

Please sign in to comment.