Makefile 7.72 KB
Newer Older
1
2
3
4
######################################
#    Build File for Docker Images    #
######################################

Jose Raul Barreras's avatar
Jose Raul Barreras committed
5
6
7
8
# Repo
####################
REPO_ORG = its-registry.unl.edu/unl-its/docker-ci

Jose Raul Barreras's avatar
Jose Raul Barreras committed
9
10
11
12
13
14
15
16
17
18
# All Dockerfiles
####################
DOCKERFILES := $(shell find ./ -name "Dockerfile")

# Get the latest commit
####################
GIT_COMMIT = $(strip $(shell git rev-parse --short HEAD))

# Docker build arguments
####################
19
BUILD_ARGS := --build-arg VCS_REF=$(GIT_COMMIT)
Jose Raul Barreras's avatar
Jose Raul Barreras committed
20

Roger Feese's avatar
Roger Feese committed
21
.PHONY: all clean test $(DOCKERFILES) static-code-analysis mobile delete_dangling_images security publish utility dotnet
22

23
all: php-lint php-unit-test mobile static-code-analysis utility detect-secrets dependency-check xml-lint
24

25
26
# Image Groups
####################
Alan Nelson's avatar
Alan Nelson committed
27
28
php-lint: php-lint_5.6 php-lint_7.0 php-lint_7.1 php-lint_7.2 php-lint_7.3 php-lint_7.4 php-lint_8.0 php-lint_latest
php-unit-test: php-unit-test_5.6 php-unit-test_7.0 php-unit-test_7.1 php-unit-test_7.2 php-unit-test_7.3 php-unit-test_7.4 php-unit-test_8.0 php-unit-test_latest
29
30
mobile: android-build-server
static-code-analysis: static-code-analysis_latest static-code-analysys_php static-code-analysys_python static-code-analysys_android
Alan Nelson's avatar
Alan Nelson committed
31
utility: alpine-ssh-client merge-request-check
32
dotnet: dotnet_3.1 dotnet_5.0
33
34

# PHP Lint Images
35
####################
Jose Raul Barreras's avatar
Jose Raul Barreras committed
36
php-lint_5.6: php-lint/5.6/Dockerfile
Jose Raul Barreras's avatar
Jose Raul Barreras committed
37
	docker build $(BUILD_ARGS) -t ${REPO_ORG}/php-lint:5.6 -f php-lint/5.6/Dockerfile php-lint
38

Jose Raul Barreras's avatar
Jose Raul Barreras committed
39
php-lint_7.0: php-lint/7.0/Dockerfile
Jose Raul Barreras's avatar
Jose Raul Barreras committed
40
	docker build $(BUILD_ARGS) -t ${REPO_ORG}/php-lint:7.0 -f php-lint/7.0/Dockerfile php-lint
41

Jose Raul Barreras's avatar
Jose Raul Barreras committed
42
php-lint_7.1: php-lint/7.1/Dockerfile
Jose Raul Barreras's avatar
Jose Raul Barreras committed
43
	docker build $(BUILD_ARGS) -t ${REPO_ORG}/php-lint:7.1 -f php-lint/7.1/Dockerfile php-lint
44

Jose Raul Barreras's avatar
Jose Raul Barreras committed
45
php-lint_7.2: php-lint/7.2/Dockerfile
Jose Raul Barreras's avatar
Jose Raul Barreras committed
46
	docker build $(BUILD_ARGS) -t ${REPO_ORG}/php-lint:7.2 -f php-lint/7.2/Dockerfile php-lint
Alan Nelson's avatar
Alan Nelson committed
47

Alan Nelson's avatar
Alan Nelson committed
48
49
php-lint_7.3: php-lint/7.3/Dockerfile
	docker build $(BUILD_ARGS) -t ${REPO_ORG}/php-lint:7.3 -f php-lint/7.3/Dockerfile php-lint
50

Alan Nelson's avatar
Alan Nelson committed
51
52
53
54
55
56
php-lint_7.4: php-lint/7.4/Dockerfile
	docker build $(BUILD_ARGS) -t ${REPO_ORG}/php-lint:7.4 -f php-lint/7.4/Dockerfile php-lint

php-lint_8.0: php-lint/8.0/Dockerfile
	docker build $(BUILD_ARGS) -t ${REPO_ORG}/php-lint:8.0 -f php-lint/8.0/Dockerfile php-lint

Alan Nelson's avatar
Alan Nelson committed
57
58
59
60
61
php-lint_8.1: php-lint/8.1/Dockerfile
	docker build $(BUILD_ARGS) -t ${REPO_ORG}/php-lint:8.1 -f php-lint/8.1/Dockerfile php-lint

php-lint_latest: php-lint_8.1
	docker tag  ${REPO_ORG}/php-lint:8.1 ${REPO_ORG}/php-lint:latest
62

63
64
65
# PHP Unit Test Images
####################
php-unit-test_5.6: php-unit-test/5.6/Dockerfile
Jose Raul Barreras's avatar
Jose Raul Barreras committed
66
	docker build $(BUILD_ARGS) -t ${REPO_ORG}/php-unit-test:5.6 -f php-unit-test/5.6/Dockerfile php-unit-test
67
68

php-unit-test_7.0: php-unit-test/7.0/Dockerfile
Jose Raul Barreras's avatar
Jose Raul Barreras committed
69
	docker build $(BUILD_ARGS) -t ${REPO_ORG}/php-unit-test:7.0 -f php-unit-test/7.0/Dockerfile php-unit-test
70
71

php-unit-test_7.1: php-unit-test/7.1/Dockerfile
Jose Raul Barreras's avatar
Jose Raul Barreras committed
72
	docker build $(BUILD_ARGS) -t ${REPO_ORG}/php-unit-test:7.1 -f php-unit-test/7.1/Dockerfile php-unit-test
73
74

php-unit-test_7.2: php-unit-test/7.2/Dockerfile
Jose Raul Barreras's avatar
Jose Raul Barreras committed
75
	docker build $(BUILD_ARGS) -t ${REPO_ORG}/php-unit-test:7.2 -f php-unit-test/7.2/Dockerfile php-unit-test
76

Alan Nelson's avatar
Alan Nelson committed
77
78
79
php-unit-test_7.3: php-unit-test/7.3/Dockerfile
	docker build $(BUILD_ARGS) -t ${REPO_ORG}/php-unit-test:7.3 -f php-unit-test/7.3/Dockerfile php-unit-test

Alan Nelson's avatar
Alan Nelson committed
80
81
82
83
84
85
php-unit-test_7.4: php-unit-test/7.4/Dockerfile
	docker build $(BUILD_ARGS) -t ${REPO_ORG}/php-unit-test:7.4 -f php-unit-test/7.4/Dockerfile php-unit-test

php-unit-test_8.0: php-unit-test/8.0/Dockerfile
	docker build $(BUILD_ARGS) -t ${REPO_ORG}/php-unit-test:8.0 -f php-unit-test/8.0/Dockerfile php-unit-test

Alan Nelson's avatar
Alan Nelson committed
86
87
88
89
90
php-unit-test_8.1: php-unit-test/8.1/Dockerfile
	docker build $(BUILD_ARGS) -t ${REPO_ORG}/php-unit-test:8.1 -f php-unit-test/8.1/Dockerfile php-unit-test

php-unit-test_latest: php-unit-test_8.1
	docker tag ${REPO_ORG}/php-unit-test:8.1 ${REPO_ORG}/php-unit-test:latest
91

92
93
94
# Mobile Applications
####################
android-build-server: android-build-server/Dockerfile
Jose Raul Barreras's avatar
Jose Raul Barreras committed
95
	docker build $(BUILD_ARGS) -t ${REPO_ORG}/android-build-server:latest android-build-server
96

Jose Raul Barreras's avatar
Jose Raul Barreras committed
97
98
# Sonarqube static-code-analysis
# #####################
99
static-code-analysis_latest: static-code-analysis/Dockerfile
Jose Raul Barreras's avatar
Jose Raul Barreras committed
100
101
	docker build $(BUILD_ARGS) -t ${REPO_ORG}/static-code-analysis:latest static-code-analysis/

102
static-code-analysys_php: static-code-analysis/Dockerfile
Jose Raul Barreras's avatar
Jose Raul Barreras committed
103
104
	docker build $(BUILD_ARGS) -t ${REPO_ORG}/static-code-analysis:php static-code-analysis/

105
static-code-analysys_python: static-code-analysis/Dockerfile
Jose Raul Barreras's avatar
Jose Raul Barreras committed
106
107
	docker build $(BUILD_ARGS) -t ${REPO_ORG}/static-code-analysis:python static-code-analysis/

108
static-code-analysys_android: android-build-server static-code-analysis/android/Dockerfile
Jose Raul Barreras's avatar
Jose Raul Barreras committed
109
	docker build $(BUILD_ARGS) -t ${REPO_ORG}/static-code-analysis:android static-code-analysis/android/
110

111
112
113
114
115
# XML Lint Images
####################
xml-lint: xml-lint/Dockerfile
	docker build $(BUILD_ARGS) -t ${REPO_ORG}/xml-lint:latest xml-lint/

116
117
118
119
120
# Utility Images
####################
alpine-ssh-client: alpine-ssh-client/Dockerfile
	docker build $(BUILD_ARGS) -t ${REPO_ORG}/alpine-ssh-client:latest alpine-ssh-client/

Alan Nelson's avatar
Alan Nelson committed
121
122
123
merge-request-check: merge-request-check/Dockerfile
	docker build $(BUILD_ARGS) -t ${REPO_ORG}/merge-request-check:latest merge-request-check/

Jose Raul Barreras's avatar
Jose Raul Barreras committed
124
125
test: $(DOCKERFILES)
$(DOCKERFILES):
126
	@echo "Linting and validating $(@D)..."
Jose Raul Barreras's avatar
Jose Raul Barreras committed
127
128
129
	@docker run --rm -i nimmis/label-inspector lint < $(@D)/Dockerfile
	@docker run --rm -i nimmis/label-inspector validate < $(@D)/Dockerfile

130
131
132
133
134
135
136
137
138
139
140
141

# detect-secrets
# ##############
detect-secrets: detect-secrets/Dockerfile
	docker build $(BUILD_ARGS) -t ${REPO_ORG}/detect-secrets detect-secrets/


# dependency-check
# ################
dependency-check: dependency-check/Dockerfile
	 docker build $(BUILD_ARGS) -t ${REPO_ORG}/dependency-check dependency-check/

142
143
144
145
146
147
148
149
150
# dotnet Images
####################
dotnet_3.1: dotnet-build-server/3.1/Dockerfile
	docker build $(BUILD_ARGS) -t ${REPO_ORG}/dotnet-build-server:3.1 -f dotnet-build-server/3.1/Dockerfile dotnet-build-server/3.1/

dotnet_5.0: dotnet-build-server/5.0/Dockerfile
	docker build $(BUILD_ARGS) -t ${REPO_ORG}/dotnet-build-server:5.0 -f dotnet-build-server/5.0/Dockerfile dotnet-build-server/5.0/


151
#IMAGES_TO_SCAN = $(shell docker images --format '{{.Repository}}:{{.Tag}}' | grep unl-its )
152
153
154
155
156
157
#security:
#	@docker login -u ${TENABLE_IO_ACCESS_KEY} -p ${TENABLE_IO_SECRET_KEY} registry.cloud.tenable.com
#	@for image in $(IMAGES_TO_SCAN); do \
#		docker tag $$image registry.cloud.tenable.com/`echo $$image | cut -d "/" -f 2`; \
#		docker push registry.cloud.tenable.com/`echo $$image | cut -d "/" -f 2`; \
#	done
Jose Raul Barreras's avatar
Jose Raul Barreras committed
158

Alan Nelson's avatar
Alan Nelson committed
159
IMAGES_TO_PUBLISH = $(shell docker images --format '{{.Repository}}:{{.Tag}}' --filter 'dangling=false' --filter=reference='$(REPO_ORG)/$(IMG_NAME)*' | grep -v ':<none>$$')
Jose Raul Barreras's avatar
Jose Raul Barreras committed
160
161
162
163
164
publish:
	@for image in $(IMAGES_TO_PUBLISH); do \
		docker push $$image; \
	done

165
166
167
168
169
170
#Update README.md based on the template ._README.md
TOOLSET = `make all --dry-run | grep 'docker build' | cut -d ' ' -f 6 | sort -u | awk '{print "- " $$0}'`
README_HEAD = `cat ./_README.md | sed -e '/%CONTAINERS_LIST%/Q'`
README_TAIL = `cat ./_README.md | sed -e '1,/%CONTAINERS_LIST%/d'`
README_FOOTER = `echo "\n\r_Last update: \`date\`_\n"`
update_readme:
Alan Nelson's avatar
Alan Nelson committed
171
	@echo -e "$(README_HEAD)  \n\n$(TOOLSET) \n $(README_TAIL) \n$(README_FOOTER)" > README.md
172
173
	@git add README.md

Jose Raul Barreras's avatar
Jose Raul Barreras committed
174
delete_dangling_images:
175
176
	@echo "Removing dangling images"
	@docker image prune -f
Jose Raul Barreras's avatar
Jose Raul Barreras committed
177
help:
178
179
	@echo -e "make [all] \n\t # Creates all the images"
	@echo -e "make <TARGET> \n\t # Creates an specific image"
Jose Raul Barreras's avatar
Jose Raul Barreras committed
180
	@echo -e "make publish \n\t # Push the images to the UNL registry"
181
	@echo -e "make update_readme \n\t Update the README.md file"
182
#	@echo -e "make security \n\t # Send the images to Tenable. Use env variables TENABLE_IO_ACCESS_KEY and TENABLE_IO_SECRET_KEY"
Jose Raul Barreras's avatar
Jose Raul Barreras committed
183

184
185
debug:
	@echo -e "DOCKERFILES: \t $(DOCKERFILES)"
186
#	@echo -e "IMAGES_TO_SCAN:\t $(IMAGES_TO_SCAN)"
Jose Raul Barreras's avatar
Jose Raul Barreras committed
187
	@echo -e "IMAGES_TO_PUBLISH:\t $(IMAGES_TO_PUBLISH)"