Skip to content

Commit 97d198e

Browse files
committed
sync functions only
1 parent 722e73a commit 97d198e

1 file changed

Lines changed: 38 additions & 69 deletions

File tree

sync.sh

Lines changed: 38 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@
77
# chmod 755 sync.sh
88

99
# Usage:
10-
# Install docker-sync: ./laradock.sh sync install
11-
# Start sync and services with nginx and mysql: ./laradock.sh sync up nginx mysql
12-
# Stop containers and sync: ./laradock.sh sync down
13-
# Open bash inside the workspace: ./laradock.sh bash
14-
# Force sync: ./laradock.sh sync trigger
15-
# Clean synced files: ./laradock.sh sync clean
10+
# Install docker-sync: ./sync.sh install
11+
# Start sync and services with nginx and mysql: ./sync.sh up nginx mysql
12+
# Stop containers and sync: ./sync.sh down
13+
# Open bash inside the workspace: ./sync.sh bash
14+
# Force sync: ./sync.sh sync trigger
15+
# Clean synced files: ./sync.sh clean
1616

1717
# prints colored text
1818
print_style () {
@@ -37,16 +37,12 @@ print_style () {
3737

3838
display_options () {
3939
printf "Available options:\n";
40-
print_style " up [services]" "success"; printf "\t Starts workspace and services.\n";
41-
print_style " down" "success"; printf "\t\t\t Stops services.\n";
40+
print_style " install" "info"; printf "\t\t Installs docker-sync gem on the host machine.\n";
41+
print_style " up [services]" "success"; printf "\t Starts docker-sync and runs docker compose.\n";
42+
print_style " down" "success"; printf "\t\t\t Stops containers and docker-sync.\n";
4243
print_style " bash" "success"; printf "\t\t\t Opens bash on the workspace.\n";
43-
print_style " build" "success"; printf "\t\t\t Builds images.\n";
44-
45-
print_style " sync install" "info"; printf "\t\t Installs docker-sync gem on the host machine.\n";
46-
print_style " sync up [services]" "success"; printf "\t Starts docker-sync and runs docker compose.\n";
47-
print_style " sync down" "success"; printf "\t\t\t Stops containers and docker-sync.\n";
48-
print_style " sync trigger" "success"; printf "\t\t Manually triggers the synchronization of files.\n";
49-
print_style " sync clean" "warning"; printf "\t\t Removes all files from docker-sync.\n";
44+
print_style " trigger" "success"; printf "\t\t Manually triggers the synchronization of files.\n";
45+
print_style " clean" "warning"; printf "\t\t Removes all files from docker-sync.\n";
5046
}
5147

5248
if [[ $# -eq 0 ]] ; then
@@ -55,65 +51,38 @@ if [[ $# -eq 0 ]] ; then
5551
exit 1
5652
fi
5753

58-
if [ "$1" == "sync" ] ; then
54+
if [ "$1" == "up" ] ; then
55+
print_style "Initializing Docker Sync\n" "info";
56+
print_style "May take a long time (15min+) the first run\n" "info";
57+
docker-sync start;
58+
59+
print_style "Initializing Docker Compose\n" "info";
5960
shift; # removing first argument
60-
print_style "Using docker-sync to speed up Docker on OSX and Windows.\n" "success";
61-
62-
if [ "$1" == "up" ] ; then
63-
print_style "Initializing Docker Sync\n" "info";
64-
print_style "May take a long time (15min+) the first run\n" "info";
65-
docker-sync start;
66-
67-
print_style "Initializing Docker Compose\n" "info";
68-
shift; # removing first argument
69-
docker-compose -f docker-compose.yml -f docker-compose.sync.yml up -d ${@};
70-
71-
elif [ "$1" == "down" ]; then
72-
print_style "Stopping Docker Compose\n" "info";
73-
docker-compose down;
74-
75-
print_style "Stopping Docker Sync\n" "info";
76-
docker-sync stop;
77-
78-
elif [ "$1" == "install" ]; then
79-
print_style "Installing docker-sync\n" "info";
80-
gem install docker-sync;
81-
82-
elif [ "$1" == "trigger" ]; then
83-
print_style "Manually triggering sync between host and docker-sync container.\n" "info";
84-
docker-sync sync;
85-
86-
elif [ "$1" == "clean" ]; then
87-
print_style "Removing and cleaning up files from the docker-sync container.\n" "warning";
88-
docker-sync clean;
89-
else
90-
print_style "Invalid arguments.\n" "danger";
91-
display_options;
92-
exit 1
93-
fi
94-
else
95-
print_style "Not using docker-sync might might be slow on OSX and Windows. Use 'sync' option to speed up.\n";
61+
docker-compose -f docker-compose.yml -f docker-compose.sync.yml up -d ${@};
9662

97-
if [ "$1" == "up" ] ; then
98-
print_style "Initializing Docker Compose\n" "info";
99-
shift; # removing first argument
100-
docker-compose up -d ${@};
63+
elif [ "$1" == "down" ]; then
64+
print_style "Stopping Docker Compose\n" "info";
65+
docker-compose down;
10166

102-
elif [ "$1" == "down" ]; then
103-
print_style "Stopping Docker Compose\n" "info";
104-
docker-compose down;
67+
print_style "Stopping Docker Sync\n" "info";
68+
docker-sync stop;
10569

106-
elif [ "$1" == "build" ]; then
107-
print_style "Building workspace\n" "info";
108-
docker-compose build workspace;
70+
elif [ "$1" == "bash" ]; then
71+
docker-compose exec workspace bash;
10972

110-
elif [ "$1" == "bash" ]; then
111-
docker-compose exec workspace bash;
73+
elif [ "$1" == "install" ]; then
74+
print_style "Installing docker-sync\n" "info";
75+
gem install docker-sync;
11276

113-
else
114-
print_style "Invalid arguments.\n" "danger";
115-
display_options;
116-
exit 1
117-
fi
77+
elif [ "$1" == "trigger" ]; then
78+
print_style "Manually triggering sync between host and docker-sync container.\n" "info";
79+
docker-sync sync;
11880

81+
elif [ "$1" == "clean" ]; then
82+
print_style "Removing and cleaning up files from the docker-sync container.\n" "warning";
83+
docker-sync clean;
84+
else
85+
print_style "Invalid arguments.\n" "danger";
86+
display_options;
87+
exit 1
11988
fi

0 commit comments

Comments
 (0)