mirror of
https://github.com/dcarrillo/whatismyip.git
synced 2024-12-22 06:18:01 +00:00
46 lines
1.3 KiB
Makefile
46 lines
1.3 KiB
Makefile
VERSION ?= devel-$(shell git rev-parse --short HEAD)
|
|
DOCKER_URL ?= dcarrillo/whatismyip
|
|
|
|
.PHONY: test
|
|
test: unit-test integration-test
|
|
|
|
.PHONY: unit-test
|
|
unit-test:
|
|
go test -race -short -cover ./...
|
|
|
|
.PHONY: integration-test
|
|
integration-test:
|
|
go test ./integration-tests -v
|
|
|
|
.PHONY: install-tools
|
|
install-int:
|
|
@hash golangci-lint > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
|
|
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.43.0
|
|
fi
|
|
|
|
@hash shadow > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
|
|
go install golang.org/x/tools/go/analysis/passes/shadow/cmd/shadow@v0.1.7
|
|
fi
|
|
.PHONY: lint
|
|
lint: install-tools
|
|
golangci-lint run
|
|
shadow ./...
|
|
|
|
.PHONY: build
|
|
build:
|
|
CGO_ENABLED=0 go build -ldflags="-X 'github.com/dcarrillo/whatismyip/internal/core.Version=${VERSION}'" -o whatismyip ./cmd
|
|
|
|
.PHONY: docker-build
|
|
docker-build:
|
|
docker build --tag ${DOCKER_URL}:${VERSION} .
|
|
|
|
.PHONY: docker-run
|
|
docker-run: docker-build
|
|
docker run --tty --interactive --rm \
|
|
-v $$PWD/test/GeoIP2-City-Test.mmdb:/tmp/GeoIP2-City-Test.mmdb:ro \
|
|
-v $$PWD/test/GeoLite2-ASN-Test.mmdb:/tmp/GeoLite2-ASN-Test.mmdb:ro -p 8080:8080 \
|
|
${DOCKER_URL}:${VERSION} \
|
|
-geoip2-city /tmp/GeoIP2-City-Test.mmdb \
|
|
-geoip2-asn /tmp/GeoLite2-ASN-Test.mmdb \
|
|
-trusted-header X-Real-IP
|