-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile
38 lines (27 loc) · 1.22 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
# Database variables
container = postgres
user = user
password = 123123123
database = java_api_template
# Application Commands
install:
mvn clean install
test:
mvn test
run: start_db
mvn spring-boot:run -pl webapp
# Database Commands
start_db:
@if [ "$(container)" = "postgres" ]; then echo "Using default container name: postgres."; fi
docker start $(container)
stop_db:
@if [ "$(container)" = "postgres" ]; then echo "Using default container name: postgres."; fi
docker stop $(container)
create_db:
@if [ "$(container)" = "postgres" ]; then echo "Using default container name: 'postgres'."; fi
@if [ "$(user)" = "user" ]; then echo "Using default user name: 'user'."; fi
@if [ "$(password)" = "123123123" ]; then echo "Using default container name: '123123123'."; fi
@if [ "$(database)" = "java_api_template" ]; then echo "Using default container name: 'java_api_template'."; fi
docker run --name $(container) -e POSTGRES_PASSWORD=$(password) -e POSTGRES_USER=$(user) -p 5432:5432 -d postgres
sleep 5 # Wait for the PostgreSQL container to start (you can adjust this as needed)
docker exec -it $(container) psql -U $(user) -c 'CREATE DATABASE "$(database)" WITH ENCODING "UTF-8";'