-
Notifications
You must be signed in to change notification settings - Fork 45
/
Makefile
executable file
·89 lines (65 loc) · 1.82 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
.PHONY: help
help: ## helper
@fgrep -h "##" $(MAKEFILE_LIST) | fgrep -v fgrep | sed -e 's/\\$$//' | sed -e 's/##//'
.DEFAULT_GOAL := help
CONF ?= ./.env
VERSION = "1.0"
ifeq ($(which docker-compose),"")
DOCKER_COMPOSE_BIN=docker-compose
else
DOCKER_COMPOSE_BIN=docker compose
endif
version: ## version
@echo ${VERSION}
##
ifeq ($(shell test -e $(CONF) && echo -n yes),yes)
include $(CONF)
export $(shell sed 's/=.*//' $(CONF))
TAG = "latest"
image_build: ## build immagine
@docker build --tag "$(IMAGENAME):$(TAG)" \
--no-cache \
--target=$(ENV) \
--build-arg ENV=$(ENV) \
--build-arg APPNAME=$(APPNAME) \
--build-arg DOMAIN=$(DOMAIN) \
--build-arg WORKDIR_USER=$(WORKDIR_USER) \
--build-arg WORKDIR_GROUP=$(WORKDIR_GROUP) \
--build-arg WORKDIRPATH=$(WORKDIRPATH) \
$(DOCKERFILE_PATH)
image_push: ## publish image
@docker push "$(IMAGENAME):$(TAG)"
image_run:
@docker run -d --rm -p 80:80 -p 9000:9000 --name $(APPNAME) $(IMAGENAME):$(TAG)
## ENV: DEV
ifeq ($(ENV),develop)
down: ## down containers
$(DOCKER_COMPOSE_BIN) down
up: ## up -d containers
$(DOCKER_COMPOSE_BIN) up -d
build: # build containers
$(DOCKER_COMPOSE_BIN) build
exec: ## enter in app container
@docker exec -it $(APPNAME) /bin/bash
exec_mysql: ## enter in mysql container
@docker exec -it mysql /bin/bash
ssh_setup:
./setup.sh --ssh-setup
ssh_root: ## connessione ssh con l'utenza root o sudoers
@ssh -i $(SSHKEY) $(SRV_USER)@$(SRV_HOST)
ssh: ## connessione ssh con l'utente proprietario della workdir
@ssh -i $(SSHKEY) $(SRV_USER_WK)@$(SRV_HOST)
deploy: down build up ## rebuild containers
endif
endif
##
## APP NON CONFIGURATA
ifneq ($(shell test -e $(CONF) && echo -n yes),yes)
setup: #first install
@chmod +x ./setup.sh
@./setup.sh
manual: ## manuale configurazione
@echo "read Readme.md"
@echo "Missing .env file"
endif
##