diff --git a/Dockerfile b/Dockerfile index 1caf262..bfeb671 100644 --- a/Dockerfile +++ b/Dockerfile @@ -8,9 +8,4 @@ RUN dnf install -y golang git bzr && \ go get github.com/vbatts/imgsrv && \ rm -rf /usr/local/src /usr/local/pkg && \ dnf remove -y golang git bzr -ENTRYPOINT /usr/local/bin/imgsrv \ - -server \ - -mongo-host=$MONGODB_SERVICE_HOST:$MONGODB_SERVICE_PORT \ - -mongo-db=$MONGODB_DATABASE \ - -mongo-username=$DATABASE_USER \ - -mongo-password=$DATABASE_PASSWORD +ENTRYPOINT ["/usr/local/src/github.com/vbatts/imgsrv/run.sh"] diff --git a/run.sh b/run.sh new file mode 100644 index 0000000..f6883bb --- /dev/null +++ b/run.sh @@ -0,0 +1,24 @@ +#!/bin/sh + +binary=${APP_BINARY:-/usr/local/bin/imgsrv} +MONGODB_SERVICE_HOST=${MONGODB_SERVICE_HOST:-localhost} +MONGODB_SERVICE_PORT=${MONGODB_SERVICE_PORT:-27017} + +args="" +if [ ! -z "${DATABASE_USER}" ] ; then + args=" ${args} -mongo-username=$DATABASE_USER " +fi + +if [ ! -z "${DATABASE_PASSWORD}" ] ; then + args=" ${args} -mongo-password=$DATABASE_PASSWORD " +fi + +if ! echo "${1:-$@}" | grep -q '\-mongo-host' ; then + args=" ${args} -mongo-host=$MONGODB_SERVICE_HOST:$MONGODB_SERVICE_PORT " +fi + +${binary} \ + -server \ + -mongo-db=$MONGODB_DATABASE \ + ${1:-$@} \ + ${args}