-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMakefile
More file actions
151 lines (135 loc) · 4.57 KB
/
Makefile
File metadata and controls
151 lines (135 loc) · 4.57 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
# Database Management Makefile
# Usage: make [target]
#
# Copyright (c) 2025 Finbarrs Oketunji
# Written by Finbarrs Oketunji <f@finbarrs.eu>
#
# This file is part of data-analysts-training.
#
# data-analysts-training is an open-source software: you are free to redistribute
# and/or modify it under the terms of the Modified MIT License.
#
# data-analysts-training is made available with the hope that it will be beneficial,
# but it comes with NO WARRANTY whatsoever. This includes, but is not limited
# to, any implied warranties of MERCHANTABILITY or FITNESS FOR A PARTICULAR
# PURPOSE. For more detailed information, please refer to the
# LICENSE file.
#
# You should have received a copy of the Modified MIT License
# along with data-analysts-training. If not, email Finbarrs Oketunji <f@finbarrs.eu>
# Docker Setup and Database Targets
.PHONY: docker-setup docker-remove db2-build db2-run db2-clean mssql-build mssql-run mssql-clean oracle-build oracle-run oracle-clean mysql-setup postgres-setup help
# Docker Management Commands
docker-setup:
@echo "Setting up Docker on macOS..."
@chmod +x ./docker.sh
@./docker.sh install
docker-remove:
@echo "Removing Docker from macOS..."
@chmod +x ./docker.sh
@./docker.sh remove
# IBM DB2 Commands
db2-build:
@echo "Building IBM DB2 Docker image..."
docker build --platform linux/amd64 -t my-db2-db ./data/docker/ibm_db2
db2-run:
@echo "Creating DB2 volume and running container..."
docker volume create db2data
docker run -d \
--privileged \
--platform linux/amd64 \
-p 50000:50000 -p 55000:55000 \
--name db2-database \
-v db2data:/database \
-e LICENSE=accept \
-e DB2INSTANCE=db2inst1 \
-e DB2INST1_PASSWORD=AGIWHATNOT28 \
-e DBNAME=TESTDB \
-e BLU=false \
-e ENABLE_ORACLE_COMPATIBILITY=false \
-e UPDATEAVAIL=NO \
-e TO_CREATE_SAMPLEDB=false \
-e HADR_ENABLED=false \
-e ETCD_ENDPOINT= \
-e ETCD_USERNAME= \
-e ETCD_PASSWORD= \
my-db2-db
db2-clean:
@echo "Stopping and removing DB2 container and volume..."
-docker stop db2-database
-docker rm db2-database
-docker volume rm db2data
# MSSQL Commands
mssql-build:
@echo "Building MSSQL Docker image..."
docker build --platform linux/amd64 -t mssql-rocky ./data/docker/mssql --no-cache
mssql-run:
@echo "Running MSSQL container..."
docker run --platform linux/amd64 -d -p 1433:1433 --name mssql-server \
-e SA_PASSWORD='MyComplexPass123!@#' \
mssql-rocky
mssql-clean:
@echo "Stopping and removing MSSQL container..."
-docker stop mssql-server
-docker rm mssql-server
# Oracle Commands
oracle-build:
@echo "Building Oracle Docker image..."
docker build -t my-oracle-db ./data/docker/oracle
oracle-run:
@echo "Running Oracle container..."
docker run -d -p 1521:1521 --name oracle-db my-oracle-db
oracle-clean:
@echo "Stopping and removing Oracle container..."
-docker stop oracle-db
-docker rm oracle-db
# macOS Database Setup Commands
mysql-setup:
@echo "Setting up MySQL on macOS..."
@if [ "$$(uname)" != "Darwin" ]; then \
echo "This command is only supported on macOS"; \
exit 1; \
fi
brew install mysql
brew services start mysql
@echo "MySQL installed and started. Run 'mysql -u root' to connect"
postgres-setup:
@echo "Setting up PostgreSQL on macOS..."
@if [ "$$(uname)" != "Darwin" ]; then \
echo "This command is only supported on macOS"; \
exit 1; \
fi
brew install postgresql@15
brew services start postgresql@15
initdb /opt/homebrew/var/postgres
@echo "PostgreSQL installed and started. Run 'psql postgres' to connect"
# Utility Commands
clean-all:
@echo "Cleaning all database containers..."
make db2-clean
make mssql-clean
make oracle-clean
help:
@echo "Database Management Makefile"
@echo ""
@echo "Docker Management:"
@echo " docker-setup - Install and setup Docker on macOS"
@echo " docker-remove - Remove Docker from macOS"
@echo ""
@echo "Docker Database Targets:"
@echo " db2-build - Build IBM DB2 Docker image"
@echo " db2-run - Run IBM DB2 container"
@echo " db2-clean - Stop and remove DB2 container"
@echo " mssql-build - Build MSSQL Docker image"
@echo " mssql-run - Run MSSQL container"
@echo " mssql-clean - Stop and remove MSSQL container"
@echo " oracle-build - Build Oracle Docker image"
@echo " oracle-run - Run Oracle container"
@echo " oracle-clean - Stop and remove Oracle container"
@echo " clean-all - Clean all database containers"
@echo ""
@echo "macOS Setup Targets:"
@echo " mysql-setup - Install and setup MySQL on macOS"
@echo " postgres-setup - Install and setup PostgreSQL on macOS"
@echo ""
@echo "Usage: make [target]"