Simplify Makefile and docker usage (#24)

This commit is contained in:
Adrian Macneil 2018-01-22 21:49:12 -08:00 committed by GitHub
parent 2b8b849626
commit c2fc8b5441
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 44 additions and 35 deletions

View file

@ -2,25 +2,35 @@ DC := docker-compose
BUILD_FLAGS := -ldflags '-s'
PACKAGES := ./cmd/... ./pkg/...
all: clean container test lint build
.PHONY: all
all: install test lint build
.PHONY: install
install:
go install -v $(PACKAGES)
.PHONY: test
test:
go test -v $(PACKAGES)
.PHONY: lint
lint:
golint -set_exit_status $(PACKAGES)
go vet $(PACKAGES)
errcheck $(PACKAGES)
.PHONY: clean
clean:
rm -rf dist
container:
.PHONY: build
build: clean
GOARCH=amd64 go build $(BUILD_FLAGS) -o dist/dbmate-linux-amd64 ./cmd/dbmate
# musl target does not support sqlite
GOARCH=amd64 CGO_ENABLED=0 go build $(BUILD_FLAGS) -o dist/dbmate-linux-musl-amd64 ./cmd/dbmate
.PHONY: docker
docker:
$(DC) pull
$(DC) build
$(DC) up -d
lint:
$(DC) run --rm dbmate golint -set_exit_status $(PACKAGES)
$(DC) run --rm dbmate go vet $(PACKAGES)
$(DC) run --rm dbmate errcheck $(PACKAGES)
test:
$(DC) run --rm dbmate go test -v $(PACKAGES)
build: clean
$(DC) run --rm -e GOARCH=amd64 dbmate go build $(BUILD_FLAGS) -o dist/dbmate-linux-amd64 ./cmd/dbmate
# musl target does not support sqlite
$(DC) run --rm -e GOARCH=amd64 -e CGO_ENABLED=0 dbmate go build $(BUILD_FLAGS) -o dist/dbmate-linux-musl-amd64 ./cmd/dbmate
$(DC) run --rm dbmate make