Skip to content

Commit

Permalink
Add Dockerfile and refine Makefile.
Browse files Browse the repository at this point in the history
  • Loading branch information
wi1dcard committed Jan 8, 2020
1 parent 7f0cb42 commit c2c0fb7
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 15 deletions.
6 changes: 6 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
FROM alpine

ARG ARCH
EXPOSE 9550

COPY dist/v2ray-exporter_linux_${ARCH} /usr/bin/v2ray-exporter
37 changes: 22 additions & 15 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,10 +1,22 @@
LAST_TAG = $(shell git describe --tags --abbrev=0 HEAD)
COMMIT = $(shell git rev-parse --short HEAD)
FULL_COMMIT = $(shell git rev-parse HEAD)
LAST_TAG = $(shell git describe --tags --abbrev=0 HEAD)
COMMIT = $(shell git rev-parse --short HEAD)
FULL_COMMIT = $(shell git rev-parse HEAD)
RELEASE_NOTES = $(shell git log ${LAST_TAG}..HEAD --oneline --decorate)
DATE = $(shell date +%Y-%m-%d)
DATE = $(shell date +%Y-%m-%d)

build:
lint:
golangci-lint run *.go

release_notes:
@echo "${RELEASE_NOTES}"

before_build:
go get github.com/mitchellh/gox

check_tag:
test ! -z "${TAG}"

build: check_tag
gox -verbose \
-output "dist/{{.Dir}}_{{.OS}}_{{.Arch}}" \
-osarch "linux/amd64 linux/arm64 linux/arm darwin/amd64 windows/amd64" \
Expand All @@ -13,15 +25,10 @@ build:
-X main.buildVersion=${LAST_TAG}" \
./...

before_build:
go get github.com/mitchellh/gox

lint:
golangci-lint run *.go

release_notes:
@echo "${RELEASE_NOTES}"

release: build
test ! -z "${TAG}"
@ghr -u wi1dcard -b "${RELEASE_NOTES}" -c "${FULL_COMMIT}" "${TAG}" dist/

docker_build: build
docker build --build-arg ARCH=amd64 -t "wi1dcard/v2ray-exporter:${TAG}" .
docker build --build-arg ARCH=arm64 -t "wi1dcard/v2ray-exporter:${TAG}-arm64" .
docker build --build-arg ARCH=arm -t "wi1dcard/v2ray-exporter:${TAG}-arm" .

0 comments on commit c2c0fb7

Please sign in to comment.