Skip to content

Commit

Permalink
Add os-arch suffix to binary names
Browse files Browse the repository at this point in the history
Signed-off-by: Tamal Saha <[email protected]>
  • Loading branch information
tamalsaha committed May 11, 2020
1 parent cedfe2f commit 5759c2e
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 10 deletions.
2 changes: 1 addition & 1 deletion Dockerfile.dbg
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@

FROM {ARG_FROM}

ADD bin/{ARG_OS}_{ARG_ARCH}/{ARG_BIN} /{ARG_BIN}
ADD bin/{ARG_BIN}-{ARG_OS}-{ARG_ARCH} /{ARG_BIN}

ENTRYPOINT ["/{ARG_BIN}"]
2 changes: 1 addition & 1 deletion Dockerfile.in
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

FROM {ARG_FROM}

ADD bin/{ARG_OS}_{ARG_ARCH}/{ARG_BIN} /{ARG_BIN}
ADD bin/{ARG_BIN}-{ARG_OS}-{ARG_ARCH} /{ARG_BIN}

# This would be nicer as `nobody:nobody` but distroless has no such entries.
USER 65535:65535
Expand Down
17 changes: 9 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,10 @@ TAG_DBG := $(VERSION)-dbg_$(OS)_$(ARCH)
GO_VERSION ?= 1.14.2
BUILD_IMAGE ?= appscode/golang-dev:$(GO_VERSION)

OUTBIN = bin/$(OS)_$(ARCH)/$(BIN)
OUTBIN = bin/$(BIN)-$(OS)-$(ARCH)
ifeq ($(OS),windows)
OUTBIN = bin/$(OS)_$(ARCH)/$(BIN).exe
OUTBIN := bin/$(BIN)-$(OS)-$(ARCH).exe
BIN := $(BIN).exe
endif

# Directories that we need created to build/test.
Expand Down Expand Up @@ -189,7 +190,7 @@ $(OUTBIN): .go/$(OUTBIN).stamp
"
@if [ $(COMPRESS) = yes ] && [ $(OS) != darwin ]; then \
echo "compressing $(OUTBIN)"; \
@docker run \
docker run \
-i \
--rm \
-u $$(id -u):$$(id -g) \
Expand All @@ -201,19 +202,19 @@ $(OUTBIN): .go/$(OUTBIN).stamp
--env HTTP_PROXY=$(HTTP_PROXY) \
--env HTTPS_PROXY=$(HTTPS_PROXY) \
$(BUILD_IMAGE) \
upx --brute /go/$(OUTBIN); \
upx --brute /go/bin/$(BIN); \
fi
@if ! cmp -s .go/$(OUTBIN) $(OUTBIN); then \
mv .go/$(OUTBIN) $(OUTBIN); \
date >$@; \
@if ! cmp -s .go/bin/$(OS)_$(ARCH)/$(BIN) $(OUTBIN); then \
mv .go/bin/$(OS)_$(ARCH)/$(BIN) $(OUTBIN); \
date >$@; \
fi
@echo

# Used to track state in hidden files.
DOTFILE_IMAGE = $(subst /,_,$(IMAGE))-$(TAG)

container: bin/.container-$(DOTFILE_IMAGE)-PROD bin/.container-$(DOTFILE_IMAGE)-DBG
bin/.container-$(DOTFILE_IMAGE)-%: bin/$(OS)_$(ARCH)/$(BIN) $(DOCKERFILE_%)
bin/.container-$(DOTFILE_IMAGE)-%: $(OUTBIN) $(DOCKERFILE_%)
@echo "container: $(IMAGE):$(TAG_$*)"
@sed \
-e 's|{ARG_BIN}|$(BIN)|g' \
Expand Down

0 comments on commit 5759c2e

Please sign in to comment.