dockerfile: trying a different approach for entrypoint

This commit is contained in:
Vincent Batts 2017-06-07 18:49:51 -04:00
parent b3f5e06c4d
commit be4ac4b880
2 changed files with 25 additions and 6 deletions

View File

@ -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"]

24
run.sh Normal file
View File

@ -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}