From 514ee287dc257ba14bfd113cf2a07012ae1ab934 Mon Sep 17 00:00:00 2001 From: Pedro Jose Romero Gombau Date: Thu, 16 Jan 2025 17:01:29 +0100 Subject: [PATCH] Commands --- SECRETS | 2 ++ VERSION | 1 + buildImage.bat | 1 + dockyard.bat | 85 ++++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 89 insertions(+) create mode 100644 SECRETS create mode 100644 VERSION create mode 100644 buildImage.bat create mode 100644 dockyard.bat diff --git a/SECRETS b/SECRETS new file mode 100644 index 0000000..03e32f7 --- /dev/null +++ b/SECRETS @@ -0,0 +1,2 @@ +REG_USER=admin +REG_PASSWORD=Rx22hh36DOCKYARD \ No newline at end of file diff --git a/VERSION b/VERSION new file mode 100644 index 0000000..9f8e9b6 --- /dev/null +++ b/VERSION @@ -0,0 +1 @@ +1.0 \ No newline at end of file diff --git a/buildImage.bat b/buildImage.bat new file mode 100644 index 0000000..b93b9c0 --- /dev/null +++ b/buildImage.bat @@ -0,0 +1 @@ +docker build -t launchsim . \ No newline at end of file diff --git a/dockyard.bat b/dockyard.bat new file mode 100644 index 0000000..9b80d11 --- /dev/null +++ b/dockyard.bat @@ -0,0 +1,85 @@ +REM @echo off +setlocal enabledelayedexpansion + +REM Leer usuario y contraseña del archivo SECRETS +REM (deben ser líneas con formato REG_USER=xxx y REG_PASSWORD=xxx, sin espacios) +for /f "usebackq tokens=1,2 delims==" %%A in ("SECRETS") do ( + if /I "%%A"=="REG_USER" set "REG_USER=%%B" + if /I "%%A"=="REG_PASSWORD" set "REG_PASSWORD=%%B" +) + +REM Leer la versión del archivo VERSION +REM (asumimos que la primera línea tiene la versión, p.ej. 1.0) +for /f "usebackq tokens=* delims=" %%V in ("VERSION") do ( + set "VERSION=%%V" + goto :GotVersion +) + +:GotVersion + +REM Verificar que los valores estén cargados +if not defined REG_USER ( + echo Error: REG_USER no encontrado en SECRETS. + exit /b 1 +) + +if not defined REG_PASSWORD ( + echo Error: REG_PASSWORD no encontrado en SECRETS. + exit /b 1 +) + +if not defined VERSION ( + echo Error: VERSION no encontrado o vacío en VERSION. + exit /b 1 +) + +REM Login en el registro Docker +echo Realizando login en dockyard.spark-ops.com... +echo !REG_PASSWORD! | docker login dockyard.spark-ops.com --username !REG_USER! --password-stdin +if %ERRORLEVEL% neq 0 ( + echo Error: Falló el login en el registro Docker. + exit /b 1 +) + +REM Construir la imagen Docker +echo Construyendo la imagen Docker launchsim:!VERSION!... +docker build -t launchsim:!VERSION! . +if %ERRORLEVEL% neq 0 ( + echo Error: Falló la construcción de la imagen Docker. + exit /b 1 +) + +REM Etiquetar la imagen con la versión +echo Etiquetando la imagen para el registro... +docker tag launchsim:!VERSION! dockyard.spark-ops.com/launchsim/launchsim:!VERSION! +if %ERRORLEVEL% neq 0 ( + echo Error: Falló al etiquetar la imagen Docker. + exit /b 1 +) + +REM Etiquetar la imagen como latest +echo Etiquetando la imagen como latest... +docker tag launchsim:!VERSION! dockyard.spark-ops.com/launchsim/launchsim:latest +if %ERRORLEVEL% neq 0 ( + echo Error: Falló al etiquetar la imagen como latest. + exit /b 1 +) + +REM Subir la imagen con la versión +echo Subiendo la imagen al registro con la versión !VERSION!... +docker push dockyard.spark-ops.com/launchsim/launchsim:!VERSION! +if %ERRORLEVEL% neq 0 ( + echo Error: Falló al subir la imagen con la versión. + exit /b 1 +) + +REM Subir la imagen como latest +echo Subiendo la imagen como latest al registro... +docker push dockyard.spark-ops.com/launchsim/launchsim:latest +if %ERRORLEVEL% neq 0 ( + echo Error: Falló al subir la imagen como latest. + exit /b 1 +) + +echo Proceso completado exitosamente. +endlocal