-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile
35 lines (27 loc) · 1.08 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
SHELL := /bin/bash
TEMPLATE_IMAGES = $(shell find * -type f -name 'Dockerfile.template' -not -path "." | xargs -I {} dirname {})
IMAGES = $(shell find * -type f -name 'Dockerfile' -not -path "." | xargs -I {} dirname {})
GIT_COMMIT_ID=$(shell git rev-parse --short HEAD)
export GIT_COMMIT_ID
GIT_BRANCH=$(shell git describe --abbrev=1 --tags --always)
export GIT_BRANCH
REPO=ghcr.io/unchartedsky
template: $(TEMPLATE_IMAGES)
for TEMPLATE_IMAGE in $(TEMPLATE_IMAGES) ; do \
cat $${TEMPLATE_IMAGE}/Dockerfile.template | docker run -i --rm subfuzion/envtpl > $${TEMPLATE_IMAGE}/Dockerfile ; \
done
image: template
@ for IMAGE in $(IMAGES) ; do \
echo Building $(REPO)/$${IMAGE}:$(GIT_COMMIT_ID) ; \
docker build -t $(REPO)/$${IMAGE}:$(GIT_COMMIT_ID) $${IMAGE} ; \
docker tag $(REPO)/$${IMAGE}:$(GIT_COMMIT_ID) $(REPO)/$${IMAGE}:latest ; \
done
deploy: image
@ for IMAGE in $(IMAGES) ; do \
echo Pushing $(REPO)/$${IMAGE}:$(GIT_COMMIT_ID) ; \
docker push $(REPO)/$${IMAGE}:$(GIT_COMMIT_ID) ; \
docker push $(REPO)/$${IMAGE}:latest ; \
done
.PHONY: clean
clean: ;
cleanall: clean ;