Fix dockerized iptoasn
* Downgrade alpine from edge to 3.7, where libressl is 2.6 (needed for openssl crate) and almost everything is more robust. * Copy to the container only required files. * Add libgcc package. * Add readme file.
This commit is contained in:
parent
4092f6d9fe
commit
d0ac396e12
|
@ -1,13 +1,14 @@
|
||||||
FROM alpine:edge
|
FROM alpine:3.7
|
||||||
|
|
||||||
COPY ./ /tmp
|
COPY Cargo.* /tmp/iptoasn/
|
||||||
|
COPY src /tmp/iptoasn/src
|
||||||
|
|
||||||
WORKDIR /tmp
|
WORKDIR /tmp/iptoasn
|
||||||
|
|
||||||
RUN apk update \
|
RUN apk add --update --no-cache ca-certificates \
|
||||||
&& apk add --no-cache ca-certificates \
|
libressl \
|
||||||
libressl \
|
llvm-libunwind \
|
||||||
llvm-libunwind \
|
libgcc \
|
||||||
&& apk add --no-cache --virtual .build-rust \
|
&& apk add --no-cache --virtual .build-rust \
|
||||||
rust \
|
rust \
|
||||||
cargo \
|
cargo \
|
||||||
|
@ -16,15 +17,16 @@ RUN apk update \
|
||||||
&& cargo build --release \
|
&& cargo build --release \
|
||||||
&& strip target/release/iptoasn-webservice \
|
&& strip target/release/iptoasn-webservice \
|
||||||
&& mv target/release/iptoasn-webservice /usr/bin/iptoasn-webservice \
|
&& mv target/release/iptoasn-webservice /usr/bin/iptoasn-webservice \
|
||||||
&& mv docker/iptoasn-entrypoint.sh /iptoasn-entrypoint.sh \
|
&& adduser -D app \
|
||||||
&& chmod +x /iptoasn-entrypoint.sh \
|
|
||||||
\
|
\
|
||||||
|
&& apk del .build-rust \
|
||||||
&& rm -rf ~/.cargo \
|
&& rm -rf ~/.cargo \
|
||||||
/var/cache/apk/* \
|
/var/cache/apk/* \
|
||||||
/tmp/* \
|
/tmp/*
|
||||||
&& apk del .build-rust
|
|
||||||
|
COPY docker/iptoasn-entrypoint.sh /iptoasn-entrypoint.sh
|
||||||
|
RUN chmod +x /iptoasn-entrypoint.sh
|
||||||
|
|
||||||
RUN adduser -D app
|
|
||||||
USER app
|
USER app
|
||||||
|
|
||||||
ENTRYPOINT ["/iptoasn-entrypoint.sh"]
|
ENTRYPOINT ["/iptoasn-entrypoint.sh"]
|
||||||
|
|
|
@ -0,0 +1,34 @@
|
||||||
|
## How to use
|
||||||
|
|
||||||
|
Assume you are in the repo's root folder:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
docker build -t iptoasn -f docker/Dockerfile .
|
||||||
|
docker run -itd \
|
||||||
|
--name my-iptoasn \
|
||||||
|
-p 80:53661 \
|
||||||
|
iptoasn
|
||||||
|
```
|
||||||
|
|
||||||
|
Wait while iptoasn is downloading data, and then you can do `curl` requests as you used to:
|
||||||
|
```bash
|
||||||
|
curl 127.0.0.1:80/v1/as/ip/8.8.8.8
|
||||||
|
```
|
||||||
|
|
||||||
|
### Setting service parameters
|
||||||
|
|
||||||
|
Listen port and database URL can be specified by environment variables:
|
||||||
|
```bash
|
||||||
|
docker run -itd \
|
||||||
|
--name my-iptoasn \
|
||||||
|
-e IPTOASN_PORT=10000 \
|
||||||
|
-e IPTOASN_DBURL='http://your-database-url.com' \
|
||||||
|
-p 80:10000 \
|
||||||
|
iptoasn
|
||||||
|
```
|
||||||
|
|
||||||
|
### Use as a binary
|
||||||
|
|
||||||
|
```bash
|
||||||
|
docker run -it --rm iptoasn --help
|
||||||
|
```
|
Loading…
Reference in New Issue