forked from CovenantSQL/CovenantSQL
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
41 lines (32 loc) · 1.06 KB
/
Copy pathMakefile
File metadata and controls
41 lines (32 loc) · 1.06 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
default: build
IMAGE := covenantsql.io/covenantsql
GIT_COMMIT ?= $(shell git rev-parse --short HEAD)
GIT_DIRTY ?= $(shell test -n "`git status --porcelain`" && echo "+CHANGES" || true)
GIT_DESCRIBE ?= $(shell git describe --tags --always)
COMMIT := $(GIT_COMMIT)$(GIT_DIRTY)
VERSION := $(GIT_DESCRIBE)
SHIP_VERSION := $(shell docker image inspect -f "{{ .Config.Labels.version }}" $(IMAGE):latest 2>/dev/null)
IMAGE_TAR := $(subst /,_,$(IMAGE)).$(SHIP_VERSION).tar
IMAGE_TAR_GZ := $(IMAGE_TAR).gz
status:
@echo "Commit: $(COMMIT) Version: $(VERSION) Ship Version: $(SHIP_VERSION)"
build: status
docker build \
--tag $(IMAGE):$(VERSION) \
--tag $(IMAGE):latest \
--build-arg COMMIT=$(COMMIT) \
--build-arg VERSION=$(VERSION) \
.
save: status
ifeq ($(SHIP_VERSION),)
$(error No version to ship, please build first)
endif
docker save $(IMAGE):$(SHIP_VERSION) > $(IMAGE_TAR)
tar zcf $(IMAGE_TAR_GZ) $(IMAGE_TAR)
start:
docker-compose down
docker-compose up --no-start
docker-compose start
logs:
docker-compose logs -f --tail=10
.PHONY: status build save start logs