Skip to content

Commit

Permalink
update build for post-vgo
Browse files Browse the repository at this point in the history
  • Loading branch information
bketelsen committed Jan 20, 2019
1 parent 207604a commit f26bd96
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 12 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,4 @@ captainhook
.envrc
dist/
cover
.idea/
24 changes: 24 additions & 0 deletions Dockerfile.multi
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
FROM golang:1.10 as builder
ADD . /go/src/github.com/bketelsen/captainhook
WORKDIR /go/src/github.com/bketelsen/captainhook
RUN go get -u golang.org/x/vgo
RUN CGO_ENABLED=0 GOOS=linux vgo build -a -installsuffix cgo -o captainhook .

FROM alpine:latest as alpine
RUN apk --no-cache add ca-certificates
WORKDIR /root/
COPY --from=builder /go/src/github.com/bketelsen/captainhook/captainhook .


FROM scratch

COPY --from=alpine /root/captainhook /usr/bin/captainhook
COPY --from=alpine /etc/ssl/certs/ /etc/ssl/certs

VOLUME /config
ENTRYPOINT [ "/root/captainhook" ]
CMD ["/root/captainhook"]




23 changes: 11 additions & 12 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ all: setup test build
.PHONY: build
build: setup
@echo "Building..."
$Q vgo build $(if $V,-v) $(VERSION_FLAGS)
$Q go build $(if $V,-v) $(VERSION_FLAGS)

.PHONY: dist
dist: setup clean-dist
@echo "Building Distribution..."
$Q vgo build $(if $V,-v) $(VERSION_FLAGS) -o $(dist_dir)/$(BINARY) $(IMPORT_PATH)
$Q go build $(if $V,-v) $(VERSION_FLAGS) -o $(dist_dir)/$(BINARY) $(IMPORT_PATH)

.PHONY: clean-dist
clean-dist:
Expand Down Expand Up @@ -55,28 +55,28 @@ docker:

clean:
@echo "Clean..."
$Q rm -rf captainhook
$Q rm -rf $(BINARY)

test:
@echo "Testing..."
$Q vgo test $(if $V,-v) ./...
$Q go test $(if $V,-v) ./...
ifndef CI
@echo "Testing Outside CI..."
@echo "VGO Vet"
$Q vgo vet ./...
@echo "VGO test -race"
$Q GODEBUG=cgocheck=2 vgo test -race
@echo "GO Vet"
$Q go vet ./...
@echo "GO test -race"
$Q GODEBUG=cgocheck=2 go test -race
else
@echo "Testing in CI..."
$Q ( vgo vet ./...; echo $$? ) | \
$Q ( go vet ./...; echo $$? ) | \
tee test/vet.txt | sed '$$ d'; exit $$(tail -1 test/vet.txt)
$Q ( GODEBUG=cgocheck=2 vgo test -v -race ./...; echo $$? ) | \
$Q ( GODEBUG=cgocheck=2 go test -v -race ./...; echo $$? ) | \
tee test/output.txt | sed '$$ d'; exit $$(tail -1 test/output.txt)
endif

list:
@echo "List..."
vgo list -m
go list -m


format: $(GOIMPORTS)
Expand All @@ -92,7 +92,6 @@ setup: clean
if ! grep "dist" .gitignore > /dev/null 2>&1; then \
echo "dist" >> .gitignore; \
fi
go get -u golang.org/x/vgo
go get -u rsc.io/goversion
go get -u golang.org/x/tools/cmd/goimports

Expand Down

0 comments on commit f26bd96

Please sign in to comment.