-
Notifications
You must be signed in to change notification settings - Fork 9
/
dev-sync
executable file
·38 lines (32 loc) · 1.04 KB
/
dev-sync
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
#!/bin/bash
### Continously watch a local directory for changes, and rsync immediately to a docker volume.
## dev-sync VOLUME SRC DEST
set -e
BIN=$(dirname ${BASH_SOURCE})
source ${BIN}/funcs.sh
${BIN}/check_deps inotifywait
if [[ $# -lt 2 ]]; then
fault "Invalid arguments. The correct arguments are: VOLUME SRC_DIR [DEST_DIR]"
fi
VOLUME="${1}"
SRC_DIR="${2}"
if [[ $# == 3 ]]; then
DEST_DIR="${3}"
else
DEST_DIR="/"
fi
DO_FIRST_TIME_CHECKS=true
${BIN}/volume_mkdir "${VOLUME}"
set +e
while [[ true ]] ; do
if [[ "${DO_CHECKS_FIRST_TIME}" == true ]]; then
DO_FIRST_TIME_CHECKS=false
else
# Only do volume_rsync checks the first time:
export DISABLE_VOLUME_RSYNC_CHECKS=true
fi
${BIN}/volume_rsync "${VOLUME}" -av --delete --exclude={'.git','.*','passwords.json','target','node_modules','build','dist','docker-compose.*','Dockerfile*'} "${SRC_DIR}/" "volume:/data/${DEST_DIR}"
echo ""
echo "Waiting for changes ..."
inotifywait -r -t 600 -e modify,delete,create,move --exclude '\.#.*' .
done