mirror of
https://github.com/steinhobelgruen/netatmo-exporter.git
synced 2024-11-21 09:03:55 +00:00
Update build system
This commit is contained in:
parent
8e1542e7f4
commit
9573c83179
1
.dockerignore
Symbolic link
1
.dockerignore
Symbolic link
|
@ -0,0 +1 @@
|
|||
.gitignore
|
16
Dockerfile
16
Dockerfile
|
@ -1,29 +1,21 @@
|
|||
FROM golang:1 AS builder
|
||||
FROM golang:1.14.4-alpine AS builder
|
||||
|
||||
RUN apt-get update && apt-get install -y upx
|
||||
RUN apk add --no-cache make git
|
||||
|
||||
WORKDIR /build
|
||||
|
||||
ENV LD_FLAGS="-w"
|
||||
ENV CGO_ENABLED=0
|
||||
|
||||
COPY go.mod go.sum /build/
|
||||
RUN go mod download
|
||||
RUN go mod verify
|
||||
|
||||
COPY . /build/
|
||||
RUN echo "-- TEST" \
|
||||
&& go test -cover ./... \
|
||||
&& echo "-- BUILD" \
|
||||
&& go install -tags netgo -ldflags "${LD_FLAGS}" . \
|
||||
&& echo "-- PACK" \
|
||||
&& upx -9 /go/bin/netatmo-exporter
|
||||
RUN make
|
||||
|
||||
FROM busybox
|
||||
LABEL maintainer="Robert Jacob <xperimental@solidproject.de>"
|
||||
|
||||
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt
|
||||
COPY --from=builder /go/bin/netatmo-exporter /bin/netatmo-exporter
|
||||
COPY --from=builder /build/netatmo-exporter /bin/netatmo-exporter
|
||||
|
||||
USER nobody
|
||||
EXPOSE 9210
|
||||
|
|
18
Makefile
Normal file
18
Makefile
Normal file
|
@ -0,0 +1,18 @@
|
|||
.PHONY: all test build-binary install clean
|
||||
|
||||
GO ?= go
|
||||
GO_CMD := CGO_ENABLED=0 $(GO)
|
||||
GIT_VERSION := $(shell git describe --tags --dirty)
|
||||
VERSION := $(GIT_VERSION:v%=%)
|
||||
GIT_COMMIT := $(shell git rev-parse HEAD)
|
||||
|
||||
all: test build-binary
|
||||
|
||||
test:
|
||||
$(GO_CMD) test -cover ./...
|
||||
|
||||
build-binary:
|
||||
$(GO_CMD) build -tags netgo -ldflags "-w -X main.Version=$(VERSION) -X main.GitCommit=$(GIT_COMMIT)" -o netatmo-exporter .
|
||||
|
||||
clean:
|
||||
rm -f netatmo-exporter
|
Loading…
Reference in a new issue