Allow providing GeoIP license key in Dockerfile

This commit is contained in:
Sandro Jäckel 2020-04-07 04:24:16 +02:00
parent 2fe2f078e2
commit e31edadbb1
No known key found for this signature in database
GPG Key ID: 3AF5A43A3EECC2E5
3 changed files with 17 additions and 2 deletions

View File

@ -4,13 +4,19 @@ WORKDIR /go/src/github.com/mpolden/echoip
COPY . .
# Must build without cgo because libc is unavailable in runtime image
ENV GO111MODULE=on CGO_ENABLED=0
RUN make
ARG GEOIP_LICENSE_KEY
RUN if [ ${GEOIP_LICENSE_KEY:-} ]; then \
make all geoip-download ;\
else \
make all ;\
fi
# Run
FROM scratch
EXPOSE 8080
COPY --from=build \
/go/bin/echoip \
/go/src/github.com/mpolden/echoip/data/ \
/go/src/github.com/mpolden/echoip/index.html \
/opt/echoip/
WORKDIR /opt/echoip

View File

@ -36,7 +36,7 @@ endif
geoip-download: $(databases)
docker-build:
$(DOCKER) build -t $(DOCKER_IMAGE) .
$(DOCKER) build -t $(DOCKER_IMAGE) . --build-arg GEOIP_LICENSE_KEY
docker-login:
@echo "$(DOCKER_PASSWORD)" | $(DOCKER) login -u "$(DOCKER_USERNAME)" --password-stdin

View File

@ -106,6 +106,15 @@ Hub](https://hub.docker.com/r/mpolden/echoip), which can be downloaded with:
`docker pull mpolden/echoip`
### GeoIP support
To build the Docker Image with GeoIP support follow the following steps:
1. Clone the repo
2. Get a license key. See https://blog.maxmind.com/2019/12/18/significant-changes-to-accessing-and-using-geolite2-databases/
3. Run with replacing xxxxxxxxxxxxxxxx with the license key and USERNAME with your name: ``make docker-build GEOIP_LICENSE_KEY=xxxxxxxxxxxxxxxx DOCKER_IMAGE=USERNAME/echoip``
4. Run the image with: ``docker run -p 8080:8080 USERNAME/echoip -f country.mmdb -c city.mmdb -a asn.mmdb
### Usage
```