From 29e57dad4272fbbc17c69003e3b8c38e3fd22dac Mon Sep 17 00:00:00 2001 From: Trevor Sullivan Date: Fri, 3 Jan 2020 10:42:08 -0800 Subject: [PATCH 1/2] =?UTF-8?q?Adding=20Dockerfile=20for=20Jupyter=20Power?= =?UTF-8?q?Shell=20=F0=9F=91=A8=F0=9F=8F=BB=E2=80=8D=F0=9F=92=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Dockerfile | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..543f0a6 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,42 @@ +FROM python:buster + +# Install Jupyter package and PowerShell "kernel" for Jupyter +WORKDIR /app + +ADD [".", "/app/"] + +RUN pip install jupyterlab powershell_kernel \ + && python -m powershell_kernel.install \ + && mkdir /home/python \ + && useradd --home-dir /home/python --shell /bin/bash python \ + && chown -R python /home/python + +# Install PowerShell for Debian 10 (Buster) and dependencies +# NOTE: PowerShell v7 or later is required for Debian 10, according to Microsoft documentation +ARG PS_VERSION=7.0.0-rc.1 +ARG PS_PACKAGE=powershell-preview_${PS_VERSION}-1.debian.10_amd64.deb +ARG PS_PACKAGE_URL=https://github.com/PowerShell/PowerShell/releases/download/v${PS_VERSION}/${PS_PACKAGE} + +ADD ${PS_PACKAGE_URL} /tmp/powershell.deb + +RUN apt-get update \ + && apt-get install apt-utils --yes \ + && apt-get install /tmp/powershell.deb less locales gss-ntlmssp --yes \ + && apt-get clean \ + && rm -rf /var/lib/apt/lists/* \ + && rm /tmp/powershell.deb + +# Add PowerShell install directory to $PATH, else it can't be located +ENV PATH="/opt/microsoft/powershell/7-preview:${PATH}" + +# Best practice: Run container under a non-root user +USER python + +# Expose Jupyter on TCP port 8080 +EXPOSE 8080 + +# Set the working directory to non-root user's $HOME directory, so Jupyter UI works correctly +WORKDIR /home/python + +# Set the entrypoint for the container image +CMD ["jupyter", "notebook", "--ip=0.0.0.0", "--port=8080"] \ No newline at end of file From c208f49906796d2d62d17ecc8149e88f00b4eb63 Mon Sep 17 00:00:00 2001 From: Trevor Sullivan Date: Fri, 3 Jan 2020 11:18:15 -0800 Subject: [PATCH 2/2] Add LICENSE to Dockerfile and update README --- Dockerfile | 20 ++++++++++++++++++++ README.md | 30 ++++++++---------------------- 2 files changed, 28 insertions(+), 22 deletions(-) diff --git a/Dockerfile b/Dockerfile index 543f0a6..b89b578 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,3 +1,23 @@ +# Copyright (c) 2020 Trevor Sullivan + +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: + +# The above copyright notice and this permission notice shall be included in all +# copies or substantial portions of the Software. + +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. + FROM python:buster # Install Jupyter package and PowerShell "kernel" for Jupyter diff --git a/README.md b/README.md index cd8a900..1f9b459 100644 --- a/README.md +++ b/README.md @@ -1,31 +1,22 @@ -# jupyter-powershell +# Docker Image for jupyter-powershell -PowerShell language kernel for Jupyter. -Works on Windows, Linux and MacOS. +Dockerized PowerShell language kernel for Jupyter. Works on Linux and Docker Desktop. -## Install kernel +## Build Container Image -``` -pip install powershell_kernel -python -m powershell_kernel.install -``` - -This command will install the kernel with Full PowerShell on Windows and Core on non-Windows. -You can also specify command (i.e. if you want to use powershell Core on Windows). +To build the container image, run the following command: ``` -python -m powershell_kernel.install --powershell-command pwsh +docker build --tag jupyter-powershell . ``` -## Run - -Run jupyter and you will see new kernel available! +To run a container, run the following command: ``` -jupyter notebook +docker run --interactive --tty --publish 8080:8080 jupyter-powershell ``` -## Aknowledgement +## Acknowledgement This is an early prototype, but I tried to avoid unnessesary dependencies. @@ -44,8 +35,3 @@ This means that, although the parts of SublimeREPL that I (wuub) wrote are publi I'd like to avoid GPLv2 dependencies (and I don't need any of that code), so I want to list all used code (BSD/MIT): * `subprocess_repl.py` wrote by wuub, licensed under BSD/MIT. - - -### LICENSE - -All code that I (vors) wrote is licensed under MIT v3 license.