-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
113 lines (74 loc) · 3.59 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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
init: docker-down-clear init-ci client-ready
init-ci: api-clear client-clear \
docker-pull docker-build docker-up \
api-init client-init
up: docker-up
down: docker-down
restart: down up
clear: client-clear api-clear
rebuild: docker-down init-ci client-ready
update-deps: api-composer-update client-yarn-upgrade restart
docker-up:
docker compose up -d
docker-down:
docker compose down --remove-orphans
docker-down-clear:
docker compose down -v --remove-orphans
docker-pull:
docker compose pull
docker-build:
docker compose build --pull
api-clear:
docker run --rm -v ${PWD}/api:/app -w /app alpine sh -c 'rm -rf storage/framework/cache/data/* storage/framework/sessions/* storage/framework/testing/* storage/framework/views/* storage/logs/*'
api-init: api-permissions api-composer-install api-wait-db api-migrations
api-permissions:
docker run --rm -v ${PWD}/api:/app -w /app alpine chmod 777 -R storage bootstrap/cache
api-composer-install:
docker compose run --rm api-php-cli composer install
api-composer-update:
docker compose run --rm api-php-cli composer update
api-wait-db:
docker compose run --rm api-php-cli wait-for-it api-db:3306 -t 30
api-migrations:
docker compose run --rm api-php-cli php artisan migrate --force
api-optimize:
docker compose run --rm api-php-cli php artisan optimize:clear
client-clear:
docker run --rm -v ${PWD}/client:/app -w /app alpine sh -c 'rm -rf .ready build'
client-init: client-yarn-install
client-yarn-install:
docker compose run --rm client-node-cli yarn install
client-yarn-upgrade:
docker compose run --rm client-node-cli yarn upgrade
client-ready:
docker run --rm -v ${PWD}/client:/app -w /app alpine touch .ready
build: build-gateway build-client build-api
build-gateway:
docker --log-level=debug build --pull --file=gateway/docker/prod/nginx/Dockerfile --tag=${REGISTRY}/lk-gateway:${IMAGE_TAG} gateway/docker
build-client:
docker --log-level=debug build --pull --file=client/docker/prod/nginx/Dockerfile --tag=${REGISTRY}/lk-client:${IMAGE_TAG} client
build-api:
docker --log-level=debug build --pull --file=api/docker/prod/nginx/Dockerfile --tag=${REGISTRY}/lk-api:${IMAGE_TAG} api
docker --log-level=debug build --pull --file=api/docker/prod/php-fpm/Dockerfile --tag=${REGISTRY}/lk-api-php-fpm:${IMAGE_TAG} api
docker --log-level=debug build --pull --file=api/docker/prod/php-cli/Dockerfile --tag=${REGISTRY}/lk-api-php-cli:${IMAGE_TAG} api
docker --log-level=debug build --pull --file=centrifugo/Dockerfile --tag=${REGISTRY}/lk-centrifugo:${IMAGE_TAG} centrifugo
try-build:
REGISTRY=localhost IMAGE_TAG=0 make build
push: push-gateway push-client push-api
push-gateway:
docker push ${REGISTRY}/lk-gateway:${IMAGE_TAG}
push-client:
docker push ${REGISTRY}/lk-client:${IMAGE_TAG}
push-api:
docker push ${REGISTRY}/lk-api:${IMAGE_TAG}
docker push ${REGISTRY}/lk-api-php-fpm:${IMAGE_TAG}
docker push ${REGISTRY}/lk-api-php-cli:${IMAGE_TAG}
docker push ${REGISTRY}/lk-centrifugo:${IMAGE_TAG}
deploy:
ssh -o StrictHostKeyChecking=no [email protected] 'rm -rf lk_${BUILD_NUMBER} && mkdir lk_${BUILD_NUMBER}'
envsubst < docker-compose-prod.yml > docker-compose-prod-env.yml
scp -o StrictHostKeyChecking=no docker-compose-prod-env.yml [email protected]:lk_${BUILD_NUMBER}/docker-compose.yml
rm -f docker-compose-prod-env.yml
ssh -o StrictHostKeyChecking=no [email protected] 'cd lk_${BUILD_NUMBER} && docker stack deploy --compose-file docker-compose.yml lk --with-registry-auth --prune'
rollback:
ssh -o StrictHostKeyChecking=no [email protected] 'cd lk_${BUILD_NUMBER} && docker stack deploy --compose-file docker-compose.yml lk --with-registry-auth --prune'