-
Notifications
You must be signed in to change notification settings - Fork 224
/
sandbox.bat
164 lines (148 loc) · 4.69 KB
/
sandbox.bat
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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
@ECHO OFF
TITLE sandbox.bat - TICK Sandbox
SET interactive=1
SET COMPOSE_CONVERT_WINDOWS_PATHS=1
SET TYPE=latest
SET TELEGRAF_TAG=latest
SET INFLUXDB_TAG=latest
SET CHRONOGRAF_TAG=latest
SET KAPACITOR_TAG=latest
ECHO %cmdcmdline% | FIND /i "/c"
IF %ERRORLEVEL% == 0 SET interactive=0
REM Enter attaches users to a shell in the desired container
IF "%1"=="enter" (
IF "%2"=="" (
ECHO sandbox enter ^(influxdb^|^|chronograf^|^|kapacitor^|^|telegraf^)
GOTO End
)
IF "%2"=="influxdb" (
ECHO Entering ^/bin^/bash session in the influxdb container...
docker-compose exec influxdb /bin/bash
GOTO End
)
IF "%2"=="chronograf" (
ECHO Entering ^/bin^/bash session in the chronograf container...
docker-compose exec chronograf /bin/bash
GOTO End
)
IF "%2"=="kapacitor" (
ECHO Entering ^/bin^/bash session in the kapacitor container...
docker-compose exec kapacitor /bin/bash
GOTO End
)
IF "%2"=="telegraf" (
ECHO Entering ^/bin^/bash session in the telegraf container...
docker-compose exec telegraf /bin/bash
GOTO End
)
)
REM Logs streams the logs from the container to the shell
IF "%1"=="logs" (
IF "%2"=="" (
ECHO sandbox logs ^(influxdb^|^|chronograf^|^|kapacitor^|^|telegraf^)
GOTO End
)
IF "%2"=="influxdb" (
ECHO Following the logs from the influxdb container...
docker-compose logs -f influxdb
GOTO End
)
IF "%2"=="chronograf" (
ECHO Following the logs from the chronograf container...
docker-compose logs -f chronograf
GOTO End
)
IF "%2"=="kapacitor" (
ECHO Following the logs from the kapacitor container...
docker-compose logs -f kapacitor
GOTO End
)
IF "%2"=="telegraf" (
ECHO Following the logs from the telegraf container...
docker-compose logs -f telegraf
GOTO End
)
)
IF "%1"=="up" (
IF "%2"=="-nightly" (
ECHO Spinning up nightly Docker Images...
ECHO If this is your first time starting sandbox this might take a minute...
SET TYPE=nightly
SET INFLUXDB_TAG=nightly
SET CHRONOGRAF_TAG=nightly
docker-compose up -d --build
ECHO Opening tabs in browser...
timeout /t 3 /nobreak > NUL
START "" http://localhost:3010
START "" http://localhost:8888
GOTO End
) ELSE (
ECHO Spinning up latest, stable Docker Images...
ECHO If this is your first time starting sandbox this might take a minute...
docker-compose up -d --build
ECHO Opening tabs in browser...
timeout /t 3 /nobreak > NUL
START "" http://localhost:3010
START "" http://localhost:8888
GOTO End
)
)
IF "%1"=="down" (
ECHO Stopping and removing running sandbox containers...
docker-compose down
GOTO End
)
IF "%1"=="restart" (
ECHO Stopping all sandbox processes...
docker-compose down >NUL 2>NUL
ECHO Starting all sandbox processes...
docker-compose up -d --build >NUL 2>NUL
ECHO Services available!
GOTO End
)
IF "%1"=="delete-data" (
ECHO Deleting all influxdb, kapacitor and chronograf data...
rmdir /S /Q kapacitor\data influxdb\data chronograf\data
GOTO End
)
IF "%1"=="docker-clean" (
ECHO Stopping all running sandbox containers...
docker-compose down
echo Removing TICK images...
docker-compose down --rmi=all
GOTO End
)
IF "%1"=="influxdb" (
ECHO Entering the influx cli...
docker-compose exec influxdb /usr/bin/influx
GOTO End
)
IF "%1"=="flux" (
ECHO Entering the flux cli...
docker-compose exec influxdb /usr/bin/influx -type flux
GOTO End
)
IF "%1"=="rebuild-docs" (
echo Rebuilding documentation container...
docker build -t sandbox_documentation documentation\ >NUL 2>NUL
echo "Restarting..."
docker-compose down >NUL 2>NUL
docker-compose up -d --build >NUL 2>NUL
GOTO End
)
ECHO sandbox commands:
ECHO up -^> spin up the sandbox environment
ECHO down -^> tear down the sandbox environment
ECHO restart -^> restart the sandbox
ECHO influxdb -^> attach to the influx cli
ECHO flux -^> attach to the flux REPL
ECHO.
ECHO enter ^(influxdb^|^|kapacitor^|^|chronograf^|^|telegraf^) -^> enter the specified container
ECHO logs ^(influxdb^|^|kapacitor^|^|chronograf^|^|telegraf^) -^> stream logs for the specified container
ECHO.
ECHO delete-data -^> delete all data created by the TICK Stack
ECHO docker-clean -^> stop and remove all running docker containers and images
ECHO rebuild-docs -^> rebuild the documentation image
:End
IF "%interactive%"=="0" PAUSE
EXIT /B 0