Simplify build process (drop docker and cross-compilation)
This commit is contained in:
parent
97cd8b60f0
commit
9c58b4a7d5
2 changed files with 9 additions and 37 deletions
20
Dockerfile
20
Dockerfile
|
@ -1,20 +0,0 @@
|
||||||
FROM golang:alpine as build
|
|
||||||
|
|
||||||
WORKDIR /root
|
|
||||||
COPY . /root
|
|
||||||
RUN go install golang.org/x/tools/cmd/stringer@latest && go generate ./... && go build .
|
|
||||||
|
|
||||||
FROM alpine:latest
|
|
||||||
|
|
||||||
ENV LISTEN_ADDRESS="0.0.0.0" LISTEN_PORT="9452"
|
|
||||||
|
|
||||||
RUN addgroup -S mystrom \
|
|
||||||
&& adduser -S mystrom -G mystrom \
|
|
||||||
&& mkdir /app \
|
|
||||||
&& chown -R mystrom:mystrom /app
|
|
||||||
|
|
||||||
WORKDIR /app
|
|
||||||
USER mystrom
|
|
||||||
COPY --from=build /root/mystrom-exporter /app
|
|
||||||
|
|
||||||
CMD /app/mystrom-exporter -web.listen-address $LISTEN_ADDRESS:$LISTEN_PORT
|
|
20
Makefile
20
Makefile
|
@ -21,36 +21,28 @@ LDFLAGS := -w -s \
|
||||||
-X $(versionPkgPrefix).BuildUser=${builduser} \
|
-X $(versionPkgPrefix).BuildUser=${builduser} \
|
||||||
-X $(versionPkgPrefix).BuildDate=${builddate}
|
-X $(versionPkgPrefix).BuildDate=${builddate}
|
||||||
GOFLAGS := -v
|
GOFLAGS := -v
|
||||||
GOX_FLAGS := -mod=vendor
|
|
||||||
GO_BUILD_FLAGS := -v
|
GO_BUILD_FLAGS := -v
|
||||||
export GO111MODULE := on
|
export GO111MODULE := on
|
||||||
|
|
||||||
build: go-tools generate ## builds the all platform binaries of the exporter
|
build: go-tools generate ## build mystrom-exporter for your local system
|
||||||
$(GOPATH)/bin/gox \
|
$(GO) build \
|
||||||
-os="darwin linux" \
|
-o ${BINDIR}/mystrom-exporter \
|
||||||
-arch="amd64 arm arm64" \
|
|
||||||
-osarch="!darwin/arm" \
|
|
||||||
-output "${BINDIR}/{{.Dir}}-{{.OS}}-{{.Arch}}" \
|
|
||||||
-gcflags "$(GO_BUILD_FLAGS)" \
|
-gcflags "$(GO_BUILD_FLAGS)" \
|
||||||
-ldflags '$(LDFLAGS)' \
|
-ldflags '$(LDFLAGS)' \
|
||||||
-tags '$(TAGS)' \
|
-tags '$(TAGS)' \
|
||||||
./...
|
.
|
||||||
|
|
||||||
run:
|
run:
|
||||||
${BINDIR}/mystrom-exporter-$(shell $(GO) env GOOS)-$(shell $(GO) env GOARCH)
|
${BINDIR}/mystrom-exporter
|
||||||
|
|
||||||
|
|
||||||
generate: go-tools
|
generate: go-tools
|
||||||
$(GO) generate ./...
|
$(GO) generate ./...
|
||||||
|
|
||||||
go-tools: $(GOPATH)/bin/stringer $(GOPATH)/bin/gox
|
go-tools: $(GOPATH)/bin/stringer
|
||||||
|
|
||||||
# -- see more info on https://pkg.go.dev/golang.org/x/tools/cmd/stringer
|
# -- see more info on https://pkg.go.dev/golang.org/x/tools/cmd/stringer
|
||||||
$(GOPATH)/bin/stringer:
|
$(GOPATH)/bin/stringer:
|
||||||
$(GO) install golang.org/x/tools/cmd/stringer@latest
|
$(GO) install golang.org/x/tools/cmd/stringer@latest
|
||||||
|
|
||||||
$(GOPATH)/bin/gox:
|
|
||||||
$(GO) install github.com/mitchellh/gox@latest
|
|
||||||
# --
|
|
||||||
help:
|
help:
|
||||||
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
|
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
|
||||||
|
|
Loading…
Reference in a new issue