-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
43 lines (34 loc) · 1.13 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
IMAGE_NAME = wbor-groupme-image
CONTAINER_NAME = wbor-groupme
NETWORK_NAME = wbor-network
HOST_DIR = "/var/wbor-groupme"
default: clean build run logsf
q: clean build run
exec:
docker exec -it $(CONTAINER_NAME) /bin/bash
logsf:
docker logs -f $(CONTAINER_NAME)
build:
@echo "Building..."
nice -n 10 docker buildx build -q -t $(IMAGE_NAME) .
start: run
run: stop
docker run -d --network $(NETWORK_NAME) --name $(CONTAINER_NAME) -v ${HOST_DIR}/logs:/app/logs $(IMAGE_NAME)
stop:
@echo "Checking if container $(CONTAINER_NAME) is running..."
@if [ "$$(docker ps -a -q -f name=$(CONTAINER_NAME))" != "" ]; then \
echo "Stopping $(CONTAINER_NAME)..."; \
docker stop $(CONTAINER_NAME) > /dev/null; \
echo "Removing the container $(CONTAINER_NAME)..."; \
docker rm -f $(CONTAINER_NAME) > /dev/null; \
else \
echo "No running container with name $(CONTAINER_NAME) found."; \
fi
clean: stop
@IMAGE_ID=$$(docker images -q $(IMAGE_NAME)); \
if [ "$$IMAGE_ID" ]; then \
echo "Removing image $(IMAGE_NAME) with ID $$IMAGE_ID..."; \
docker rmi $$IMAGE_ID > /dev/null; \
else \
echo "No image found with name $(IMAGE_NAME)."; \
fi