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
/
Copy pathMakefile
143 lines (104 loc) · 3.44 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
### BASE_IMAGE #################################################################
BASE_IMAGE_NAME ?= $(DOCKER_PROJECT)/baseimage-alpine
BASE_IMAGE_TAG ?= 3.8
### DOCKER_IMAGE ###############################################################
DOCKER_NAME ?= dockerspec
DOCKER_PROJECT_DESC ?= An image intended to run Docker image tests using RSpec and ServerSpec
DOCKER_PROJECT_URL ?= http://serverspec.org
DOCKER_IMAGE_TAG ?= 1.1.0
DOCKER_IMAGE_TAGS ?= latest
### BUILD ######################################################################
# Docker image build variables
BUILD_VARS += DOCKER_VERSION \
DOCKER_COMPOSE_VERSION \
GEM_DOCKER_API_VERSION \
GEM_RSPEC_VERSION \
GEM_SPECINFRA_VERSION \
GEM_SERVERSPEC_VERSION \
RUBY_VERSION
# Supported Docker Compose file versions:
# - docker-18.03.1: 3.6
# - docker-compose-1.21.1: 3.6
DOCKER_VERSION ?= 18.03.1-ce
DOCKER_COMPOSE_VERSION ?= 1.21.1
RUBY_VERSION ?= 2.5.1
GEM_DOCKER_API_VERSION ?= 1.34.2
GEM_RSPEC_VERSION ?= 3.7.0
GEM_SPECINFRA_VERSION ?= 2.75.0
GEM_SERVERSPEC_VERSION ?= 2.41.3
### DOCKER_EXECUTOR ############################################################
# Use the Docker Compose executor
DOCKER_EXECUTOR ?= compose
### TEST #######################################################################
# Use itself version for tests
TEST_IMAGE_TAG ?= $(DOCKER_IMAGE_TAG)
### MAKE_TARGETS ###############################################################
# Build a new image and run tests for current configuration
.PHONY: all
all: clean build start wait logs test
# Build a new image and run tests for all configurations
.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 for the current configuration
.PHONY: config-file
config-file: display-config-file
# Display the make variables for the current configuration
.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
# 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 the shell in the container
.PHONY: shell sh
shell sh: start docker-shell
# Run the current configuration 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
### MK_DOCKER_IMAGE ############################################################
PROJECT_DIR ?= $(CURDIR)
MK_DIR ?= $(PROJECT_DIR)/../Mk
include $(MK_DIR)/docker.image.mk
################################################################################