-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
96 lines (85 loc) · 3.2 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
-include .env
THIS_FILE := $(lastword $(MAKEFILE_LIST))
app := $(COMPOSE_PROJECT_NAME)-php
nginx := $(COMPOSE_PROJECT_NAME)-nginx
mysql := $(COMPOSE_PROJECT_NAME)-mysql
app-npm := npm
path := /var/www/app
#docker
build:
docker-compose -f docker-compose.yml up --build -d $(c)
rebuild:
docker-compose up -d --force-recreate --no-deps --build $(r)
rebuild-app:
docker-compose up -d --force-recreate --no-deps --build $(app)
up:
docker-compose -f docker-compose.yml up -d $(c)
stop:
docker-compose -f docker-compose.yml stop $(c)
it:
docker exec -it $(to) /bin/bash
it-app:
docker exec -it $(app) /bin/bash
it-nginx:
docker exec -it $(nginx) /bin/bash
it-mysql:
docker exec -it $(mysql) /bin/bash
up-prod:
docker-compose -f docker-compose.prod.yml down
docker-compose -f docker-compose.prod.yml up -d $(c)
#laravel
# TODO install
laravel-install:
docker exec $(app) composer create-project laravel/laravel laravel
mv .env .env-docker
@if [ -f 'README.md' ] ; then mv README.md README-DOCKER.md ; fi
@if [ -d 'public' ] ; then rm -r public ; fi
@if [ -d '.git' ] ; then rm -r .git ; fi
@if [ -f '.env.example' ] ; then rm .env.example ; fi
@if [ -f '.gitignore' ] ; then mv .gitignore .gitignore-docker ; fi
mv laravel/* .
mv laravel/.editorconfig .
mv laravel/.env .
mv laravel/.env.example .
mv laravel/.gitattributes .
mv laravel/.gitignore .
rm -r laravel
migrate:
docker exec $(app) php $(path)/artisan migrate
migrate-rollback:
docker exec $(app) php $(path)/artisan migrate:rollback
migrate-fresh:
docker exec $(app) php $(path)/artisan migrate:fresh --seed
migration:
docker exec $(app) php $(path)/artisan make:migration $(m)
#composer
composer-install:
docker exec $(app) composer install
composer-update:
docker exec $(app) composer update
composer-du:
docker exec $(app) composer du
#npm
npm-install:
docker-compose run --rm --service-ports $(app-npm) install $(c)
npm-update:
docker-compose run --rm --service-ports $(app-npm) update $(c)
npm-build:
docker-compose run --rm --service-ports $(app-npm) run build $(c)
npm-host:
docker-compose run --rm --service-ports $(app-npm) run dev --host $(c)
# сбор контейнеров на локальном окружении
docker-build:
eval `ssh-agent -s` && ssh-add
mkdir deploy
cd deploy && git clone $(GIT_REPOSITORY) .
docker build -t $(DOCKER_HUB_USER)/$(COMPOSE_PROJECT_NAME)-php:$(tag) --target=prod --build-arg user=$(DOCKER_USER) --build-arg uid=1000 -f docker/dockerfiles/php/Dockerfile .
docker build -t $(DOCKER_HUB_USER)/$(COMPOSE_PROJECT_NAME)-scheduler:$(tag) --target=scheduler --build-arg user=$(DOCKER_USER) --build-arg uid=1000 -f docker/dockerfiles/php/Dockerfile .
docker build -t $(DOCKER_HUB_USER)/$(COMPOSE_PROJECT_NAME)-nginx:$(tag) --target=prod -f docker/dockerfiles/nginx/Dockerfile .
docker build -t $(DOCKER_HUB_USER)/$(COMPOSE_PROJECT_NAME)-mysql:$(tag) --build-arg password=$(DB_PASSWORD) -f docker/dockerfiles/mysql/Dockerfile .
# #push
docker push $(DOCKER_HUB_USER)/$(COMPOSE_PROJECT_NAME)-php:$(tag)
docker push $(DOCKER_HUB_USER)/$(COMPOSE_PROJECT_NAME)-scheduler:$(tag)
docker push $(DOCKER_HUB_USER)/$(COMPOSE_PROJECT_NAME)-nginx:$(tag)
docker push $(DOCKER_HUB_USER)/$(COMPOSE_PROJECT_NAME)-db:$(tag)
sudo rm -r deploy