-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
77 lines (66 loc) · 1.89 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
#!/bin/bash
APP = aktak
VERSION := $(shell cat ./VERSION)
DOCKER_REPO_NGINX = ikerib/${APP}_nginx:${VERSION}
DOCKER_REPO_APP = ikerib/${APP}_app_prod:${VERSION}
USER_ID = $(shell id -u)
GROUP_ID= $(shell id -g)
user==www-data
help:
@echo 'usage: make [target]'
@echo
@echo 'targets'
@egrep '^(.+)\:\ ##\ (.+)' ${MAKEFILE_LIST} | column -t -c 2 -s ":#"
build:
@echo 'Create temp folder'
@echo '------------------'
rm -fr docker_temp
mkdir -p docker_temp/app
rm -fr ~/docker_temp/
mkdir -p ~/docker_temp/app
@echo
@echo
@echo 'Copy all to temp folder'
@echo '-----------------------'
cp -r . ~/docker_temp/app
@echo
@echo
@echo 'Remove all unnecesary files and folders'
@echo '---------------------------------------'
rm -fr ~/docker_temp/app/.git/
rm -fr ~/docker_temp/app/.idea/
rm -fr ~/docker_temp/app/fitxategiak/
rm -fr ~/docker_temp/app/node_modules/
rm -fr ~/docker_temp/app/vendor/
rm -fr ~/docker_temp/app/tmp/
@echo
@echo
@echo 'Copy prod folders to temp folder with project to create a docker image'
@echo '----------------------------------------------------------------------'
cp -r ~/docker_temp/app ./docker_temp/
#mv ./docker_temp/docker_temp ./docker_temp/app
docker build -t ${DOCKER_REPO_APP} --file=docker/prod/php/Dockerfile .
rm -fr ./docker_temp/
@echo
@echo
@echo '-------------------'
@echo 'Process finished OK'
@echo '-------------------'
deploy: build
# Dockerfile available args
# ARG user=www-data
# ARG USER_ID=1000
# ARG GROUP_ID=1000
# ARG DOCKER_TIMEZONE=Europe/Madrid
# docker build -t ${DOCKER_REPO_APP} --file=docker/prod/php/Dockerfile .
docker build -t ${DOCKER_REPO_NGINX} --file=docker/prod/nginx/Dockerfile .
docker push ${DOCKER_REPO_NGINX}
docker push ${DOCKER_REPO_APP}
restart:
$(MAKE) stop && $(MAKE) run
run:
USER_ID=${USER_ID} docker-compose up -d
ssh:
docker-compose exec app zsh
stop:
USER_ID=${USER_ID} docker-compose down