Created
April 10, 2017 07:39
-
-
Save stronk7/339b3abb167ab7a08d206602fc8721f3 to your computer and use it in GitHub Desktop.
A very simple docker image to use unoconv easily
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
FROM ubuntu:xenial | |
RUN \ | |
apt-get update && \ | |
DEBIAN_FRONTEND=noninteractive apt-get install -y unoconv && \ | |
apt-get clean && \ | |
rm -rf /var/lib/apt/lists/ | |
# Get latest unoconv script and hack it to use python3. | |
# (it fixes an issue about unoconv listener failing first time with libreoffice). | |
# Reference: https://github.com/dagwieers/unoconv/pull/327 | |
ADD https://raw.githubusercontent.com/dagwieers/unoconv/master/unoconv /usr/bin/unoconv | |
RUN \ | |
chmod +xr /usr/bin/unoconv && \ | |
sed -i 's/env python$/env python3/' /usr/bin/unoconv | |
# Create the /tmp/in and /tmp/out to be used as volumes for sharing | |
RUN \ | |
mkdir -p /tmp/in && \ | |
mkdir -p /tmp/out | |
ENTRYPOINT [ "/usr/bin/unoconv" ] | |
CMD [ "--help" ] |
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
#!/usr/bin/env bash | |
execparams= | |
outputpath= | |
inputpath= | |
while getopts ":f:o:-:" opt; do | |
case $opt in | |
-) | |
execparams+="--" | |
execparams+=$OPTARG | |
execparams+=" " | |
;; | |
f) | |
execparams+="-f " | |
execparams+=$OPTARG | |
execparams+=" " | |
;; | |
o) | |
# Get output path | |
outputpath=$(dirname $(readlink -f $OPTARG)) | |
execparams+="-o " | |
execparams+="/tmp/out/" | |
execparams+=$(basename $OPTARG) | |
execparams+=" " | |
;; | |
\?) | |
execparams+="-" | |
execparams+=$OPTARG | |
execparams+=" " | |
;; | |
esac | |
done | |
shift $((OPTIND-1)) | |
[ "$1" = "--" ] && shift | |
# Get input path | |
if [[ -n $1 ]]; then | |
inputpath=$(dirname $(readlink -f $1)) | |
execparams+="/tmp/in/" | |
execparams+=$(basename $1) | |
execparams+=" " | |
fi | |
execparams=${execparams%% } | |
if [[ -n $outputpath ]] && [[ -n $inputpath ]]; then | |
docker run \ | |
-v $outputpath:/tmp/out \ | |
-v $inputpath:/tmp/in \ | |
moodle-docker_images/unoconv $execparams | |
else | |
docker run \ | |
moodle-docker_images/unoconv $execparams | |
fi | |
execparams=${execparams%% } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment