Skip to content

Commit 396f6aa

Browse files
authoredNov 13, 2024
Merge pull request #177 from Nnnes/dev-windows
Add support for Windows users with no WSL
2 parents 71ddaae + 615c0a1 commit 396f6aa

File tree

2 files changed

+84
-1
lines changed

2 files changed

+84
-1
lines changed
 

‎README.md

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ Docker-Volume-mounted. There is no need to build the Docker Image yourself (see
2222

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

25-
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.
25+
Linux, macOS, or WSL:
2626

2727
```bash
2828
cd workshop
@@ -35,6 +35,18 @@ cd workshop
3535
./geopython-workshop-ctl.sh stop
3636
```
3737

38+
Windows (Powershell or Command Prompt):
39+
40+
```bat
41+
cd workshop
42+
43+
.\win-geopython-workshop-ctl.bat start
44+
45+
.\win-geopython-workshop-ctl.bat url
46+
47+
.\win-geopython-workshop-ctl.bat stop
48+
```
49+
3850
NB [Jupyter notebook](https://en.wikipedia.org/wiki/Project_Jupyter) needs a **token**. The token is displayed in the jupyter container logs on startup:
3951

4052
`http://127.0.0.1:8888/?token=<longtokenhexstring>`.
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
@ECHO OFF
2+
3+
SETLOCAL EnableDelayedExpansion
4+
5+
SET "PROGRAM_NAME=%~nx0"
6+
7+
SET "USAGE=Usage: %PROGRAM_NAME% ^<start^|stop^|url^|update^|clean^>"
8+
9+
IF "%1"=="" (
10+
ECHO %USAGE%
11+
ENDLOCAL
12+
EXIT /B 1
13+
)
14+
IF NOT "%2"=="" (
15+
ECHO %USAGE%
16+
ENDLOCAL
17+
EXIT /B 1
18+
)
19+
20+
REM Sniff which Docker Compose variant is installed
21+
REM and set an alias.
22+
REM See https://github.com/geopython/geopython-workshop/issues/82
23+
docker-compose --version >NUL
24+
IF !ERRORLEVEL! EQU 0 (
25+
SET DOCKERCOMPOSE=docker-compose
26+
ECHO Using docker-compose
27+
) ELSE (
28+
docker compose version >NUL
29+
IF !ERRORLEVEL! NEQ 0 (
30+
ECHO Neither docker-compose nor docker compose is available
31+
ECHO Check your Docker Installation
32+
ENDLOCAL
33+
EXIT /B 1
34+
)
35+
SET "DOCKERCOMPOSE=docker compose"
36+
ECHO Using docker compose
37+
)
38+
39+
REM Test for the command
40+
IF /I "%1"=="start" (
41+
%PROGRAM_NAME% stop
42+
%DOCKERCOMPOSE% up -d
43+
) ELSE ( IF /I "%1"=="stop" (
44+
%DOCKERCOMPOSE% stop
45+
%DOCKERCOMPOSE% rm --force
46+
) ELSE ( IF /I "%1"=="url" (
47+
REM try to open the Jupyter Notebook in Browser
48+
REM Filter the URL from the log output
49+
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 }"
50+
IF !ERRORLEVEL! NEQ 0 (
51+
ECHO workshop not started
52+
ECHO did you start the workshop? (i.e. %PROGRAM_NAME% start^)
53+
ENDLOCAL
54+
EXIT /B 2
55+
)
56+
) ELSE ( IF /I "%1"=="update" (
57+
docker pull geopython/geopython-workshop:latest
58+
ECHO:
59+
ECHO:
60+
ECHO workshop is running the latest Docker images
61+
ECHO If updates occured, then stop/start the workshop
62+
) ELSE ( IF /I "%1"=="clean" (
63+
REM Remove all exited containers
64+
FOR /F %%c IN ('docker ps -a -f status^=exited -q') DO docker rm %%c
65+
REM And dangling images
66+
FOR /F %%i IN ('docker images -f dangling^=true -q') DO docker rmi %%i
67+
) ELSE (
68+
ECHO %USAGE%
69+
) ) ) ) )
70+
71+
ENDLOCAL

0 commit comments

Comments
 (0)
Please sign in to comment.