forked from marcelbirkner/docker-ci-tool-stack
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
92 lines (73 loc) · 2.54 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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
##############################################################################
# Environment variables
# Set locales
#
CITY=$(shell timedatectl | awk '/Time zone/ {print $$3}' | awk -F/ '{print $$2}')
COUNTRY=$(shell echo $$LANG | awk -F. '{print $$1}' | awk -F_ '{print $$2}')
LANGUAGE=$(shell echo $$LANG | awk -F. '{print $$1}' | awk -F_ '{print $$2}')
TIMEZONE=$(shell timedatectl | awk '/Time zone/ {print $$3}')
##############################################################################
.PHONY: help # This help message
help:
@grep '^.PHONY: .* #' Makefile \
| sed 's/\.PHONY: \(.*\) # \(.*\)/\1\t\2/' \
| expand -t20 \
| sort
##############################################################################
.PHONY: prepare # Generate Dockerfiles from templates
prepare:
# Sonar: Set locales and proxy
@sed "s!%%COUNTRY%%!${COUNTRY}! ; \
s!%%LANGUAGE%%!${LANGUAGE}! ; \
s!%%TIMEZONE%%!${TIMEZONE}! ; \
s!%%HTTP_PROXY%%!${HTTP_PROXY}!" \
sonar/Dockerfile.tmpl > sonar/Dockerfile
# Jenkins: Set locales and proxy
@sed "s!%%HTTP_PROXY%%!${HTTP_PROXY}!" \
jenkins/Dockerfile.tmpl > jenkins/Dockerfile
@test -z ${HTTP_PROXY} \
&& sed '/HTTP_PROXY/d' \
jenkins/Dockerfile.tmpl > jenkins/Dockerfile \
|| true
# Nexus: Set proxy
@sed "s!%%HTTP_PROXY%%!${HTTP_PROXY}!" \
nexus/Dockerfile.tmpl > nexus/Dockerfile
@test -z ${HTTP_PROXY} \
&& sed '/^HTTP_OPTIONS/d' \
nexus/Dockerfile.tmpl > nexus/Dockerfile \
|| true
# docker-compose: Set traefik virtualhost
@test -z ${TRAEFIK_VIRTUALHOST} \
&& sed "s/%%TRAEFIK_VIRTUALHOST%%/localhost/" \
docker-compose.yml.tmpl > docker-compose.yml \
|| sed "s/%%TRAEFIK_VIRTUALHOST%%/${TRAEFIK_VIRTUALHOST}/" \
docker-compose.yml.tmpl > docker-compose.yml
.PHONY: clean # Stop and remove temporary files
clean: down
@docker-compose rm
@rm -f \
jenkins/Dockerfile \
nexus/Dockerfile \
sonar/Dockerfile \
docker-compose.yml
##############################################################################
.PHONY: status # Get stack status "docker-compose ps"
status:
@docker-compose ps
.PHONY: up # Start "docker-compose up"
up: prepare
@docker-compose up
.PHONY: daemon # Start "docker-compose up -d"
daemon: prepare
@docker-compose up -d
.PHONY: down # Stop the stack "docker-compose down"
down:
@docker-compose down
.PHONY: rebuild # Rebuild the containers and run
rebuild: prepare
@docker-compose down --rmi all
@docker-compose up --build
.PHONY: daemon-rebuild # Rebuild the containers and run
daemon-rebuild: prepare
@docker-compose down --rmi all
@docker-compose up --build -d