-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
73 lines (60 loc) · 1.78 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
STAGE ?= dev
REMOTE ?= deploy@keskonmang.knpnet.net
REMOTE_PATH=/home/deploy/api
IMAGE_TAG ?= dev
.PHONY: dev
dev: cp-env build install-deps start
.PHONY: cp-env
cp-env:
cp -n .env.dist .env
.PHONY: install-deps
install-deps:
docker-compose run --rm php composer install
.PHONY: start
start:
docker-compose -f docker/$(STAGE).yml up -d --no-build --remove-orphans
.PHONY: stop
stop:
docker-compose down
.PHONY: build
build: .ensure-stage-exists .validate-image-tag
docker-compose -f docker/$(STAGE).yml build $(SERVICES)
.PHONY: push
push: .ensure-stage-exists .validate-image-tag
docker-compose -f docker/$(STAGE).yml push
.PHONY: remote-deploy
remote-deploy: .ensure-stage-exists .validate-image-tag
ssh -t ${REMOTE} 'vim ${REMOTE_PATH}/.env'
scp docker/$(STAGE).yml ${REMOTE}:${REMOTE_PATH}/docker/$(STAGE).yml
ssh -t ${REMOTE} '\
cd ${REMOTE_PATH} && \
export IMAGE_TAG=$(IMAGE_TAG) && \
sed -i "s/^IMAGE_TAG=.*$$/IMAGE_TAG=$(IMAGE_TAG)/" .env && \
docker-compose -f docker/${STAGE}.yml pull --include-deps && \
docker-compose -f docker/$(STAGE).yml up -d --no-build --remove-orphans && \
docker-compose -f docker/$(STAGE).yml ps'
.PHONY: .ensure-stage-exists
.ensure-stage-exists:
ifeq (,$(wildcard docker/$(STAGE).yml))
@echo "Env $(STAGE) not supported."
@exit 1
endif
.PHONY: .validate-image-tag
.validate-image-tag:
ifneq ($(STAGE),dev)
ifeq ($(IMAGE_TAG),)
@echo "You can't build, push or deploy to prod without an IMAGE_TAG.\n"
@exit 1
endif
endif
.PHONY: phpspec
phpspec:
docker-compose run --rm php vendor/bin/phpspec run -fpretty -v
.PHONY: lint-compose-files
lint-compose-files:
@for file in docker/*.yml; do \
docker-compose -f $$file config >/dev/null; \
done
.PHONY: lint-yaml
lint-yaml:
docker-compose run --rm php bin/console lint:yaml config --parse-tags