forked from BallAerospace/COSMOS
-
Notifications
You must be signed in to change notification settings - Fork 0
/
cosmos-control.bat
152 lines (137 loc) · 4.08 KB
/
cosmos-control.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
@echo off
setlocal ENABLEDELAYEDEXPANSION
if "%1" == "" (
GOTO usage
)
if "%1" == "cosmos" (
FOR /F "tokens=*" %%i in (%~dp0.env) do SET %%i
set params=%*
call set params=%%params:*%1=%%
REM Start (and remove when done --rm) the cosmos-base container with the current working directory
REM mapped as volume (-v) /cosmos/local and container working directory (-w) also set to /cosmos/local.
REM This allows tools running in the container to have a consistent path to the current working directory.
REM Run the command "ruby /cosmos/bin/cosmos" with all parameters ignoring the first.
docker run --rm -v %cd%:/cosmos/local -w /cosmos/local ballaerospace/cosmosc2-base:!COSMOS_TAG! ruby /cosmos/bin/cosmos !params!
GOTO :EOF
)
if "%1" == "restart" (
GOTO restart
)
if "%1" == "start" (
GOTO startup
)
if "%1" == "stop" (
GOTO stop
)
if "%1" == "cleanup" (
GOTO cleanup
)
if "%1" == "build" (
GOTO build
)
if "%1" == "run" (
GOTO run
)
if "%1" == "dev" (
GOTO dev
)
if "%1" == "dind" (
GOTO dind
)
if "%1" == "deploy" (
GOTO deploy
)
if "%1" == "test" (
GOTO test
)
if "%1" == "util" (
GOTO util
)
GOTO usage
:startup
CALL cosmos-control build || exit /b
docker-compose -f compose.yaml up -d
@echo off
GOTO :EOF
:restart
docker-compose -f compose.yaml restart
@echo off
GOTO :EOF
:stop
docker-compose -f compose.yaml down
@echo off
GOTO :EOF
:cleanup
docker-compose -f compose.yaml down -v
@echo off
GOTO :EOF
:build
CALL scripts\windows\cosmos_setup || exit /b
docker-compose -f compose.yaml -f compose-build.yaml build cosmos-ruby || exit /b
docker-compose -f compose.yaml -f compose-build.yaml build cosmos-base || exit /b
docker-compose -f compose.yaml -f compose-build.yaml build cosmos-node || exit /b
docker-compose -f compose.yaml -f compose-build.yaml build || exit /b
@echo off
GOTO :EOF
:run
docker-compose -f compose.yaml up -d
@echo off
GOTO :EOF
:dev
docker-compose -f compose.yaml -f compose-dev.yaml up -d
@echo off
GOTO :EOF
:dind
docker build -t cosmos-build .
docker run --rm -ti -v /var/run/docker.sock:/var/run/docker.sock cosmos-build
@echo off
GOTO :EOF
:deploy
REM Send the remaining arguments to cosmos_deploy
set args=%*
call set args=%%args:*%1=%%
CALL scripts\windows\cosmos_deploy %args% || exit /b
@echo off
GOTO :EOF
:test
REM Building COSMOS
CALL scripts\windows\cosmos_setup || exit /b
docker-compose -f compose.yaml -f compose-build.yaml build
set args=%*
call set args=%%args:*%1=%%
REM Running tests
CALL scripts\windows\cosmos_test %args% || exit /b
@echo off
GOTO :EOF
:util
REM Send the remaining arguments to cosmos_util
set args=%*
call set args=%%args:*%1=%%
CALL scripts\windows\cosmos_util %args% || exit /b
@echo off
GOTO :EOF
:usage
@echo Usage: %0 [start, stop, cleanup, build, run, deploy, util] 1>&2
@echo * cosmos: run a cosmos command ('cosmos help' for more info) 1>&2
@echo * start: run the docker containers for cosmos 1>&2
@echo * stop: stop the running docker containers for cosmos 1>&2
@echo * restart: stop and run the minimal docker containers for cosmos 1>&2
@echo * cleanup: cleanup network and volumes for cosmos 1>&2
@echo * build: build the containers for cosmos 1>&2
@echo * run: run the prebuilt containers for cosmos 1>&2
@echo * dev: run cosmos in dev mode 1>&2
@echo * dind: build and run the docker development container (cosmos-build) 1>&2
@echo * deploy: deploy the containers to localhost repository 1>&2
@echo * repository: hostname of the docker repository 1>&2
@echo * test: test COSMOS 1>&2
@echo * rspec: run tests against Ruby code 1>&2
@echo * playwright: run end-to-end tests 1>&2
@echo * util: various helper commands 1>&2
@echo * encode: encode a string to base64 1>&2
@echo * hash: hash a string using SHA-256 1>&2
@echo * load: load docker images from tar files 1>&2
@echo * save: save docker images to tar files 1>&2
@echo * zip: create cosmos zipfile 1>&2
@echo * clean: remove node_modules, coverage, etc 1>&2
@echo * hostsetup: configure host for redis 1>&2
@echo on