diff --git a/Dockerfile b/Dockerfile index c60e84f..8d5b8a5 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,18 +1,27 @@ -FROM golang:1.18-alpine AS build +FROM golang:1.18 AS build -ENV CGO_ENABLED=0 ENV PORT 10000 -COPY . /go/src/sablier WORKDIR /go/src/sablier +COPY go.mod ./ +COPY go.sum ./ +RUN go mod download + +COPY . /go/src/sablier + ARG TARGETOS ARG TARGETARCH -RUN GIN_MODE=release GOOS=${TARGETOS} GOARCH=${TARGETARCH} go build -buildvcs=false -o /go/bin/sablier +RUN make ${TARGETOS}/${TARGETARCH} FROM alpine + +RUN addgroup -S sablier && adduser -S sablier -G sablier +USER sablier:sablier + +COPY --from=build --chown=sablier:sablier /go/src/sablier/sablier* /go/bin/sablier + EXPOSE 10000 -COPY --from=build /go/bin/sablier /go/bin/sablier ENTRYPOINT [ "/go/bin/sablier" ] -CMD [ "--swarmMode=true" ] \ No newline at end of file +CMD [ "start", "--provider.name=docker"] \ No newline at end of file diff --git a/Makefile b/Makefile index 552ceed..bc4c997 100644 --- a/Makefile +++ b/Makefile @@ -13,8 +13,10 @@ VPREFIX := github.com/acouvreur/sablier/version GO_LDFLAGS := -X $(VPREFIX).Branch=$(GIT_BRANCH) -X $(VPREFIX).Version=$(version) -X $(VPREFIX).Revision=$(GIT_REVISION) -X $(VPREFIX).BuildUser=$(shell whoami)@$(shell hostname) -X $(VPREFIX).BuildDate=$(shell date -u +"%Y-%m-%dT%H:%M:%SZ") $(PLATFORMS): - GIN_MODE=release GOOS=$(os) GOARCH=$(arch) go build -ldflags="${GO_LDFLAGS}" -o 'sablier_$(version)_$(os)-$(arch)' . + CGO_ENABLED=0 GIN_MODE=release GOOS=$(os) GOARCH=$(arch) go build -tags=nomsgpack -v -ldflags="${GO_LDFLAGS}" -o 'sablier_$(version)_$(os)-$(arch)' . +build: + CGO_ENABLED=0 GIN_MODE=release GOOS=$(os) GOARCH=$(arch) go build -tags=nomsgpack -v -ldflags="${GO_LDFLAGS}" -o 'sablier_$(version)_$(os)-$(arch)' . release: $(PLATFORMS) .PHONY: release $(PLATFORMS) \ No newline at end of file