forked from hypriot/rpi-drone
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
44 lines (38 loc) · 1.87 KB
/
Makefile
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
IMAGENAME := $(shell basename `git rev-parse --show-toplevel`)
SHA := $(shell git rev-parse --short HEAD)
targz_file := $(shell cat FILEPATH)
timestamp := $(shell date +"%Y%m%d%H%M")
REL :=$(shell cat VERSION)
default: loadS3_and_extract dockerbuild push
loadS3_and_extract:
aws s3 cp s3://$(AWS_BUCKET)/$(targz_file) ./binary.tar.gz
mkdir content/
tar xzf binary.tar.gz -C content/
ls -la content/
dockerbuild:
docker rmi -f $(NAMESPACE)/$(IMAGENAME):bak || true
docker tag $(NAMESPACE)/$(IMAGENAME) $(NAMESPACE)/$(IMAGENAME):bak || true
docker rmi -f $(NAMESPACE)/$(IMAGENAME) || true
docker build -t $(NAMESPACE)/$(IMAGENAME) .
testimg:
docker rm -f new-$(IMAGENAME) || true
docker run -d --name new-$(IMAGENAME) $(NAMESPACE)/$(IMAGENAME):latest
docker inspect -f '{{.NetworkSettings.IPAddress}}' new-$(IMAGENAME)
docker logs -f new-$(IMAGENAME)
push:
# push VERSION
docker tag -f $(NAMESPACE)/$(IMAGENAME):latest $(REGISTRY_URL)/$(NAMESPACE)/$(IMAGENAME):$(VERSION)
docker push $(REGISTRY_URL)/$(NAMESPACE)/$(IMAGENAME):$(VERSION)
docker rmi $(REGISTRY_URL)/$(NAMESPACE)/$(IMAGENAME):$(VERSION) || true
# push commit SHA
docker tag -f $(NAMESPACE)/$(IMAGENAME):latest $(REGISTRY_URL)/$(NAMESPACE)/$(IMAGENAME):$(SHA)
docker push $(REGISTRY_URL)/$(NAMESPACE)/$(IMAGENAME):$(SHA)
docker rmi $(REGISTRY_URL)/$(NAMESPACE)/$(IMAGENAME):$(SHA) || true
# push timestamp
docker tag -f $(NAMESPACE)/$(IMAGENAME):latest $(REGISTRY_URL)/$(NAMESPACE)/$(IMAGENAME):$(timestamp)
docker push $(REGISTRY_URL)/$(NAMESPACE)/$(IMAGENAME):$(timestamp)
docker rmi $(REGISTRY_URL)/$(NAMESPACE)/$(IMAGENAME):$(timestamp) || true
# push latest
docker tag -f $(NAMESPACE)/$(IMAGENAME):latest $(REGISTRY_URL)/$(NAMESPACE)/$(IMAGENAME):latest
# docker push $(REGISTRY_URL)/$(NAMESPACE)/$(IMAGENAME):latest
docker rmi $(REGISTRY_URL)/$(NAMESPACE)/$(IMAGENAME):latest || true