This repository has been archived by the owner on Mar 31, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
149 lines (108 loc) · 3.42 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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
### BASE_IMAGE #################################################################
BASE_IMAGE_NAME ?= $(DOCKER_PROJECT)/lighttpd
BASE_IMAGE_TAG ?= 1.4.49
### DOCKER_IMAGE ###############################################################
SIMPLE_CA_VERSION ?= 1.1.1
DOCKER_PROJECT ?= sicz
DOCKER_PROJECT_DESC ?= A simple automated Certificate Authority
DOCKER_PROJECT_URL ?= https://github.com/sicz/docker-simple-ca
DOCKER_NAME ?= simple-ca
DOCKER_IMAGE_TAG ?= $(SIMPLE_CA_VERSION)
DOCKER_IMAGE_TAGS ?= latest
### BUILD ######################################################################
# Docker image build variables
BUILD_VARS += SIMPLE_CA_VERSION
### DOCKER_EXECUTOR ############################################################
# Use the Docker Compose executor
DOCKER_EXECUTOR ?= compose
# Variables used in the Docker Compose file
COMPOSE_VARS += SERVER_CRT_HOST \
SERVICE_NAME
# Certificate subject aletrnative names
SERVER_CRT_HOST ?= $(shell echo $(SERVICE_NAME) | tr "_" "-").local
### DOCKER_MAKE_VARS ###########################################################
# Display the make variables
MAKE_VARS ?= GITHUB_MAKE_VARS \
BASE_IMAGE_MAKE_VARS \
DOCKER_IMAGE_MAKE_VARS \
BUILD_MAKE_VARS \
EXECUTOR_MAKE_VARS \
CONFIG_MAKE_VARS \
SHELL_MAKE_VARS \
DOCKER_REGISTRY_MAKE_VARS
define CONFIG_MAKE_VARS
SIMPLE_CA_VERSION: $(SIMPLE_CA_VERSION)
SERVER_CRT_HOST: $(SERVER_CRT_HOST)
endef
export CONFIG_MAKE_VARS
### MAKE_TARGETS ###############################################################
# Build a new image and run the tests
.PHONY: all
all: clean build start wait logs test
# Build a new image and run the tests
.PHONY: ci
ci: all
@$(MAKE) clean
### BUILD_TARGETS ##############################################################
# Build a new image with using the Docker layer caching
.PHONY: build
build: docker-build
# Build a new image without using the Docker layer caching
.PHONY: rebuild
rebuild: docker-rebuild
### EXECUTOR_TARGETS ###########################################################
# Display the configuration file
.PHONY: config-file
config-file: display-config-file
# Display the make variables
.PHONY: makevars vars
makevars vars: display-makevars
# Remove the containers and then run them fresh
.PHONY: run up
run up: docker-up
# Create the containers
.PHONY: create
create: docker-create
@true
# Start the containers
.PHONY: start
start: create docker-start
# Wait for the start of the containers
.PHONY: wait
wait: start docker-wait
# Display running containers
.PHONY: ps
ps: docker-ps
# Display the container logs
.PHONY: logs
logs: docker-logs
# Follow the container logs
.PHONY: logs-tail tail
logs-tail tail: docker-logs-tail
# Run shell in the container
.PHONY: shell sh
shell sh: start docker-shell
# Run the tests
.PHONY: test
test: start docker-test
# Run the shell in the test container
.PHONY: test-shell tsh
test-shell tsh:
@$(MAKE) test TEST_CMD=/bin/bash
# Stop the containers
.PHONY: stop
stop: docker-stop
# Restart the containers
.PHONY: restart
restart: stop start
# Remove the containers
.PHONY: down rm
down rm: docker-rm
# Remove all containers and work files
.PHONY: clean
clean: docker-clean
### MAKE_TARGETS ###############################################################
PROJECT_DIR ?= $(CURDIR)
MK_DIR ?= $(PROJECT_DIR)/../Mk
include $(MK_DIR)/docker.image.mk
################################################################################