-
Notifications
You must be signed in to change notification settings - Fork 0
/
dev.sh
executable file
·89 lines (78 loc) · 2.13 KB
/
dev.sh
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
#!/bin/bash
RESTORE='\033[0m'
RED='\033[00;31m'
GREEN='\033[00;32m'
YELLOW='\e[0;33m'
export PROJECT_NAME=ENV_PROJECT_NAME
export PROJECT_BASE=$(pwd)
function dkbuild {
CD=$(pwd)
cd $PROJECT_BASE
docker-compose build --force-rm --no-cache app
exitcode=$?
cd $CD
return $exitcode
}
function dkupd {
CD=$(pwd)
cd $PROJECT_BASE
docker-compose up -d
exitcode=$?
cd $CD
return $exitcode
}
function dkupa {
CD=$(pwd)
cd $PROJECT_BASE
docker-compose up
exitcode=$?
cd $CD
return $exitcode
}
function dkdown {
CD=$(pwd)
cd $PROJECT_BASE
docker-compose down
exitcode=$?
cd $CD
return $exitcode
}
function dk {
docker-compose run --rm "app" $@
}
function pkg_install {
CD=$(pwd)
cd $PROJECT_BASE
docker-compose run --rm app "yarn"
cd $CD
}
function db_setup {
docker exec -ti ${PROJECT_NAME}-db psql -U postgres -c "create database ENV_PROJECT_NAME_development"
docker exec -ti ${PROJECT_NAME}-db psql -U postgres -c "create database ENV_PROJECT_NAME_test"
}
function setup_dev_environment {
docker volume create --name development_postgres
docker network create development_network
cp .env.example .env
pkg_install
db_setup
}
function devhelp {
echo -e "${GREEN}devhelp${RESTORE} Prints ${RED}devhelp${RESTORE}"
echo -e ""
echo -e "${GREEN}db_setup${RESTORE} ${RED}Setup environment${RESTORE}"
echo -e ""
echo -e "${GREEN}dkbuild${RESTORE} ${RED}Builds project docker image${RESTORE}"
echo -e ""
echo -e "${GREEN}pkg_install${RESTORE} ${RED}Install node packages${RESTORE}"
echo -e ""
echo -e "${GREEN}dkupa${RESTORE} ${RED}Starts docker services${RESTORE} in attach mode (at first time, runs pkg_install)"
echo -e ""
echo -e "${GREEN}dkupd${RESTORE} ${RED}Starts docker services${RESTORE} in detached mode (at first time, runs pkg_install)"
echo -e ""
echo -e "${GREEN}dk \"cmd\"${RESTORE} ${RED}Runs the 'cmd' command inside the container"
echo -e ""
echo -e "${GREEN}dkdown${RESTORE} ${RED}Stop and remove docker containers${RESTORE}"
echo -e ""
}
devhelp