-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
79 lines (52 loc) · 1.43 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
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
CONTAINER = nginx
ENVIRONMENT = common
.PHONY: build
.PHONY: clean
.PHONY: init
.PHONY: log
.PHONY: run
.PHONY: shell
.PHONY: status
all: clean init build run
build:
@. envs/$(ENVIRONMENT); \
docker-compose build $(CONTAINER)
clean:
@. envs/$(ENVIRONMENT); \
docker-compose down --remove-orphans; \
docker-compose rm -fsv $(CONTAINER); \
rm -rf docker/etc/letsencrypt/csr/*.pem
init:
@. envs/$(ENVIRONMENT); \
./init.sh; \
mkdir -p $${HOME}/.aws; \
[ -f $${HOME}/.aws/config ] || echo "[default]\nregion = $${AWS_REGION}" > $${HOME}/.aws/config; \
[ -f $${HOME}/.aws/credentials ] || echo "[default]\naws_access_key_id = $${AWS_ACCESS_KEY_ID}\naws_secret_access_key = $${AWS_SECRET_ACCESS_KEY}" > $${HOME}/.aws/credentials; \
chmod 0600 $${HOME}/.aws/*
log:
@. envs/$(ENVIRONMENT); \
docker-compose logs $(CONTAINER)
run: build
@. envs/$(ENVIRONMENT); \
docker-compose up -d $(CONTAINER)
shell:
@. envs/$(ENVIRONMENT); \
docker-compose exec $(CONTAINER) bash
status:
@. envs/$(ENVIRONMENT); \
docker-compose ps --all
prereqs:
command -v docker >>/dev/null
docker info >>/dev/null
command -v docker-compose >>/dev/null
command -v dig >>/dev/null
command -v aws >>/dev/null
aws ec2 describe-instances
## EC2 targets
ec2: init ec2_bootstrap ec2_provision
ec2_bootstrap:
@. envs/$(ENVIRONMENT); \
ansible-playbook -vvv bootstrap.yml
ec2_provision:
@. envs/$(ENVIRONMENT); \
ansible-playbook -vvv provision.yml