-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
72 lines (59 loc) · 2.75 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
ENV_FILE = ./docker/.env
include $(ENV_FILE)
DOCKER_COMPOSE_PATH = ./docker/docker-compose.yaml
# use `gawk` on mac os
AWK := awk
ifeq ($(shell uname -s), Darwin)
AWK = gawk
ifeq (, $(shell which gawk 2> /dev/null))
$(error "gawk not found")
endif
endif
################################################################################
# Miscellaneous
################################################################################
.PHONY: help
## (default) Show help page.
help:
@echo "$$(tput bold)Available rules:$$(tput sgr0)";echo;sed -ne"/^## /{h;s/.*//;:d" -e"H;n;s/^## //;td" -e"s/:.*//;G;s/\\n## /---/;s/\\n/ /g;p;}" ${MAKEFILE_LIST}|awk -F --- -v n=$$(tput cols) -v i=29 -v a="$$(tput setaf 6)" -v z="$$(tput sgr0)" '{printf"%s%*s%s ",a,-i,$$1,z;m=split($$2,w," ");l=n-i;for(j=1;j<=m;j++){l-=length(w[j])+1;if(l<= 0){l=n-i-length(w[j])-1;printf"\n%*s ",-i," ";}printf"%s ",w[j];}printf"\n\n";}'
################################################################################
# Containers
################################################################################
.PHONY: docker-build
## Build docker container static server.
docker-build:
@docker compose -f $(DOCKER_COMPOSE_PATH) --env-file $(ENV_FILE) build
.PHONY: docker-start
## Start docker compose containers (all by default).
## Format: `docker-start [compose=<docker-compose-service>]`.
## Example: `docker-start`, `docker-stop compose=postgres`.
docker-start:
@docker compose -f $(DOCKER_COMPOSE_PATH) --env-file $(ENV_FILE) up -d $(compose)
.PHONY: docker-stop
## Stop docker compose containers (all by default).
## Format: `docker-stop [compose=<docker-compose-service>]`.
## Example: `docker-stop`, `docker-stop compose=postgres`.
docker-stop:
@docker compose -f $(DOCKER_COMPOSE_PATH) stop $(compose)
.PHONY: docker-ash
## Run `ash` in docker container of static server.
docker-ash:
@docker exec -it $(SERVICE_NAME) /bin/ash
.PHONY: docker-clean
## Remove containers, networks, volumes, and images created by `make docker-start`.
docker-clean:
@docker compose -f $(DOCKER_COMPOSE_PATH) down
.PHONY: build-image
## Build docker image of frontend static server with name.
build-image:
@docker build -f docker/Dockerfile --platform linux/amd64 -t daronenko/$(SERVICE_NAME)-frontend:$(VERSION) .
.PHONY: push-image
## Push docker image of frontend static server to the docker hub.
push-image:
@docker push daronenko/$(SERVICE_NAME)-frontend:$(VERSION)
.PHONY: docker-rebuild
## Rebuild and restart the Docker containers with the latest changes.
docker-rebuild:
@docker compose -f $(DOCKER_COMPOSE_PATH) --env-file $(ENV_FILE) down
@docker compose -f $(DOCKER_COMPOSE_PATH) --env-file $(ENV_FILE) build --no-cache
@docker compose -f $(DOCKER_COMPOSE_PATH) --env-file $(ENV_FILE) up -d --force-recreate