-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
189 lines (147 loc) · 4.76 KB
/
Makefile
File metadata and controls
189 lines (147 loc) · 4.76 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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
##
## Variables
##
PROJ_ENV = local
DOCKER_DIR := docker/local
include $(DOCKER_DIR)/.env
DOCKER_COMPOSE = docker-compose -f $(DOCKER_DIR)/docker-compose.yaml
DOCKER_COMPOSE_DB = docker-compose -f $(DOCKER_DIR)/docker-compose-db.yaml
##
## General functions
##
## Global configuration
.DELETE_ON_ERROR:
help:
@echo ' '
@echo 'Makefile for generating basic skeleton for Python - Flask app '
@echo ' '
@echo 'Usage: '
@echo ' make Print the help '
@echo ' make help Print the help '
@echo ' make load-vars Import the variables '
@echo ' make build-structure Creates the directory structure '
@echo ' make build Build the environment from scratch '
@echo ' make urls Print the application URLs '
@echo ' make start Start the application '
@echo ' make stop Stop the application '
@echo ' make status Display the status of the containers '
@echo ' make destroy Delete the environment '
@echo ' make logs Display logs for the Python container '
@echo ' make logs-db Display logs for the Postgres container '
@echo ' make ssh Connect to the Python container '
@echo ' make ssh-db Connect to the Postgres container '
@echo ' make connect-db Connect to the Postgres database locally using psql command '
@echo ' make requirements Install packages from the requirements.txt file '
@echo ' make sonarqube-analysis Run Sonarqube analysis '
@echo ' make sonarqube-check Check the status of the project '
@echo ' '
# This functions creates the directory structure
# NOTE: This functions MUST be run just once
build-structure:
@echo "build-structure... Running..."
# Prepare the project for Flask or just Python
ifeq ($(PYTHON_BUILD),true)
@mv $(DEFAULT_DIR)/file.py $(DEFAULT_DIR)/__init__.py
else
@rm $(DEFAULT_DIR)/file.py
endif
# Prepare the project directory structure
ifeq ($(SRC_BUILD),false)
@if [ -z "$(wildcard $(DEFAULT_DIR)/*)" ]; then \
echo "The directory '$(DEFAULT_DIR)' is empty, so there is nothing to copy."; \
exit 1; \
fi
@mv $(DEFAULT_DIR)/* .
@rmdir $(DEFAULT_DIR)/
endif
build:
ifeq ($(POSTGRESQL_BUILD),true)
@$(MAKE) -f build/makefile_postgresql build
else
@$(MAKE) -f build/makefile_no_postgresql build
endif
urls:
ifeq ($(POSTGRESQL_BUILD),true)
@$(MAKE) -f build/makefile_postgresql urls
else
@$(MAKE) -f build/makefile_no_postgresql urls
endif
start:
ifeq ($(POSTGRESQL_BUILD),true)
@$(MAKE) -f build/makefile_postgresql start
else
@$(MAKE) -f build/makefile_no_postgresql start
endif
stop:
ifeq ($(POSTGRESQL_BUILD),true)
@$(MAKE) -f build/makefile_postgresql stop
else
@$(MAKE) -f build/makefile_no_postgresql stop
endif
status:
ifeq ($(POSTGRESQL_BUILD),true)
@$(MAKE) -f build/makefile_postgresql status
else
@$(MAKE) -f build/makefile_no_postgresql status
endif
destroy:
ifeq ($(POSTGRESQL_BUILD),true)
@$(MAKE) -f build/makefile_postgresql destroy
else
@$(MAKE) -f build/makefile_no_postgresql destroy
endif
ssh:
ifeq ($(POSTGRESQL_BUILD),true)
@$(MAKE) -f build/makefile_postgresql ssh
else
@$(MAKE) -f build/makefile_no_postgresql ssh
endif
ssh-db:
ifeq ($(POSTGRESQL_BUILD),true)
@$(MAKE) -f build/makefile_postgresql ssh-db
else
@echo "You are not using Postgres..."
endif
connect-db:
ifeq ($(POSTGRESQL_BUILD),true)
@$(MAKE) -f build/makefile_postgresql connect-db
else
@echo "You are not using Postgres..."
endif
logs:
ifeq ($(POSTGRESQL_BUILD),true)
@$(MAKE) -f build/makefile_postgresql logs
else
@$(MAKE) -f build/makefile_no_postgresql logs
endif
logs-db:
ifeq ($(POSTGRESQL_BUILD),true)
@$(MAKE) -f build/makefile_no_postgresql logs-db
else
@echo "You are not using Postgres..."
endif
requirements:
ifeq ($(POSTGRESQL_BUILD),true)
@$(MAKE) -f build/makefile_postgresql requirements
else
@$(MAKE) -f build/makefile_no_postgresql requirements
endif
sonarqube-setup:
ifeq ($(POSTGRESQL_BUILD),true)
@$(MAKE) -f build/makefile_postgresql sonarqube-setup
else
@$(MAKE) -f build/makefile_no_postgresql sonarqube-setup
endif
sonarqube-analysis:
ifeq ($(POSTGRESQL_BUILD),true)
@$(MAKE) -f build/makefile_postgresql sonarqube-analysis
else
@$(MAKE) -f build/makefile_no_postgresql sonarqube-analysis
endif
sonarqube-check:
ifeq ($(POSTGRESQL_BUILD),true)
@$(MAKE) -f build/makefile_postgresql sonarqube-check
else
@$(MAKE) -f build/makefile_no_postgresql sonarqube-check
endif
.PHONY: help build-structure build urls start stop status destroy logs logs-db ssh ssh-db connect-db requirements sonarqube-setup sonarqube-analysis sonarqube-check