build: update dockerfile (#82)

This commit is contained in:
Ludvig Lundgren 2022-01-13 23:18:05 +01:00 committed by GitHub
parent dbf7ce0deb
commit ff33bcb99a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 9 deletions

View file

@ -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"]

View file

@ -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