forked from efabless/foss-asic-tools
-
Notifications
You must be signed in to change notification settings - Fork 61
/
start_jupyter.bat
67 lines (55 loc) · 3.29 KB
/
start_jupyter.bat
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
:: ========================================================================
:: Start script for IIC docker images (use for Jupyter notebooks only)
::
:: SPDX-FileCopyrightText: 2022-2023 Harald Pretl and Georg Zachl
:: Johannes Kepler University, Institute for Integrated Circuits
::
:: Licensed under the Apache License, Version 2.0 (the "License");
:: you may not use this file except in compliance with the License.
:: You may obtain a copy of the License at
::
:: http://www.apache.org/licenses/LICENSE-2.0
::
:: Unless required by applicable law or agreed to in writing, software
:: distributed under the License is distributed on an "AS IS" BASIS,
:: WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
:: See the License for the specific language governing permissions and
:: limitations under the License.
:: SPDX-License-Identifier: Apache-2.0
:: ========================================================================
@echo off
SETLOCAL
SET DEFAULT_DESIGNS=%USERPROFILE%\eda\designs
IF DEFINED DRY_RUN (
echo This is a dry run, all commands will be printed to the shell ^(Commands printed but not executed are marked with ^$^)!
SET ECHO_IF_DRY_RUN=ECHO $
)
IF NOT DEFINED DESIGNS SET DESIGNS=%DEFAULT_DESIGNS%
echo Using/creating designs directory: %DESIGNS%
if not exist "%DESIGNS%" %ECHO_IF_DRY_RUN% mkdir "%DESIGNS%"
IF NOT DEFINED JUPYTER_PORT SET JUPYTER_PORT=8888
IF NOT DEFINED DOCKER_USER SET DOCKER_USER=hpretl
IF NOT DEFINED DOCKER_IMAGE SET DOCKER_IMAGE=iic-osic-tools
IF NOT DEFINED DOCKER_TAG SET DOCKER_TAG=latest
IF NOT DEFINED CONTAINER_USER SET CONTAINER_USER=1000
IF NOT DEFINED CONTAINER_GROUP SET CONTAINER_GROUP=1000
IF NOT DEFINED CONTAINER_NAME SET CONTAINER_NAME=iic-osic-tools_jupyter
IF %CONTAINER_USER% NEQ 0 if %CONTAINER_USER% LSS 1000 echo WARNING: Selected User ID %CONTAINER_USER% is below 1000. This ID might interfere with User-IDs inside the container and cause undefined behaviour!
IF %CONTAINER_GROUP% NEQ 0 if %CONTAINER_GROUP% LSS 1000 echo WARNING: Selected Group ID %CONTAINER_GROUP% is below 1000. This ID might interfere with Group-IDs inside the container and cause undefined behaviour!
SET PARAMS=--security-opt seccomp=unconfined
IF DEFINED JUPYTER_PORT SET PARAMS=%PARAMS% -p %JUPYTER_PORT%:8888
IF DEFINED DOCKER_EXTRA_PARAMS SET PARAMS=%PARAMS% %DOCKER_EXTRA_PARAMS%
@REM Check if the container exists and if it is running.
docker container inspect %CONTAINER_NAME% 2>&1 | find "Status" | find /i "running"
IF NOT ERRORLEVEL 1 (
ECHO Container is running! Stop with \"docker stop %CONTAINER_NAME%\" and remove with \"docker rm %CONTAINER_NAME%\" if required.
) ELSE (
docker container inspect %CONTAINER_NAME% 2>&1 | find "Status" | find /i "exited"
IF NOT ERRORLEVEL 1 (
echo Container %CONTAINER_NAME% exists. Restart with \"docker start %CONTAINER_NAME%\" or remove with \"docker rm %CONTAINER_NAME%\" if required.
) ELSE (
echo Container does not exist, pulling %DOCKER_USER%/%DOCKER_IMAGE%:%DOCKER_TAG and creating %CONTAINER_NAME% ...
%ECHO_IF_DRY_RUN% docker pull %DOCKER_USER%/%DOCKER_IMAGE%:%DOCKER_TAG
%ECHO_IF_DRY_RUN% docker run -d --user %CONTAINER_USER%:%CONTAINER_GROUP% %PARAMS% -v "%DESIGNS%":/foss/designs --name %CONTAINER_NAME% %DOCKER_USER%/%DOCKER_IMAGE%:%DOCKER_TAG% -s jupyter lab --no-browser
)
)