-
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.
feat: Allow for container to be run in non-interactive (remote) mode (#…
…47) * feat: Allow for container to be run in non-interactive (remote) mode * feat: Upgrade unoserver to 2.0.1 (unoserver version is now set explicitly) * feat: Change to official Eclipse Temurin alpine image * feat: Upgrade to Java 21 * feat: Upgrade to alpine 3.19.1
- Loading branch information
Showing
7 changed files
with
148 additions
and
125 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
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
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,85 @@ | ||
= Unoserver Docker Image | ||
|
||
Docker image for unoserver | ||
|
||
== The environment | ||
|
||
This Docker image uses Alpine Linux as a base image and provides: | ||
|
||
* link:https://www.libreoffice.org/[LibreOffice] | ||
* link:https://github.com/unoconv/unoserver[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 | ||
|
||
=== In interactive mode | ||
|
||
Just run: | ||
|
||
[source,bash] | ||
---- | ||
docker run -it -v <your directory>:/data/ ghcr.io/unoconv/unoserver-docker | ||
---- | ||
|
||
After you start the container, you can use link:https://github.com/unoconv/unoserver#unoconvert[unoconvert] command to convert documents using LibreOffice. | ||
|
||
or to convert directly using unoconvert: | ||
|
||
[source,bash] | ||
---- | ||
docker run -it -v <your directory>:/data/ ghcr.io/unoconv/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 link:https://docs.docker.com/storage/bind-mounts/#configure-the-selinux-label[Docker docs] or link:https://docs.podman.io/en/latest/markdown/podman-run.1.html#volume-v-source-volume-host-dir-container-dir-options[Podman docs]. | ||
|
||
|
||
=== In non-interactive (remote) mode | ||
|
||
[source,bash] | ||
---- | ||
docker run -p 2003:2003 ghcr.io/unoconv/unoserver-docker unoconvert /data/document.docx /data/document.pdf | ||
---- | ||
|
||
After you start the container, you can use link:https://github.com/unoconv/unoserver#unoconvert[unoconvert] command to convert documents using LibreOffice. | ||
|
||
NOTE: You must use `--host-location` otherwise unoconvert will default to local although running unoserver in a container should be handled as remote. | ||
|
||
[source,bash] | ||
---- | ||
unoconvert --host-location remote example.docx x2.pdfdocker | ||
---- | ||
== FAQ | ||
|
||
Q. Why do I get an error during when converting is writing/exporting to file? | ||
|
||
A. It's very likely that you haven't given the container write permission to the mounted data directory. See: link:https://github.com/unoconv/unoserver-docker/issues/44[Issue #44] | ||
|
||
== 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,45 @@ | ||
#!/bin/bash | ||
set -e -u | ||
|
||
# Function to wait for unoserver to start | ||
wait_for_unoserver() { | ||
echo "Waiting for unoserver to start on port 2003..." | ||
while ! netstat -tln | grep -q 2003; do | ||
sleep 1 | ||
done | ||
echo "unoserver started." | ||
} | ||
|
||
export PS1='\u@\h:\w\$ ' | ||
|
||
echo "using: $(libreoffice --version)" | ||
|
||
# if tty then assume that container is interactive | ||
if [ ! -t 0 ]; then | ||
echo "Running unoserver-docker in non-interactive." | ||
echo "For interactive mode use '-it', e.g. 'docker run -v /tmp:/data -it unoserver/unoserver-docker'." | ||
|
||
unoserver --interface 0.0.0.0 | ||
# # run supervisord in foreground | ||
# supervisord -c "$SUPERVISOR_NON_INTERACTIVE_CONF" | ||
else | ||
echo "Running unoserver-docker in interactive mode." | ||
echo "For non-interactive mode omit '-it', e.g. 'docker run -p 2003:2003 unoserver/unoserver-docker'." | ||
|
||
# default parameters for supervisord | ||
export SUPERVISOR_INTERACTIVE_CONF='/supervisor/conf/interactive/supervisord.conf' | ||
export UNIX_HTTP_SERVER_PASSWORD=${UNIX_HTTP_SERVER_PASSWORD:-$(cat /proc/sys/kernel/random/uuid)} | ||
|
||
# run supervisord as detached | ||
supervisord -c "$SUPERVISOR_INTERACTIVE_CONF" | ||
|
||
# wait until unoserver started and listens on port 2002. | ||
wait_for_unoserver | ||
|
||
# if commands have been passed to container run them and exit, else start bash | ||
if [[ $# -gt 0 ]]; then | ||
eval "$@" | ||
else | ||
/bin/bash | ||
fi | ||
fi |
File renamed without changes.
This file was deleted.
Oops, something went wrong.