forked from scottgigawatt/wiki
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
147 lines (126 loc) Β· 3.62 KB
/
Makefile
File metadata and controls
147 lines (126 loc) Β· 3.62 KB
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
#
# Makefile for managing Docker Compose services.
# This Makefile includes targets for building, starting, stopping, and cleaning Docker services.
# It ensures that necessary dependencies are installed and Docker images are built with specified options.
#
#
# Makefile targets
#
ALL=all
DOWN=down
CLEAN=clean
BUILD_DEPENDS=build-depends
BUILD=build
UP=up
LOGS=logs
OPEN=open
HELP=help
START=start
#
# Docker Compose service name
#
COMPOSE_SERVICE_NAME ?= mkdocs-material
#
# Docker Compose service down timeout
#
COMPOSE_DOWN_TIMEOUT ?= 30
#
# Docker Compose down options
#
COMPOSE_DOWN_OPTIONS ?= --timeout $(COMPOSE_DOWN_TIMEOUT) --rmi all --volumes
#
# Docker Compose build options
#
COMPOSE_BUILD_OPTIONS ?= --pull --no-cache
#
# Docker Compose up options
#
COMPOSE_UP_OPTIONS ?= --build --force-recreate --pull always --detach
#
# Docker Compose logs options
#
COMPOSE_LOGS_OPTIONS ?= --follow
#
# Build dependencies
#
DEPENDENCIES=docker docker-compose
#
# Extract base FROM image from Dockerfile
#
FROM_IMAGE=$(shell awk '/^FROM / { print $$2 }' docker/Dockerfile | sed 's/:.*//' | head -n 1)
#
# Targets that are not files (i.e. never up-to-date); these will run every
# time the target is called or required.
#
.PHONY: $(ALL) $(DOWN) $(CLEAN) $(BUILD_DEPENDS) $(BUILD) $(UP) $(LOGS) $(OPEN) $(HELP) $(START)
#
# $(ALL): Default makefile target. Builds and starts the service stack.
#
$(ALL): $(UP)
#
# $(BUILD_DEPENDS): Ensure build dependencies are installed.
#
$(BUILD_DEPENDS):
$(foreach exe,$(DEPENDENCIES), \
$(if $(shell which $(exe) 2> /dev/null),,$(error "No $(exe) in PATH")))
#
# $(DOWN): Stops containers and removes containers, networks, volumes, and images created by up.
#
$(DOWN): $(BUILD_DEPENDS)
@echo "\nStopping service $(COMPOSE_SERVICE_NAME)"
docker-compose down $(COMPOSE_DOWN_OPTIONS)
@for i in `docker images -aq "$(FROM_IMAGE)"`; do \
echo "Removing image $$i"; \
docker rmi -f "$$i" || true; \
done
#
# $(BUILD): Builds the service stack.
#
# Dependencies: $(BUILD_DEPENDS) - Ensure build dependencies are installed.
#
$(BUILD): $(BUILD_DEPENDS)
@echo "\nBuilding service $(COMPOSE_SERVICE_NAME)"
docker-compose build $(COMPOSE_BUILD_OPTIONS) $(COMPOSE_SERVICE_NAME)
#
# $(UP): Builds, (re)creates, and starts containers for services.
#
$(UP): $(BUILD_DEPENDS)
@echo "\nStarting service $(COMPOSE_SERVICE_NAME)"
HOST_WIKI_PATH=${PWD} docker-compose up $(COMPOSE_UP_OPTIONS)
#
# $(LOGS): View output from containers.
#
$(LOGS):
@echo "\nGetting logs for service $(COMPOSE_SERVICE_NAME)"
docker-compose logs $(COMPOSE_LOGS_OPTIONS)
#
# $(OPEN): Opens the service site in the default web browser.
#
$(OPEN):
@echo "\nOpening $(COMPOSE_SERVICE_NAME) site in default browser"
open "http://localhost:`docker-compose port $(COMPOSE_SERVICE_NAME) 8000 | cut -d: -f2`"
#
# $(HELP): Print help information.
#
$(HELP):
@echo "Usage: make [TARGET]"
@echo ""
@echo "Targets:"
@echo " $(ALL) - Builds and starts the service stack."
@echo " $(BUILD_DEPENDS) - Ensures build dependencies are installed."
@echo " $(DOWN) - Stops and removes containers, networks, volumes, and images."
@echo " $(CLEAN) - Alias for $(DOWN)."
@echo " $(BUILD) - Builds the service stack."
@echo " $(UP) - Builds, (re)creates, and starts containers for services."
@echo " $(START) - Alias for $(UP)."
@echo " $(LOGS) - Shows logs for the service."
@echo " $(OPEN) - Opens the service site in the default web browser."
@echo " $(HELP) - Displays this help message."
#
# Alias for down
#
$(CLEAN): $(DOWN)
#
# Alias for up
#
$(START): $(UP)