mirror of
https://github.com/jedisct1/iptoasn-webservice
synced 2025-04-11 22:55:50 +02:00
Merge branch 'master' of github.com:jedisct1/iptoasn-webservice
* 'master' of github.com:jedisct1/iptoasn-webservice: Add entrypoint shell script Add docker support
This commit is contained in:
commit
45ac24c589
30
docker/Dockerfile
Normal file
30
docker/Dockerfile
Normal file
@ -0,0 +1,30 @@
|
||||
FROM alpine:edge
|
||||
|
||||
COPY ./ /tmp
|
||||
|
||||
WORKDIR /tmp
|
||||
|
||||
RUN apk update \
|
||||
&& apk add --no-cache ca-certificates \
|
||||
libressl \
|
||||
llvm-libunwind \
|
||||
&& apk add --no-cache --virtual .build-rust \
|
||||
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/* \
|
||||
&& apk del .build-rust
|
||||
|
||||
RUN adduser -D app
|
||||
USER app
|
||||
|
||||
ENTRYPOINT ["/iptoasn-entrypoint.sh"]
|
18
docker/iptoasn-entrypoint.sh
Normal file
18
docker/iptoasn-entrypoint.sh
Normal 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
|
Loading…
x
Reference in New Issue
Block a user