forked from CarnegieLearningWeb/UpGrade
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
79 lines (61 loc) · 2.28 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
# Variables
backendDockerfile := ./backend/dev.Dockerfile
backendImage := upgrade-backend:latest
backendContainer := upgrade-backend-1
frontendDockerfile := ./frontend/dev.Dockerfile
frontendImage := upgrade-frontend:latest
frontendContainer := upgrade-frontend-1
postgresContainer := upgrade-postgres-1
postgresOutputPath := __ABSOLUTE_PATH_TO_BACKUP_AND_RESTORE_FILES__
postgresBackupFile := local-upgrade-dev-postgres.`date +%Y%m%d`.sql
postgresRestoreFile := staging-cli-upgrade-dev-postgres.20220131.sql
# Commands
default:
@echo "---- Launching Environment ----"
docker-compose up -d
images:
@echo "---- Building Docker Images ----"
docker build -f $(backendDockerfile) -t $(backendImage) .
docker build -f $(frontendDockerfile) -t $(frontendImage) .
image-backend:
@echo "---- Building Backend Docker Image ----"
docker build -f $(backendDockerfile) -t $(backendImage) .
image-frontend:
@echo "---- Building Frontend Docker Image ----"
docker build -f $(frontendDockerfile) -t $(frontendImage) .
log-backend:
@echo "---- Backend Logs ----"
docker logs -f -t --details $(backendContainer)
log-frontend:
@echo "---- Frontend Logs ----"
docker logs -f -t --details $(frontendContainer)
log-db:
@echo "---- Database Logs ----"
docker logs -f -t --details $(postgresContainer)
bash-backend-container:
@echo "---- Entering Backend Container ----"
docker exec -it $(backendContainer) /bin/sh
bash-frontend-container:
@echo "---- Entering Frontend Container ----"
docker exec -it $(frontendContainer) /bin/sh
bash-db-container:
@echo "---- Entering Database Container ----"
docker exec -it $(postgresContainer) /bin/sh
down:
@echo "---- Taking Environment Down ----"
docker-compose down
clean: down
@echo "---- Cleaning Docker System Information ----"
docker system prune -f
destroy: clean
@echo "---- Removing Persistent Volume Information ----"
docker volume prune -f
setup-local:
@echo "---- Setup for the Local Environment ----"
./docker-setup.sh -l
db-dump:
@echo "---- Backing Up Database ----"
docker exec -t $(postgresContainer) pg_dumpall -c -U postgres > $(addsuffix $(postgresBackupFile),$(postgresOutputPath))
db-restore:
@echo "---- Restoring Database ----"
cat $(addsuffix $(postgresRestoreFile),$(postgresOutputPath)) | docker exec -i $(postgresContainer) psql -U postgres