2019-03-16 15:14:32 +01:00
|
|
|
DOCKER_IMAGE := mpolden/echoip
|
2018-02-09 21:20:32 +01:00
|
|
|
OS := $(shell uname)
|
|
|
|
ifeq ($(OS),Linux)
|
|
|
|
TAR_OPTS := --wildcards
|
|
|
|
endif
|
|
|
|
|
2018-06-28 17:39:45 +02:00
|
|
|
all: deps lint test install
|
2014-12-22 16:01:23 +01:00
|
|
|
|
2018-09-11 22:08:12 +02:00
|
|
|
deps:
|
|
|
|
go get ./...
|
2013-09-08 19:37:41 +02:00
|
|
|
|
2018-09-11 22:08:12 +02:00
|
|
|
test: deps
|
2015-09-17 20:57:27 +02:00
|
|
|
go test ./...
|
2014-12-22 16:53:41 +01:00
|
|
|
|
2018-09-11 22:08:12 +02:00
|
|
|
vet: deps
|
2016-04-15 17:59:56 +02:00
|
|
|
go vet ./...
|
|
|
|
|
2018-06-28 17:39:45 +02:00
|
|
|
check-fmt:
|
2018-08-27 20:45:51 +02:00
|
|
|
bash -c "diff --line-format='%L' <(echo -n) <(gofmt -d -s .)"
|
2018-06-28 17:39:45 +02:00
|
|
|
|
2018-08-27 21:24:28 +02:00
|
|
|
lint: check-fmt vet
|
2018-06-28 17:39:45 +02:00
|
|
|
|
2018-09-11 22:08:12 +02:00
|
|
|
install: deps
|
2018-02-09 21:57:33 +01:00
|
|
|
go install ./...
|
2015-09-17 22:25:37 +02:00
|
|
|
|
2018-02-09 21:20:32 +01:00
|
|
|
databases := GeoLite2-City GeoLite2-Country
|
|
|
|
|
|
|
|
$(databases):
|
|
|
|
mkdir -p data
|
2019-01-04 16:56:16 +01:00
|
|
|
curl -fsSL -m 30 https://geolite.maxmind.com/download/geoip/database/$@.tar.gz | tar $(TAR_OPTS) --strip-components=1 -C $(CURDIR)/data -xzf - '*.mmdb'
|
2018-02-09 21:20:32 +01:00
|
|
|
test ! -f data/GeoLite2-City.mmdb || mv data/GeoLite2-City.mmdb data/city.mmdb
|
|
|
|
test ! -f data/GeoLite2-Country.mmdb || mv data/GeoLite2-Country.mmdb data/country.mmdb
|
|
|
|
|
|
|
|
geoip-download: $(databases)
|
2019-03-16 15:14:32 +01:00
|
|
|
|
|
|
|
docker-build:
|
|
|
|
docker build -t $(DOCKER_IMAGE) .
|
|
|
|
|
|
|
|
docker-login:
|
|
|
|
@echo "$(DOCKER_PASSWORD)" | docker login -u "$(DOCKER_USERNAME)" --password-stdin
|
|
|
|
|
2019-03-29 20:38:43 +01:00
|
|
|
docker-test:
|
|
|
|
$(eval CONTAINER=$(shell docker run --rm --detach --publish-all $(DOCKER_IMAGE)))
|
|
|
|
$(eval DOCKER_PORT=$(shell docker port $(CONTAINER) | cut -d ":" -f 2))
|
|
|
|
curl -qfsS -m 5 localhost:$(DOCKER_PORT) > /dev/null; docker stop $(CONTAINER)
|
|
|
|
|
|
|
|
docker-push: docker-test docker-login
|
2019-03-16 15:14:32 +01:00
|
|
|
docker push $(DOCKER_IMAGE)
|