diff --git a/Dockerfile b/Dockerfile index fb5602f..ab9bc03 100644 --- a/Dockerfile +++ b/Dockerfile @@ -7,7 +7,9 @@ COPY web . RUN yarn build # build app -FROM golang:1.16 AS app-builder +FROM golang:1.17.6-alpine AS app-builder + +RUN apk add --no-cache git make build-base ENV SERVICE=autobrr @@ -21,12 +23,11 @@ COPY . ./ COPY --from=web-builder /web/build ./web/build COPY --from=web-builder /web/build.go ./web -ENV CGO_ENABLED=0 ENV GOOS=linux +ENV CGO_ENABLED=1 -#RUN make -f Makefile build/app -RUN go build -o bin/${SERVICE} ./cmd/${SERVICE}/main.go -RUN go build -o bin/autobrrctl ./cmd/autobrrctl/main.go +RUN make -f Makefile build/app +RUN make -f Makefile build/ctl # build runner FROM alpine:latest @@ -44,5 +45,5 @@ VOLUME /config COPY --from=app-builder /src/bin/autobrr /usr/local/bin/ COPY --from=app-builder /src/bin/autobrrctl /usr/local/bin/ -ENTRYPOINT ["autobrr", "--config", "/config"] +ENTRYPOINT ["/usr/local/bin/autobrr", "--config", "/config"] #CMD ["--config", "/config"] diff --git a/Makefile b/Makefile index e7c720c..609f949 100644 --- a/Makefile +++ b/Makefile @@ -2,10 +2,13 @@ .POSIX: .SUFFIXES: +GIT_COMMIT := $(shell git rev-parse HEAD 2> /dev/null) +GIT_TAG := $(shell git tag --points-at HEAD 2> /dev/null | head -n 1) + SERVICE = autobrr GO = go RM = rm -GOFLAGS = +GOFLAGS = "-X main.commit=$(GIT_COMMIT) -X main.version=$(GIT_TAG)" PREFIX = /usr/local BINDIR = bin @@ -21,10 +24,10 @@ test: build: deps build/web build/app build/app: - go build -o bin/$(SERVICE) cmd/$(SERVICE)/main.go + go build -ldflags $(GOFLAGS) -o bin/$(SERVICE) cmd/$(SERVICE)/main.go build/ctl: - go build -o bin/autobrrctl cmd/autobrrctl/main.go + go build -ldflags $(GOFLAGS) -o bin/autobrrctl cmd/autobrrctl/main.go build/web: cd web && yarn build