-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
146 lines (129 loc) · 4.38 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
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
# https://makefiletutorial.com/
# load .env file
include ./src/.env
repo:
@if [ -d .git ]; then \
echo "\033[31mPlease enter github repo name: \033[0m "; \
read -r repo; \
gh repo create dclmict/$$repo --public --source=. --remote=origin; \
echo "\033[31m Enter commit message\033[0m"; \
read -r cm; \
git add . && git commit -m "$$cm"; \
git push --set-upstream origin main; \
else \
echo "\033[31mPlease enter github repo name: \033[0m "; \
git init && git add . && git commit -m "DCLM DAM"; \
read -r repo; \
gh repo create dclmict/$$repo --public --source=. --remote=origin; \
echo "\033[31m Enter commit message\033[0m"; \
read -r cm; \
git add . && git commit -m "$$cm"; \
git push --set-upstream origin main; \
fi
git:
@if git status --porcelain | grep -q '^??'; then \
echo "\033[31mUntracked files found::\033[0m \033[32mPlease enter commit message:\033[0m"; \
read -r msg1; \
git add -A; \
git commit -m "$$msg1"; \
read -p "Do you want to push your commit to GitHub? (yes|no): " choice; \
case "$$choice" in \
yes|Y|y) \
echo "\033[32mPushing commit to GitHub...:\033[0m"; \
git push; \
;; \
no|N|n) \
echo "\033[32m Nothing to be done. Thank you...:\033[0m"; \
exit 0; \
;; \
*) \
echo "\033[32m No choice. Exiting script...:\033[0m"; \
exit 1; \
;; \
esac \
else \
echo "\033[31mThere are no new files::\033[0m \033[32mPlease enter commit message:\033[0m"; \
read -r msg2; \
git commit -am "$$msg2"; \
read -p "Do you want to push your commit to GitHub? (yes|no): " choice; \
case "$$choice" in \
yes|Y|y) \
echo "\033[32mPushing commit to GitHub...:\033[0m"; \
git push; \
;; \
no|N|n) \
echo "\033[32m Nothing to be done. Thank you...:\033[0m"; \
exit 0; \
;; \
*) \
echo "\033[32m No choice. Exiting script...:\033[0m"; \
exit 1; \
;; \
esac \
fi
build:
@if docker images | grep -q $(DIN); then \
echo "\033[31mRemoving all dangling images\033[0m image"; \
echo y | docker image prune --filter="dangling=true"; \
echo "\033[31mRemoving $(DIN):$(DIV) image\033[0m"; \
docker image rm $(DIN):$(DIV); \
echo "Building \033[31m$(DIN):$(DIV)\033[0m image"; \
docker build -t $(DIN):$(DIV) .; \
docker images | grep $(DIN); \
else \
echo "Building \033[31m$(DIN):$(DIV)\033[0m image"; \
docker build -t $(DIN):$(DIV) .; \
docker images | grep $(DIN); \
fi
push:
cp ./ops/.env.dev ./src/.env
echo ${DLP} | docker login -u opeoniye --password-stdin
docker push $(DIN):$(DIV)
dev:
cp ./ops/.env.dev ./src/.env
cp ./docker-dev.yml ./src/docker-compose.yml
docker compose -f ./src/docker-compose.yml --env-file ./src/.env up -d
prod:
@if [ -d .git ]; then \
echo "\033[31mDirectory exists, starting container...\033[0m"; \
touch ops/.env.prod; \
echo "\033[32mPaste .env content and save with :wq\033[0m"; \
vim ops/.env.prod; \
cp ./ops/.env.prod ./src/.env; \
cp ./docker-prod.yml ./src/docker-compose.yml; \
docker pull $(DIN):$(DIV); \
docker compose -f ./src/docker-compose.yml --env-file ./src/.env up -d; \
else \
echo "\033[31mDirectory not found, setting up project...\033[0m"; \
git clone https://github.com/dclmict/dclm-dam.git .; \
sudo chown -R ubuntu:ubuntu .; \
touch ops/.env.prod; \
echo "\033[32mPaste .env content and save with :wq\033[0m"; \
vim ops/.env.prod; \
cp ./ops/.env.prod ./src/.env; \
cp ./docker-prod.yml ./src/docker-compose.yml; \
docker pull $(DIN):$(DIV); \
docker compose -f ./src/docker-compose.yml --env-file ./src/.env up -d; \
fi
up:
docker compose -f ./src/docker-compose.yml --env-file ./src/.env up --detach
down:
docker compose -f ./src/docker-compose.yml --env-file ./src/.env down
start:
docker compose -f ./src/docker-compose.yml --env-file ./src/.env start
stop:
docker compose -f ./src/docker-compose.yml --env-file ./src/.env stop
restart:
docker compose -f ./src/docker-compose.yml --env-file ./src/.env.dev restart
destroy:
docker compose -f ./src/docker-compose.yml --env-file ./src/.env down --volumes
shell:
docker compose -f ./src/docker-compose.yml --env-file ./src/.env exec $(CN) bash
ps:
docker compose -f ./src/docker-compose.yml ps
log:
docker compose -f ./src/docker-compose.yml --env-file ./src/.env logs -f $(CN)
run:
@echo "\033[31mEnter command to run inside container: \033[0m"; \
read -r cmd; \
docker compose -f ./src/docker-compose.yml exec $(CN) bash -c "$$cmd"