-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathMakefile
More file actions
34 lines (30 loc) · 933 Bytes
/
Makefile
File metadata and controls
34 lines (30 loc) · 933 Bytes
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
.PHONY: up gen-secret
# Default target
all: help
help:
@echo "Usage:"
@echo " make up Start the services with a random password"
@echo " make gen-secret Generate a random password and save it to .env"
# Generate .env file with random password
gen-secret:
@echo "Generating secret..."
@touch .env
@if ! grep -q "^POSTGRES_PASSWORD=" .env; then \
echo "POSTGRES_PASSWORD=$$(openssl rand -base64 16)" >> .env; \
fi
@if ! grep -q "^POSTGRES_USER=" .env; then \
echo "POSTGRES_USER=pguser" >> .env; \
fi
@if ! grep -q "^POSTGRES_DB=" .env; then \
echo "POSTGRES_DB=tasks_db" >> .env; \
fi
@if ! grep -q "^POSTGRES_HOST=" .env; then \
echo "POSTGRES_HOST=postgres" >> .env; \
fi
@if ! grep -q "^POSTGRES_PORT=" .env; then \
echo "POSTGRES_PORT=5432" >> .env; \
fi
# Generate secret and start the services
up: gen-secret
@echo "Starting services..."
docker compose --env-file .env up --build