Skip to content

Commit

Permalink
! scripts moved
Browse files Browse the repository at this point in the history
  • Loading branch information
ALERTua committed Sep 10, 2024
1 parent 7a1cc15 commit 51b6905
Show file tree
Hide file tree
Showing 3 changed files with 83 additions and 66 deletions.
63 changes: 0 additions & 63 deletions deploy.cmd

This file was deleted.

81 changes: 81 additions & 0 deletions script/deploy.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
@echo off
setlocal enabledelayedexpansion enableextensions

poetry check || goto :end
if not exist poetry.lock poetry lock || goto :end

if not defined DOCKER_BUILDKIT set DOCKER_BUILDKIT=1
if not defined DOCKER_REGISTRY set DOCKER_REGISTRY=registry.alertua.duckdns.org
echo DOCKER_REGISTRY: %DOCKER_REGISTRY%

set prevdir=%CD%
echo prevdir: %prevdir%

cd /d %~dp0

for %%I in ("%CD%") do set "curdir=%%~nxI"
set "curdir_prefix=!curdir:~0,6!"
if /I "%curdir_prefix%"=="script" cd ..
for %%I in ("%CD%") do set "curdir=%%~nxI"
echo curdir: %curdir%

if not defined IMAGE_NAME set IMAGE_NAME=%curdir%
echo IMAGE_NAME: %IMAGE_NAME%

if not defined IMAGE_TAG set IMAGE_TAG=latest
echo IMAGE_TAG: %IMAGE_TAG%

if not defined BUILD_TAG set BUILD_TAG=%DOCKER_REGISTRY%/%IMAGE_NAME%:%IMAGE_TAG%
echo BUILD_TAG: %BUILD_TAG%

if not defined BUILD_PATH set "BUILD_PATH=%CD%"
echo BUILD_PATH: %BUILD_PATH%
pushd %BUILD_PATH%

if not defined DOCKER_EXE set DOCKER_EXE=docker
rem set DOCKER_OPTS=--insecure-registry=%DOCKER_REGISTRY%
if not defined DOCKER_OPTS set DOCKER_OPTS=--max-concurrent-uploads=10 --max-concurrent-downloads=10

"%DOCKER_EXE%" --version

echo DOCKER_REMOTE: %DOCKER_REMOTE%
if defined DOCKER_HOST echo DOCKER_HOST: %DOCKER_HOST%

@REM choice /C YN /m "Proceed?"
@REM if ["%errorlevel%"] NEQ ["1"] goto :end
timeout /t 7

if not defined DOCKER_REMOTE (
if not defined DOCKER_SERVICE set DOCKER_SERVICE=com.docker.service
where %DOCKER_EXE% >nul || set "DOCKER_EXE=%ProgramFiles%\Docker\Docker\resources\bin\docker.exe"

sc query %DOCKER_SERVICE% | findstr /IC:"running" >nul || (
echo starting Docker service %DOCKER_SERVICE%
sudo net start %DOCKER_SERVICE% || (
echo "Error starting docker service %DOCKER_SERVICE%
goto :end
)
)

tasklist | findstr /IC:"Docker Desktop.exe" >nul || (
start "" "%ProgramFiles%\Docker\Docker\Docker Desktop.exe"
:loop
call docker info >nul 2>nul || (
timeout /t 1 >nul
goto loop
)
rem timeout /t 60
)
)

"%DOCKER_EXE%" --version
"%DOCKER_EXE%" build -t %BUILD_TAG% %BUILD_PATH% %* || goto :end
"%DOCKER_EXE%" push %DOCKER_REGISTRY%/%IMAGE_NAME% || goto :end

@REM net stop %DOCKER_SERVICE% || goto :end

goto :end

:end
cd /d %prevdir%
exit /b
5 changes: 2 additions & 3 deletions deploy_remote.cmd → script/deploy_remote.cmd
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@

@echo off
cd %~dp0
set DOCKER_HOST=tcp://gitlab:2375
set DOCKER_HOST=tcp://docker:2375
set DOCKER_REMOTE=1
call deploy.cmd %*
call %~dp0\deploy.cmd %*
where nircmd >nul 2>nul && nircmd beep 500 500

0 comments on commit 51b6905

Please sign in to comment.