-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
74 lines (63 loc) · 2.31 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
#Makefile for Docker container control
# Include additional variables
include /srv/flexget/a.mk
# Define container repo and runtime name
CONTAINER_REPO = hobbsau/flexget
CONTAINER_RUN = flexget-service
# Define the exportable volumes for the container
CONFIG_VOL = /home/flexget
# This should point to the Docker host directory containing the config. The host directory must be owned by UID:GID 1000:1000. The format is '/host/directory:'
CONFIG_BIND = /srv/flexget:
# URL for triggering a rebuild
TRIGGER_URL = https://registry.hub.docker.com/u/hobbsau/flexget/trigger/2027097b-e475-417e-ae58-e3de7b33f66b/
# Trigger a remote initiated rebuild
build:
echo "Rebuilding repository $(CONTAINER_REPO) ...";
@curl --data build=true -X POST $(TRIGGER_URL)
# Intantiate service continer and start it
run:
@if [ -z "`docker ps -a -q -f name=$(CONTAINER_RUN)`" ]; \
then \
echo "Checking for latest container..."; \
docker pull $(CONTAINER_REPO); \
echo "Creating and starting container..."; \
docker run -d \
--restart=always \
-v $(CONFIG_BIND)$(CONFIG_VOL) \
-v $(DATA_BIND_1)$(DATA_VOL_1):ro \
-v $(DATA_BIND_2)$(DATA_VOL_2):ro \
--name $(CONTAINER_RUN) \
$(CONTAINER_REPO); \
else \
echo "$(CONTAINER_RUN) is already running or a stopped container by the same name exists!"; \
echo "Please try 'make clean' and then 'make run'"; \
fi
# Start the service container.
start:
@if [ -z "`docker ps -q -f name=$(CONTAINER_RUN)`" ] && [ -n "`docker ps -a -q -f name=$(CONTAINER_RUN)`" ]; \
then \
echo "Starting container..."; \
docker start $(CONTAINER_RUN); \
else \
echo "Container $(CONTAINER_RUN) doesn't exist or is already running!"; \
fi
# Stop the service container.
stop:
@if [ -z "`docker ps -q -f name=$(CONTAINER_RUN)`" ]; \
then \
echo "Nothing to stop as container $(CONTAINER_RUN) is not running!"; \
else \
echo "Stopping container..."; \
docker stop $(CONTAINER_RUN); \
fi
# Service container is ephemeral so clean should be used with impunity.
clean: stop
@if [ -z "`docker ps -a -q -f name=$(CONTAINER_RUN)`" ]; \
then \
echo "Nothing to remove as container $(CONTAINER_RUN) does not exist!"; \
else \
echo "Removing container..."; \
docker rm $(CONTAINER_RUN); \
fi
# Upgrade the container - may not work if rebuild takes too long
upgrade: build clean run