parent
b9f986bd5a
commit
7e2fa43b81
@ -0,0 +1,59 @@
|
|||||||
|
FROM ubuntu:jammy-20230126
|
||||||
|
|
||||||
|
ARG uid=1001
|
||||||
|
ARG gid=1001
|
||||||
|
ARG basedir=workspace
|
||||||
|
ENV VERSION ce_v1.0.0
|
||||||
|
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
|
||||||
|
# Get and Unpack Tomcat
|
||||||
|
RUN wget https://github.com/mnt-ltd/moredoc/releases/download/v1.0.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,0 +1,36 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
log() {
|
||||||
|
local type="$1"; shift
|
||||||
|
printf '%s [%s] [Entrypoint]: %s\n' "$(date --rfc-3339=seconds)" "$type" "$*"
|
||||||
|
}
|
||||||
|
|
||||||
|
moredoc_note() {
|
||||||
|
log Note "$@"
|
||||||
|
}
|
||||||
|
|
||||||
|
_main() {
|
||||||
|
cd ~
|
||||||
|
moredoc_note "Current path is:"
|
||||||
|
pwd
|
||||||
|
moredoc_note "Current folder contains:"
|
||||||
|
ls
|
||||||
|
if [ -f app.toml ]
|
||||||
|
then
|
||||||
|
moredoc_note "Start server"
|
||||||
|
exec ./workspace/moredoc serve
|
||||||
|
else
|
||||||
|
moredoc_note "Init server"
|
||||||
|
ESCAPED_ORIGIN=$(printf '%s\n' "root:root@tcp(localhost:3306)/moredoc?charset=utf8mb4&loc=Local&parseTime=true" | sed -e 's/[\/&]/\\&/g')
|
||||||
|
ESCAPED_REPLACE=$(printf '%s\n' "${MYSQL_CONNECTION}" | sed -e 's/[\/&]/\\&/g')
|
||||||
|
sed "s/$ESCAPED_ORIGIN/$ESCAPED_REPLACE/g" ./workspace/app.example.toml > ./workspace/app.toml
|
||||||
|
ls ./workspace
|
||||||
|
moredoc_note "Init DB"
|
||||||
|
cd workspace/
|
||||||
|
./moredoc syncdb
|
||||||
|
moredoc_note "Start server"
|
||||||
|
exec ./moredoc serve
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
_main "$@"
|
Loading…
Reference in new issue