This repository has been archived by the owner on May 30, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
/
Makefile
53 lines (46 loc) · 2.15 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
45
46
47
48
49
50
51
52
53
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")
VERSION :=$(shell cat VERSION)
#| sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]$//')
default: download dockerbuild push
loadS3_and_extract:
aws s3 cp s3://$(AWS_BUCKET)/$(targz_file) >./binary.tar.gz
mkdir contents/
tar xzf binary.tar.gz -C content/
ls -la content/
download:
curl -L https://github.com/spf13/hugo/releases/download/v$(VERSION)/hugo_$(VERSION)_linux_arm.tar.gz > ./binary.tar.gz
mkdir content/
tar xzf binary.tar.gz -C content/
cd content && \
mv hugo*/hugo* ./hugo
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