-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
45 lines (35 loc) · 1.17 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
include .env
stop_containers:
@echo "Stopping other docker container"
if [ $$(docker ps -q) ]; then \
echo "found and stopped containers"; \
docker stop $$(docker ps -q); \
else \
echo "no containers running..."; \
fi
create_container:
docker run --name ${DB_DOCKER_CONTAINER} -p 5432:5432 -e POSTGRES_USER=${USER} -e POSTGRES_PASSWORD=${PASSWORD} -d postgres:12-alpine
create_db:
docker exec -it ${DB_DOCKER_CONTAINER} createdb --username=${USER} --owner=${USER} ${DB_NAME}
start_container:
docker start ${DB_DOCKER_CONTAINER}
create_migrations:
sqlx migrate add -r init
migrate_up:
sqlx migrate run --database-url "postgres://${USER}:${PASSWORD}@${HOST}:${DB_PORT}/${DB_NAME}?sslmode=disable"
migrate_down:
sqlx migrate revert --database-url "postgres://${USER}:${PASSWORD}@${HOST}:${DB_PORT}/${DB_NAME}?sslmode=disable"
build:
if [ -f "${BINARY}" ]; then \
rm ${BINARY}; \
echo "Deleted ${BINARY}"; \
fi
@echo "Building binary..."
go build -o ${BINARY} cmd/server/*.go
run: build
./${BINARY}
# @echo "api started..."
stop:
@echo "stopping server.."
@-pkill -SIGTERM -f "./${BINARY}"
@echo "server stopped..."