Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for Windows users with no WSL #177

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Docker-Volume-mounted. There is no need to build the Docker Image yourself (see

All services are started using a [Docker Compose file](https://github.com/geopython/geopython-workshop/blob/master/workshop/docker-compose.yml).

Windows users; use [powershell](https://en.wikipedia.org/wiki/PowerShell) or [Linux Subsystem](https://en.wikipedia.org/wiki/Windows_Subsystem_for_Linux) to run below commands.
Linux, macOS, or WSL:

```bash
cd workshop
Expand All @@ -35,6 +35,18 @@ cd workshop
./geopython-workshop-ctl.sh stop
```

Windows (Powershell or Command Prompt):

```bat
cd workshop

.\win-geopython-workshop-ctl.bat start

.\win-geopython-workshop-ctl.bat url

.\win-geopython-workshop-ctl.bat stop
```

NB [Jupyter notebook](https://en.wikipedia.org/wiki/Project_Jupyter) needs a **token**. The token is displayed in the jupyter container logs on startup:

`http://127.0.0.1:8888/?token=<longtokenhexstring>`.
Expand Down
71 changes: 71 additions & 0 deletions workshop/win-geopython-workshop-ctl.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
@ECHO OFF

SETLOCAL EnableDelayedExpansion

SET "PROGRAM_NAME=%~nx0"

SET "USAGE=Usage: %PROGRAM_NAME% ^<start^|stop^|url^|update^|clean^>"

IF "%1"=="" (
ECHO %USAGE%
ENDLOCAL
EXIT /B 1
)
IF NOT "%2"=="" (
ECHO %USAGE%
ENDLOCAL
EXIT /B 1
)

REM Sniff which Docker Compose variant is installed
REM and set an alias.
REM See https://github.com/geopython/geopython-workshop/issues/82
docker-compose --version >NUL
IF !ERRORLEVEL! EQU 0 (
SET DOCKERCOMPOSE=docker-compose
ECHO Using docker-compose
) ELSE (
docker compose version >NUL
IF !ERRORLEVEL! NEQ 0 (
ECHO Neither docker-compose nor docker compose is available
ECHO Check your Docker Installation
ENDLOCAL
EXIT /B 1
)
SET "DOCKERCOMPOSE=docker compose"
ECHO Using docker compose
)

REM Test for the command
IF /I "%1"=="start" (
%PROGRAM_NAME% stop
%DOCKERCOMPOSE% up -d
) ELSE ( IF /I "%1"=="stop" (
%DOCKERCOMPOSE% stop
%DOCKERCOMPOSE% rm --force
) ELSE ( IF /I "%1"=="url" (
REM try to open the Jupyter Notebook in Browser
REM Filter the URL from the log output
powershell -Command "try { $url = (docker logs geopython-workshop-jupyter 2>&1 | Select-String -Pattern 'http://127\.0\.0\.1\S+token\S+')[-1].Matches[0].Value; Write-Output ('Attempting to open ' + $url + ' in your browser on platform Windows...') 'If this fails, simply copy/paste that URL in your browser'; start $url } catch { exit 2 }"
IF !ERRORLEVEL! NEQ 0 (
ECHO workshop not started
ECHO did you start the workshop? (i.e. %PROGRAM_NAME% start^)
ENDLOCAL
EXIT /B 2
)
) ELSE ( IF /I "%1"=="update" (
docker pull geopython/geopython-workshop:latest
ECHO:
ECHO:
ECHO workshop is running the latest Docker images
ECHO If updates occured, then stop/start the workshop
) ELSE ( IF /I "%1"=="clean" (
REM Remove all exited containers
FOR /F %%c IN ('docker ps -a -f status^=exited -q') DO docker rm %%c
REM And dangling images
FOR /F %%i IN ('docker images -f dangling^=true -q') DO docker rmi %%i
) ELSE (
ECHO %USAGE%
) ) ) ) )

ENDLOCAL