-
Notifications
You must be signed in to change notification settings - Fork 25
Expand file tree
/
Copy pathrun_dev.bat
More file actions
90 lines (76 loc) · 2.5 KB
/
run_dev.bat
File metadata and controls
90 lines (76 loc) · 2.5 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
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
@echo off
setlocal enabledelayedexpansion
REM Parse command line arguments
set "REBUILD=false"
for %%a in (%*) do (
if "%%a"=="--build" set "REBUILD=true"
)
echo.
echo ____ _ _
echo / ___|| |_ __ _ ___| | _____ _ _ _ __ ___
echo \___ \| __/ _` |/ __| |/ / __| | | | '_ \ / __|
echo ___) | || (_| | (__| <\__ \ |_| | | | | (__
echo |____/ \__\__,_|\___|_|\_\___/\__, |_| |_|\___|
echo |___/
echo.
echo App Connector Public Module
echo Documentation: https://docs.stacksync.com/workflows/app-connector
echo.
REM Ensure config directory exists
if not exist "config" (
echo Creating config directory...
mkdir config
)
REM Read port from app_config.yaml
set "DEFAULT_PORT=2003"
set "PORT=%DEFAULT_PORT%"
if exist "app_config.yaml" (
for /f "tokens=2 delims=: " %%p in ('findstr /r "^\s*port:" app_config.yaml') do (
set "PORT=%%p"
echo Using port from app_config.yaml: !PORT!
goto :port_found
)
echo No port specified. Using default port: %PORT%
) else (
echo Could not read app_config.yaml. Using default port: %PORT%
)
:port_found
REM Determine Dockerfile path
set "DOCKERFILE_PATH=config\Dockerfile.dev"
if not exist "%DOCKERFILE_PATH%" (
if exist "Dockerfile.dev" (
set "DOCKERFILE_PATH=Dockerfile.dev"
echo Using Dockerfile.dev from main directory
) else (
echo Using Dockerfile.dev from config directory
)
)
REM Get repository name
for %%I in ("%CD%") do set "DIRNAME=%%~nxI"
set "REPO_NAME=%DIRNAME%"
set "REPO_NAME=%REPO_NAME:workflows-=%"
set "APP_NAME=workflows-app-%REPO_NAME%"
echo Preparing %APP_NAME%...
REM Reset IMAGE_EXISTS
set "IMAGE_EXISTS="
REM Check if image exists
for /f %%i in ('docker images -q %APP_NAME% 2^>nul') do set "IMAGE_EXISTS=%%i"
REM Build or rebuild
if "%IMAGE_EXISTS%"=="" (
echo Docker image not found. Building: %APP_NAME%
docker build -t %APP_NAME% -f %DOCKERFILE_PATH% .
) else if "%REBUILD%"=="true" (
echo Forcing rebuild of Docker image: %APP_NAME%
docker build --no-cache -t %APP_NAME% -f %DOCKERFILE_PATH% .
) else (
echo Docker image %APP_NAME% already exists. Skipping build.
echo Use --build to force rebuild.
)
REM Detect build failure (ERRORLEVEL is 0 if success)
if errorlevel 1 (
echo ❌ Docker build failed. Exiting...
exit /b 1
)
REM Start container (8080 is internal port)
echo Starting container on port %PORT%...
docker run --rm -p %PORT%:8080 -it -e ENVIRONMENT=