Last active
December 23, 2020 21:55
-
-
Save rwasef1830/d2a2d2cf7ebde2bac33b2b1050b331f8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Echo Off | |
REM This file is replacement for the old WebMatrix / IIS Express / PHP stack | |
REM Put this file in %AppData%\Microsoft\Windows\SendTo | |
If NOT "%1"=="" cd /D "%2" | |
Echo Pulling latest image... | |
docker pull webdevops/php-apache-dev:7.4-alpine | |
Echo Pruning old images... | |
docker image prune -f | |
If exist .docker-dev-server for /F "usebackq tokens=1" %%i IN (`type .docker-dev-server`) Do SET LOCALPORT=%%i | |
for /F "usebackq" %%i IN (`wsl pwd`) DO set WSLPWD=%%i | |
if "%WSLPWD%"=="/root" goto translatePlan9Path | |
goto :start | |
:translatePlan9Path | |
For %%i IN (%CD%) DO SET WSLPWD=%%~pnxi | |
SET WSLPWD=%WSLPWD:\=/% | |
goto :start | |
:start | |
SET TEMPFILE="%TEMP%\docker.container.%RANDOM%" | |
If not "%LOCALPORT%"=="" SET PORTPARAM=%LOCALPORT%: | |
wsl docker run -p %PORTPARAM%443 -v "%WSLPWD%:/app" -v "`wslpath 'D:\Transient\PHP\profiling'`:/tmp/profiling" -d --rm -e XDEBUG_REMOTE_HOST=host.docker.internal -e XDEBUG_CLIENT_HOST=host.docker.internal -e XDEBUG_REMOTE_PORT=9000 -e XDEBUG_PROFILER_ENABLE_TRIGGER=1 -e XDEBUG_REMOTE_CONNECT_BACK=0 -e POSTFIX_RELAYHOST=host.docker.internal -e "fpm.pool.user=root" -e "fpm.pool.group=root" -e CONTAINER_UID=root -e SERVICE_PHPFPM_OPTS=-R -e "php.xdebug.profiler_output_dir=/tmp/profiling" -e "php.xdebug.profiler_output_name=callgrind.out.%%H.%%R.%%p" webdevops/php-apache-dev:7.4-alpine > "%TEMPFILE%" | |
for /F "usebackq" %%i IN (`type "%TEMPFILE%"`) DO SET CONTAINER=%%i | |
DEL "%TEMPFILE%" | |
for /F "usebackq tokens=*" %%i IN (`docker container port %CONTAINER%`) Do TITLE %CONTAINER%: %%i | |
for /f "usebackq tokens=2 delims=:" %%i IN (`docker container port %CONTAINER%`) Do set LOCALPORT=%%i | |
echo %LOCALPORT% > .docker-dev-server | |
start "" https://localhost:%LOCALPORT%/ | |
wsl docker container attach %CONTAINER% | |
goto :EOF |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Now updated to support being invoked on
\\wsl$
drive mounted share folders.