-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathnzp.cmd
More file actions
46 lines (38 loc) · 1.3 KB
/
nzp.cmd
File metadata and controls
46 lines (38 loc) · 1.3 KB
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
@echo off
setlocal
set TOOLBOX_ROOT=%cd%
set IMAGE_NAME=nzp-toolbox:latest
rem Auto-build Docker image if absent.
docker image inspect %IMAGE_NAME% >nul 2>&1
if errorlevel 1 (
echo [INFO] Docker image not found. Building...
docker build --platform=linux/amd64 -t %IMAGE_NAME% %TOOLBOX_ROOT%
echo -----------------------------------------
)
rem Detect first-time setup and pull repos if needed
set FIRSTTIME=0
if not exist "%TOOLBOX_ROOT%\repos" set FIRSTTIME=1
for /f %%G in ('dir /b "%TOOLBOX_ROOT%\repos"') do (
if exist "%TOOLBOX_ROOT%\repos\%%G\.git" (
set FIRSTTIME=0
goto skip_pull
)
)
set FIRSTTIME=1
:skip_pull
if %FIRSTTIME%==1 (
echo [INFO] Pulling repositories for first time use...
docker run --platform=linux/amd64 --rm -i ^
-v "%TOOLBOX_ROOT%/config:/workspace/config" ^
-v "%TOOLBOX_ROOT%/repos:/workspace/repos" ^
-v "%TOOLBOX_ROOT%/python_envs:/workspace/python_envs" ^
%IMAGE_NAME% fetch
echo -----------------------------------------
)
rem Run container with mounts and pass our arguments
docker run --platform=linux/amd64 --rm -i ^
-v "%TOOLBOX_ROOT%/config:/workspace/config" ^
-v "%TOOLBOX_ROOT%/repos:/workspace/repos" ^
-v "%TOOLBOX_ROOT%/python_envs:/workspace/python_envs" ^
%IMAGE_NAME% %*
endlocal