Merge pull request #13 from ilyaglow/docker-fixes

Fix dockerized iptoasn-webservice
This commit is contained in:
Frank Denis 2018-07-18 19:12:39 +02:00 committed by GitHub
commit c9127a27bf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 48 additions and 12 deletions

View File

@ -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 \
&& apk add --no-cache ca-certificates \
libressl \
llvm-libunwind \
RUN apk add --update --no-cache ca-certificates \
libressl \
llvm-libunwind \
libgcc \
&& apk add --no-cache --virtual .build-rust \
rust \
cargo \
@ -16,15 +17,16 @@ RUN apk update \
&& 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 \
&& adduser -D app \
\
&& apk del .build-rust \
&& rm -rf ~/.cargo \
/var/cache/apk/* \
/tmp/* \
&& apk del .build-rust
/tmp/*
COPY docker/iptoasn-entrypoint.sh /iptoasn-entrypoint.sh
RUN chmod +x /iptoasn-entrypoint.sh
RUN adduser -D app
USER app
ENTRYPOINT ["/iptoasn-entrypoint.sh"]

34
docker/README.md Normal file
View File

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