-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
55 lines (43 loc) · 1.33 KB
/
Makefile
File metadata and controls
55 lines (43 loc) · 1.33 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
.DEFAULT_GOAL := help
.ONESHELL:
export SHELL := $(shell which sh)
# colors
GREEN := $(shell tput -Txterm setaf 2)
YELLOW := $(shell tput -Txterm setaf 3)
WHITE := $(shell tput -Txterm setaf 7)
CYAN := $(shell tput -Txterm setaf 6)
RESET := $(shell tput -Txterm sgr0)
# targets
.PHONY: all
all: build pull run up stop down psql help
build: ## build postgres image
docker build -f Dockerfile.postgres -t some-postgres:latest .
build-py: ## build python image
docker build -f Dockerfile -t some-python:latest .
pull: ## pull postgres image
docker pull postgres:latest
run: ## run postgres container
docker run --rm --name some-postgres \
-p 5432:5432 \
-e POSTGRES_PASSWORD=mysecretpassword \
-d postgres:latest
up: ## docker-compose
docker-compose up -d
exec: ## docker-compose
docker-compose exec -it some-python bash
stop: ## docker-compose
docker-compose stop
down: ## docker-compose
docker-compose down
psql: ## run psql
docker exec -it some-postgres psql -U postgres
help: ## show this help
@echo ''
@echo 'Usage:'
@echo ' ${YELLOW}make${RESET} ${GREEN}<target>${RESET}'
@echo ''
@echo 'Targets:'
@awk 'BEGIN {FS = ":.*?## "} { \
if (/^[a-zA-Z_-]+:.*?##.*$$/) {printf " ${YELLOW}%-20s${GREEN}%s${RESET}\n", $$1, $$2} \
else if (/^## .*$$/) {printf " ${CYAN}%s${RESET}\n", substr($$1,4)} \
}' $(MAKEFILE_LIST)