diff --git a/Dockerfile b/Dockerfile index 73ca74c..fd9b12e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,9 +2,10 @@ FROM golang:latest AS builder ADD . /opt/obp WORKDIR /opt/obp # RUN go build -o baas cmd/main.go -RUN make alpine-binary +RUN make build-alpine FROM alpine:latest RUN apk --no-cache add ca-certificates -COPY --from=builder /opt/obp/bin/obp-alpine /bin/obp +ARG VERSION=* +COPY --from=builder /opt/obp/dist/obp-$VERSION-alpine_amda64/obp /bin/obp RUN chmod +x /bin/obp diff --git a/Makefile b/Makefile index 75522ce..a07be1e 100644 --- a/Makefile +++ b/Makefile @@ -5,12 +5,17 @@ docker: docker-image docker-push .PHONY: docker-push docker-push: + $(DOCKER_CMD) pull code.ndumas.com/ndumas/obsidian-pipeline:$(VERSION) + $(DOCKER_CMD) tag code.ndumas.com/ndumas/obsidian-pipeline:$(VERSION) code.ndumas.com/ndumas/obsidian-pipeline:latest $(DOCKER_CMD) push code.ndumas.com/ndumas/obsidian-pipeline:latest .PHONY: docker-image docker-image: - $(DOCKER_CMD) build -t code.ndumas.com/ndumas/obsidian-pipeline:latest . + $(DOCKER_CMD) build --build-arg VERSION=$(VERSION) -t code.ndumas.com/ndumas/obsidian-pipeline:$(VERSION) . +.PHONE: build-alpine +build-alpine: + CGO_ENABLED=0 go build -a -installsuffix cgo -o $(DISTDIR)/$(NAME)-$(VERSION)-alpine_amd64/obp cmd/obp/cmd/*.go # This file is intended as a starting point for a customized makefile for a Go project. # @@ -86,8 +91,7 @@ ARCHES ?= amd64 386 OSES ?= windows linux darwin OUTTPL = $(DISTDIR)/$(NAME)-$(VERSION)-{{.OS}}_{{.Arch}}/{{.Dir}} LDFLAGS = -X $(PKG).Version=$(VERSION) -X $(PKG).Build=$(COMMIT_ID) -GOBUILD = gox -rebuild -gocmd="$(GOCMD)" -arch="$(ARCHES)" -os="$(OSES)" -output="$(OUTTPL)" -tags "$(BUILD_TAGS)" -ldflags "$(LDFLAGS)" -GOBUILD_SIMPLE = go build -tags "$(BUILD_TAGS)" -ldflags "$(LDFLAGS)" +GOBUILD = gox -osarch="!darwin/386" -rebuild -gocmd="$(GOCMD)" -arch="$(ARCHES)" -os="$(OSES)" -output="$(OUTTPL)" -tags "$(BUILD_TAGS)" -ldflags "$(LDFLAGS)" GOCLEAN = $(GOCMD) clean GOINSTALL = $(GOCMD) install -a -tags "$(BUILD_TAGS)" -ldflags "$(LDFLAGS)" GOTEST = $(GOCMD) test -v -tags "$(BUILD_TAGS)"