Add entrypoint shell script

Listen port and database URL can be configured by using
environment variables: IPTOASN_PORT AND IPTOASN_DBURL

Docker container for the iptoasn_webservice may be used as a
binary - arbitrary args will be passed to the service if supplied
This commit is contained in:
Ilya Glotov 2017-07-31 20:44:50 +03:00
parent c8d367c97f
commit 79f0803fd5
No known key found for this signature in database
GPG Key ID: AE18CC224730A36D
2 changed files with 24 additions and 1 deletions

View File

@ -12,8 +12,13 @@ RUN apk update \
rust \
cargo \
libressl-dev \
\
&& cargo build --release \
&& strip target/release/iptoasn-webservice \
&& mv target/release/iptoasn-webservice /usr/bin/iptoasn-webservice \
&& mv docker/iptoasn-entrypoint.sh /iptoasn-entrypoint.sh \
&& chmod +x /iptoasn-entrypoint.sh \
\
&& rm -rf ~/.cargo \
/var/cache/apk/* \
/tmp/* \
@ -22,4 +27,4 @@ RUN apk update \
RUN adduser -D app
USER app
ENTRYPOINT /usr/bin/iptoasn-webservice --listen 0.0.0.0:10000
ENTRYPOINT ["/iptoasn-entrypoint.sh"]

View File

@ -0,0 +1,18 @@
#!/bin/sh
DEFAULT_PORT='53661'
DEFAULT_DBURL='https://iptoasn.com/data/ip2asn-combined.tsv.gz'
if [ $IPTOASN_PORT ] || [ $IPTOASN_DBURL]; then
if ! [ $IPTOASN_PORT ]; then
IPTOASN_PORT=$DEFAULT_PORT
fi
if ! [ $IPTOASN_DBURL ]; then
IPTOASN_DBURL=$DEFAULT_DBURL
fi
exec /usr/bin/iptoasn-webservice --listen 0.0.0.0:"$IPTOASN_PORT" --dburl "$IPTOASN_DBURL"
else
exec /usr/bin/iptoasn-webservice $@
fi