-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from unoconv/feature/create_docker_image
feat: Add inital docker image with docs
- Loading branch information
Showing
4 changed files
with
216 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
FROM alpine:3.17.0 | ||
|
||
ARG BUILD_CONTEXT="build-context" | ||
ARG UID=worker | ||
ARG GID=worker | ||
|
||
LABEL org.opencontainers.image.title="unoserver-docker" | ||
LABEL org.opencontainers.image.description="Custom Docker Image that contains unoserver, LibreOffice and major set of fonts for file format conversions" | ||
LABEL org.opencontainers.image.licenses="MIT" | ||
LABEL org.opencontainers.image.documentation="https://github.com/unoconv/unoserver-docker/blob/master/README.md" | ||
LABEL org.opencontainers.image.source="https://github.com/unoconv/unoserver-docker" | ||
LABEL org.opencontainers.image.url="https://github.com/unoconv/unoserver-docker" | ||
|
||
WORKDIR / | ||
|
||
RUN addgroup -S ${GID} && adduser -S ${UID} -G ${GID} | ||
|
||
RUN apk add --no-cache \ | ||
bash curl \ | ||
py3-pip \ | ||
libreoffice \ | ||
supervisor | ||
|
||
# fonts - https://wiki.alpinelinux.org/wiki/Fonts | ||
RUN apk add --no-cache \ | ||
font-noto font-noto-cjk font-noto-extra \ | ||
terminus-font \ | ||
ttf-font-awesome \ | ||
ttf-dejavu \ | ||
ttf-freefont \ | ||
ttf-hack \ | ||
ttf-inconsolata \ | ||
ttf-liberation \ | ||
ttf-mononoki \ | ||
ttf-opensans \ | ||
fontconfig && \ | ||
fc-cache -f | ||
|
||
RUN rm $(which wget) && \ | ||
rm -rf /var/cache/apk/* /tmp/* | ||
|
||
# renovate: datasource=repology depName=temurin-17-jdk versioning=loose | ||
ARG VERSION_ADOPTIUM_TEMURIN_JDK="17.0.4.1_p1-r0" | ||
|
||
# install Eclipse Temurin JDK | ||
RUN curl https://packages.adoptium.net/artifactory/api/security/keypair/public/repositories/apk -o /etc/apk/keys/adoptium.rsa.pub && \ | ||
echo 'https://packages.adoptium.net/artifactory/apk/alpine/main' >> /etc/apk/repositories && \ | ||
apk update && apk add temurin-17-jdk=${VERSION_ADOPTIUM_TEMURIN_JDK} | ||
|
||
# https://github.com/unoconv/unoserver/ | ||
RUN pip install -U unoserver | ||
|
||
|
||
# FIX: pyuno path not set (https://gitlab.alpinelinux.org/alpine/aports/-/issues/13359) | ||
# define path | ||
ARG PATH_LO=/usr/lib/libreoffice/program | ||
ARG PATH_SP=/usr/lib/python3.10/site-packages | ||
|
||
RUN \ | ||
# copy unohelper.py | ||
cp "$PATH_LO"/unohelper.py "$PATH_SP"/ && \ | ||
|
||
# prefix path to uno.py | ||
echo -e "\ | ||
import sys, os \n\ | ||
sys.path.append('/usr/lib/libreoffice/program') \n\ | ||
os.putenv('URE_BOOTSTRAP', 'vnd.sun.star.pathname:/usr/lib/libreoffice/program/fundamentalrc')\ | ||
" > "$PATH_SP"/uno.py && \ | ||
# copy the original's content | ||
cat "$PATH_LO"/uno.py >> "$PATH_SP"/uno.py | ||
|
||
# setup supervisor | ||
COPY --chown=${UID}:${GID} ${BUILD_CONTEXT}/supervisor / | ||
RUN chmod +x /config/entrypoint.sh && \ | ||
# mkdir -p /var/log/supervisor && \ | ||
# chown ${UID}:${GID} /var/log/supervisor && \ | ||
# mkdir -p /var/run && \ | ||
chown -R ${UID}:0 /run && \ | ||
chmod -R g=u /run | ||
|
||
USER ${UID} | ||
WORKDIR /home/worker | ||
ENV HOME="/home/worker" | ||
|
||
VOLUME ["/data"] | ||
|
||
ENTRYPOINT ["/config/entrypoint.sh"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,56 @@ | ||
# unoserver-docker | ||
Docker files for making a dockerized unoserver | ||
# Unoserver Docker Image | ||
|
||
To create a Docker image for unoserver | ||
|
||
## The environment | ||
|
||
This Docker image uses Alpine Linux as base image and provides: | ||
|
||
- [LibreOffice](https://www.libreoffice.org/) | ||
|
||
- [unoserver](https://github.com/unoconv/unoserver) | ||
|
||
- Fonts (alpine packages) | ||
- font-noto | ||
- font-noto-cjk | ||
- font-noto-extra | ||
- terminus-font | ||
- ttf-font-awesome | ||
- ttf-dejavu | ||
- ttf-freefont | ||
- ttf-hack | ||
- ttf-inconsolata | ||
- ttf-liberation | ||
- ttf-mononoki | ||
- ttf-opensans | ||
|
||
## How to use it | ||
|
||
Just run: | ||
|
||
docker run -it -v <your directory>:/data/ unoserver/unoserver-docker | ||
|
||
or to convert directly: | ||
|
||
docker run -it -v <your directory>:/data/ unoserver/unoserver-docker unoconvert /data/document.docx /data/document.pdf | ||
|
||
Docker maps your directory with /data directory in the container. | ||
|
||
You might need to add the option `:z` or `:Z` like `<your directory>:/data/:z` or `<your directory>:/data/:Z` if you are using SELinux. See [Docker docs](https://docs.docker.com/storage/bind-mounts/#configure-the-selinux-label) or [Podman docs](https://docs.podman.io/en/latest/markdown/podman-run.1.html#volume-v-source-volume-host-dir-container-dir-options). | ||
|
||
After you start the container, you can use [unoconvert](https://github.com/unoconv/unoserver#unoconvert) command to convert documents using LibreOffice. | ||
|
||
|
||
## How to contribute / do it yourself? | ||
|
||
### Requirements | ||
|
||
You need the following tools: | ||
|
||
- A bash compliant command line | ||
|
||
- Docker installed and in your path | ||
|
||
### How to build | ||
|
||
docker build . |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#!/bin/bash | ||
set -e -u | ||
|
||
# default parameters for supervisord | ||
SUPERVISOR_PARAMS='-c /etc/supervisord.conf' | ||
|
||
export PS1='\u@\h:\w\$ ' | ||
|
||
# if tty then assume that container is interactive | ||
if [ ! -t 0 ]; then | ||
echo "Running image in detached mode is probably not meaningful." | ||
echo "Use interactive mode (-it), e.g. 'docker run -v /tmp:/data -it unoserver/unoserver-docker'." | ||
exit 1 | ||
fi | ||
|
||
export UNIX_HTTP_SERVER_PASSWORD=${UNIX_HTTP_SERVER_PASSWORD:-`cat /proc/sys/kernel/random/uuid`} | ||
|
||
# run supervisord detached... | ||
supervisord $SUPERVISOR_PARAMS | ||
|
||
# wait until unoserver started and listens on port 2002. | ||
echo "Waiting for unoserver to start ..." | ||
while [ -z "`netstat -tln | grep 2002`" ]; do | ||
# echo "Waiting for unoserver to start ..." | ||
sleep 1 | ||
done | ||
echo "unoserver started." | ||
libreoffice --version | ||
|
||
# if commands have been passed to container run them and exit, else start bash | ||
if [[ $@ ]]; then | ||
eval $@ | ||
else | ||
/bin/bash | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
[supervisord] | ||
pidfile = /var/run/supervisord.pid | ||
|
||
# Note that at log level debug, the supervisord log file will record the stderr/stdout output | ||
# of its child processes and extended info info about process state changes, | ||
# which is useful for debugging a process which isn’t starting properly. | ||
# and also makes it available using `docker logs [container]` | ||
#logfile = /var/log/supervisor/supervisord.log | ||
logfile = /dev/stdout | ||
logfile_maxbytes = 0 | ||
loglevel = info | ||
|
||
# needed for supervisor to work | ||
[unix_http_server] | ||
file = /var/run/supervisor.sock | ||
chmod = 0700 | ||
username = admin | ||
password = %(ENV_UNIX_HTTP_SERVER_PASSWORD)s | ||
|
||
# needed for supervisor to work | ||
[rpcinterface:supervisor] | ||
supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface | ||
|
||
# [inet_http_server] | ||
# port = 127.0.0.1:9001 | ||
# username = admin | ||
# password = %(ENV_INET_HTTP_SERVER_PASSWORD) | ||
|
||
[supervisorctl] | ||
serverurl = unix:///var/run/supervisor.sock | ||
|
||
[program:unoserver] | ||
command = unoserver | ||
#stdout_logfile = /var/log/supervisor/%(program_name)s.log | ||
stdout_logfile = /dev/stdout | ||
stderr_logfile = /dev/stderr | ||
stdout_logfile_maxbytes = 0 | ||
stderr_logfile_maxbytes = 0 |