diff --git a/README.md b/README.md index 90b4ecc..6830e00 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ LocalDevStack provides an easy-to-use Docker-based development environment for your projects. All modules are **selective** and can be enabled via environment settings (Compose profiles). -Supports **multiple domains** and local TLS (mkcert). +Supports **multiple domains** and local TLS. > 1) Local development only. > 2) Your domain(s) must be resolvable on your host: @@ -28,12 +28,19 @@ git clone https://github.com/infocyph/LocalDevStack.git cd LocalDevStack ```` -### 2) Permissions (Linux/macOS) +### 2) Setup global shortcut and Permissions +On Linux/Mac, ```bash chmod +x ./lds 2>/dev/null || true sudo ./lds setup permissions ``` +On Windows, +```cmd +./lds setup permissions +``` + +Once ran, it will add a globally available shortcut (lds). And necessary permissions(linux/mac) will be assigned as well. ### 3) Start the stack @@ -53,28 +60,6 @@ lds setup domain sudo lds certificate install ``` -### 6) Reload HTTP (after vhost/cert changes) - -```bash -lds http reload -``` - ---- - -## Minimal configuration - -Most setups only need: - -* `PROJECT_DIR` (where your apps live) -* `COMPOSE_PROFILES` (what to run) - -Example: - -```dotenv -PROJECT_DIR=../application -COMPOSE_PROFILES=nginx,php,php84,tools,mariadb,redis -``` - --- ## CLI help (built-in “man”) @@ -92,7 +77,7 @@ lds help certificate This README stays intentionally short. -* Full documentation: **Read the Docs** (Sphinx docs in `docs/`) +* Full documentation: https://docs.infocyph.com/projects/LocalDevStack * Quick reference: `lds help ...` --- diff --git a/lds b/lds index f9fd89f..f362c06 100755 --- a/lds +++ b/lds @@ -290,8 +290,40 @@ http_reload() { ############################################################################### # 2. PERMISSIONS FIX-UP ############################################################################### +add_to_windows_path() { + [[ "$OSTYPE" =~ (msys|cygwin) ]] || return 0 + command -v cygpath >/dev/null 2>&1 || return 0 + + # Only add if lds.bat exists where we think it is + [[ -f "$DIR/lds.bat" ]] || return 0 + + local win_repo + win_repo="$(cygpath -w "$DIR")" + + powershell.exe -NoProfile -ExecutionPolicy Bypass -Command " + \$t = '$win_repo' + \$cur = [Environment]::GetEnvironmentVariable('Path','User') + if ([string]::IsNullOrWhiteSpace(\$cur)) { \$cur = '' } + + # Normalize (trim + case-insensitive compare) to avoid duplicates + \$parts = \$cur -split ';' | ForEach-Object { \$_.Trim() } | Where-Object { \$_ } + \$exists = \$false + foreach (\$p in \$parts) { if (\$p.ToLowerInvariant() -eq \$t.ToLowerInvariant()) { \$exists = \$true; break } } + + if (-not \$exists) { + \$new = (\$parts + \$t) -join ';' + [Environment]::SetEnvironmentVariable('Path', \$new, 'User') + } + " >/dev/null 2>&1 || true +} + fix_perms() { - [[ "$OSTYPE" =~ (msys|cygwin) ]] && return + if [[ "$OSTYPE" =~ (msys|cygwin) ]]; then + add_to_windows_path + printf "%bWindows PATH configured.%b\n" "$GREEN" "$NC" + return 0 + fi + ((EUID == 0)) || die "Please run with sudo." chmod 755 "$DIR" @@ -387,7 +419,7 @@ modify_profiles() { } # ───────────────────────────────────────────────────────────────────────────── -# Profiles (merged from docker/utilities/profiles) +# Profiles # ───────────────────────────────────────────────────────────────────────────── declare -A SERVICES=( @@ -1934,12 +1966,12 @@ ${CYAN}Core commands:${NC} up / start Start docker stack (quiet pull by default) stop / down Stop stack reload / restart Restart stack + reload HTTP - rebuild all| Rebuild/pull services (no full down) + rebuild [all|] Rebuild/pull services (no full down) config Validate compose tools Enter SERVER_TOOLS container lzd | lazydocker Start LazyDocker http reload Reload Nginx/Apache - core Open bash in PHP container for + core [domain] Open bash in container for ${CYAN}Setup commands:${NC} setup init Initialize Primaries! diff --git a/lds.bat b/lds.bat index 71d5550..e838a65 100644 --- a/lds.bat +++ b/lds.bat @@ -42,11 +42,20 @@ if not exist "%DEVHOME%\lds" ( ) where docker.exe >nul 2>&1 -if errorlevel 1 echo %WARN% docker.exe not found on Windows PATH. It may fail. -if errorlevel 1 goto :run +if errorlevel 1 goto :no_docker docker info >nul 2>&1 -if errorlevel 1 echo %WARN% Docker installed but NOT running/reachable (docker info failed). Start Docker Desktop / engine. +if errorlevel 1 goto :docker_not_running + +goto :run + +:no_docker +echo %WARN% docker.exe not found on Windows PATH +exit /b 10 + +:docker_not_running +echo %WARN% Docker is installed but NOT running/reachable (docker info failed) +exit /b 11 :run "%BASH_EXE%" -lc "set -euo pipefail; export TERM=xterm-256color; DEVHOME_WIN=\"$1\"; CALLER_WIN=\"$2\"; DEVHOME=$(cygpath -u \"$DEVHOME_WIN\"); CALLER=$(cygpath -u \"$CALLER_WIN\"); cd \"$DEVHOME\"; chmod +x ./lds >/dev/null 2>&1 || true; cd \"$CALLER\"; shift 2; exec \"$DEVHOME/lds\" --__win_workdir \"$CALLER_WIN\" \"$@\"" bash "%DEVHOME%" "%WORKDIR%" %*