This repository was archived by the owner on Jul 1, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathMakefile
More file actions
67 lines (53 loc) · 1.61 KB
/
Makefile
File metadata and controls
67 lines (53 loc) · 1.61 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# all goinstalls everything
.PHONY: all
all: install
# install installs binary
.PHONY: install
install:
go install github.com/gravitational/rigging/tool/rig
BUILDDIR ?= $(abspath build)
.PHONY: build
build:
go build -mod=vendor -ldflags '-w' -o $(BUILDDIR)/rig github.com/gravitational/rigging/tool/rig
.PHONY: test
test:
go test -v ./ ./tool/...
BUILDBOX := quay.io/gravitational/debian-venti:go1.16.7-buster
# Directory with sources inside the container
DST := /gopath/src/github.com/gravitational/rigging
# This directory
SRC := $(dir $(CURDIR)/$(word $(words $(MAKEFILE_LIST)),$(MAKEFILE_LIST)))
VERSION ?= $(shell git describe --tags --abbrev=8)
IMAGE := quay.io/gravitational/rig:$(VERSION)
# docker target starts build inside the container
.PHONY: docker-build
docker-build:
docker run -i --rm=true \
-u $$(id -u):$$(id -g) -e GOCACHE=/tmp/.cache \
-v $(SRC):$(DST) \
$(BUILDBOX) \
/bin/bash -c "make -C $(DST) build"
# docker target starts tests inside the container
.PHONY: docker-test
docker-test:
docker run -i --rm=true \
-v $(SRC):$(DST) \
$(BUILDBOX) \
/bin/bash -c "make -C $(DST) test"
.PHONY: docker-image
docker-image: docker-build
$(eval TEMPDIR = "$(shell mktemp -d $(BUILDDIR)/tmp.XXXXXX)")
if [ -z "$(TEMPDIR)" ]; then \
echo "TEMPDIR is not set"; exit 1; \
fi;
mkdir -p $(TEMPDIR)/build
cp build/rig $(TEMPDIR)/build/rig
cp -r docker/rig.dockerfile $(TEMPDIR)/Dockerfile
cd $(TEMPDIR) && docker build --pull -t $(IMAGE) .
rm -rf $(TEMPDIR)
.PHONY: publish-docker-image
publish-docker-image:
docker push $(IMAGE)
.PHONY: print-image
print-image:
echo $(IMAGE)