Skip to content

Commit

Permalink
Refactor add-on (#232)
Browse files Browse the repository at this point in the history
* Refactor add-on

* Replace NGinx Configuration

* Ingress!!!

* More tweaks, renames and other touches

* Revert accidental upgrade of JupyterLab
  • Loading branch information
frenck authored Feb 2, 2021
1 parent d504c96 commit 5a7eb72
Show file tree
Hide file tree
Showing 32 changed files with 258 additions and 375 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
build: ${{ steps.information.outputs.build }}
description: ${{ steps.information.outputs.description }}
name: ${{ steps.information.outputs.name }}
slug: ${{ steps.information.outputs.slug }}
slug: "jupyterlab"
target: ${{ steps.information.outputs.target }}
steps:
- name: ⤵️ Check out code from GitHub
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
description: ${{ steps.information.outputs.description }}
environment: ${{ steps.release.outputs.environment }}
name: ${{ steps.information.outputs.name }}
slug: ${{ steps.information.outputs.slug }}
slug: "jupyterlab"
target: ${{ steps.information.outputs.target }}
version: ${{ steps.release.outputs.version }}
steps:
Expand Down
4 changes: 2 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,5 @@ Even better: You could submit a pull request with a fix / new feature!
developers, or if you do not have permission to do that, you may request
the second reviewer to merge it for you.

[github]: https://github.com/hassio-addons/addon-jupyterlab-lite/issues
[prs]: https://github.com/hassio-addons/addon-jupyterlab-lite/pulls
[github]: https://github.com/hassio-addons/addon-jupyterlab/issues
[prs]: https://github.com/hassio-addons/addon-jupyterlab/pulls
22 changes: 11 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Home Assistant Community Add-on: JupyterLab Lite
# Home Assistant Community Add-on: JupyterLab

[![GitHub Release][releases-shield]][releases]
![Project Stage][project-stage-shield]
Expand Down Expand Up @@ -105,30 +105,30 @@ SOFTWARE.
[amd64-shield]: https://img.shields.io/badge/amd64-yes-green.svg
[armhf-shield]: https://img.shields.io/badge/armhf-yes-green.svg
[armv7-shield]: https://img.shields.io/badge/armv7-no-red.svg
[commits-shield]: https://img.shields.io/github/commit-activity/y/hassio-addons/addon-jupyterlab-lite.svg
[commits]: https://github.com/hassio-addons/addon-jupyterlab-lite/commits/main
[contributors]: https://github.com/hassio-addons/addon-jupyterlab-lite/graphs/contributors
[commits-shield]: https://img.shields.io/github/commit-activity/y/hassio-addons/addon-jupyterlab.svg
[commits]: https://github.com/hassio-addons/addon-jupyterlab/commits/main
[contributors]: https://github.com/hassio-addons/addon-jupyterlab/graphs/contributors
[discord-ha]: https://discord.gg/c5DvZ4e
[discord-shield]: https://img.shields.io/discord/478094546522079232.svg
[discord]: https://discord.me/hassioaddons
[docs]: https://github.com/hassio-addons/addon-jupyterlab-lite/blob/main/jupyterlab-lite/DOCS.md
[docs]: https://github.com/hassio-addons/addon-jupyterlab/blob/main/jupyterlab/DOCS.md
[forum-shield]: https://img.shields.io/badge/community-forum-brightgreen.svg
[forum]: https://community.home-assistant.io/t/home-assistant-community-add-on-jupyterlab-lite/87337?u=frenck
[frenck]: https://github.com/frenck
[github-actions-shield]: https://github.com/hassio-addons/addon-jupyterlab-lite/workflows/CI/badge.svg
[github-actions]: https://github.com/hassio-addons/addon-jupyterlab-lite/actions
[github-actions-shield]: https://github.com/hassio-addons/addon-jupyterlab/workflows/CI/badge.svg
[github-actions]: https://github.com/hassio-addons/addon-jupyterlab/actions
[github-sponsors-shield]: https://frenck.dev/wp-content/uploads/2019/12/github_sponsor.png
[github-sponsors]: https://github.com/sponsors/frenck
[home-assistant]: https://home-assistant.io
[i386-shield]: https://img.shields.io/badge/i386-no-red.svg
[issue]: https://github.com/hassio-addons/addon-jupyterlab-lite/issues
[license-shield]: https://img.shields.io/github/license/hassio-addons/addon-jupyterlab-lite.svg
[issue]: https://github.com/hassio-addons/addon-jupyterlab/issues
[license-shield]: https://img.shields.io/github/license/hassio-addons/addon-jupyterlab.svg
[maintenance-shield]: https://img.shields.io/maintenance/yes/2021.svg
[patreon-shield]: https://frenck.dev/wp-content/uploads/2019/12/patreon.png
[patreon]: https://www.patreon.com/frenck
[project-stage-shield]: https://img.shields.io/badge/project%20stage-experimental-yellow.svg
[python-packages]: https://pypi.org/
[reddit]: https://reddit.com/r/homeassistant
[releases-shield]: https://img.shields.io/github/release/hassio-addons/addon-jupyterlab-lite.svg
[releases]: https://github.com/hassio-addons/addon-jupyterlab-lite/releases
[releases-shield]: https://img.shields.io/github/release/hassio-addons/addon-jupyterlab.svg
[releases]: https://github.com/hassio-addons/addon-jupyterlab/releases
[repository]: https://github.com/hassio-addons/repository
4 changes: 2 additions & 2 deletions jupyterlab/.README.j2
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Home Assistant Community Add-on: JupyterLab Lite
# Home Assistant Community Add-on: JupyterLab

[![Release][release-shield]][release] ![Project Stage][project-stage-shield] ![Project Maintenance][maintenance-shield]

Expand Down Expand Up @@ -76,4 +76,4 @@ If you are more interested in stable releases of our add-ons:
[project-stage-shield]: https://img.shields.io/badge/project%20stage-experimental-yellow.svg
[release-shield]: https://img.shields.io/badge/version-{{ version }}-blue.svg
[release]: {{ repo }}/tree/{{ version }}
[screenshot]: https://github.com/hassio-addons/addon-jupyterlab-lite/raw/main/images/screenshot.png
[screenshot]: https://github.com/hassio-addons/addon-jupyterlab/raw/main/images/screenshot.png
53 changes: 8 additions & 45 deletions jupyterlab/DOCS.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Home Assistant Community Add-on: JupyterLab Lite
# Home Assistant Community Add-on: JupyterLab

JupyterLab is an open-source web application that allows you to create and share
documents that contain live code, equations, visualizations and narrative text.
Expand All @@ -14,10 +14,10 @@ reproducible computing, based on the Jupyter Notebook and Architecture.
The installation of this add-on is pretty straightforward and not different in
comparison to installing any other Home Assistant add-on.

1. Search for the "JupyterLab Lite" add-on in the Supervisor add-on store
1. Search for the "JupyterLab" add-on in the Supervisor add-on store
and install it.
1. Start the "JupyterLab Lite" add-on
1. Check the logs of the "JupyterLab Lite" add-on to see if everything went well.
1. Start the "JupyterLab" add-on
1. Check the logs of the "JupyterLab" add-on to see if everything went well.

## Configuration

Expand All @@ -28,9 +28,6 @@ Example add-on configuration:
```yaml
log_level: info
github_access_token: abcdef1234567890abcdef0123456789abcdef01
ssl: true
certfile: fullchain.pem
keyfile: privkey.pem
system_packages:
- ffmpeg
init_commands:
Expand Down Expand Up @@ -69,23 +66,6 @@ There is a chapter in this document with instruction on obtaining such a token.

**Note**: _This option support secrets, e.g., `!secret github_token`._

### Option: `ssl`

Enables/Disables SSL (HTTPS) on the JupyterLab Set it `true` to enable it,
`false` otherwise.

### Option: `certfile`

The certificate file to use for SSL.

**Note**: _The file MUST be stored in `/ssl/`, which is the default_

### Option: `keyfile`

The private key file to use for SSL.

**Note**: _The file MUST be stored in `/ssl/`, which is the default_

### Option: `system_packages`

Allows you to specify additional [Alpine packages][alpine-packages] to be
Expand All @@ -100,23 +80,6 @@ Customize your environment even more with the `init_commands` option.
Add one or more shell commands to the list, and they will be executed every
single time this add-on starts.

## Embedding into Home Assistant

It is possible to embed JupyterLab directly into Home Assistant, allowing
you to access the JupyterLab through the Home Assistant frontend.

Home Assistant provides the `panel_iframe` integration, for these purposes.

Example configuration:

```yaml
panel_iframe:
jupyterlab:
title: JupyterLab
icon: mdi:flask
url: https://addres.to.your.home.assistant:7777
```

## Getting a GitHub access token

You can get an access token by following these steps:
Expand Down Expand Up @@ -194,15 +157,15 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

[alpine-packages]: https://pkgs.alpinelinux.org/packages
[contributors]: https://github.com/hassio-addons/addon-jupyterlab-lite/graphs/contributors
[contributors]: https://github.com/hassio-addons/addon-jupyterlab/graphs/contributors
[discord-ha]: https://discord.gg/c5DvZ4e
[discord]: https://discord.me/hassioaddons
[forum-shield]: https://img.shields.io/badge/community-forum-brightgreen.svg
[forum]: https://community.home-assistant.io/t/home-assistant-community-add-on-jupyterlab-lite/87337?u=frenck
[forum]: https://community.home-assistant.io/t/home-assistant-community-add-on-jupyterlab/87337?u=frenck
[frenck]: https://github.com/frenck
[github-verify]: https://help.github.com/articles/verifying-your-email-address
[issue]: https://github.com/hassio-addons/addon-jupyterlab-lite/issues
[issue]: https://github.com/hassio-addons/addon-jupyterlab/issues
[python-packages]: https://pypi.org/
[reddit]: https://reddit.com/r/homeassistant
[releases]: https://github.com/hassio-addons/addon-jupyterlab-lite/releases
[releases]: https://github.com/hassio-addons/addon-jupyterlab/releases
[semver]: http://semver.org/spec/v2.0.0.htm
27 changes: 12 additions & 15 deletions jupyterlab/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ARG BUILD_FROM=hassioaddons/debian-base:3.2.3
ARG BUILD_FROM=ghcr.io/hassio-addons/debian-base/amd64:4.1.2
# hadolint ignore=DL3006
FROM ${BUILD_FROM}

Expand All @@ -25,26 +25,25 @@ RUN \
gpg=2.2.12-1+deb10u1 \
libffi-dev=3.2.1-9 \
libffi6=3.2.1-9 \
libfreetype6-dev=2.9.1-3+deb10u1 \
libfreetype6=2.9.1-3+deb10u1 \
libjpeg62-turbo-dev=1:1.5.2-2+b1 \
libjpeg62-turbo=1:1.5.2-2+b1 \
libfreetype6-dev=2.9.1-3+deb10u2 \
libfreetype6=2.9.1-3+deb10u2 \
libjpeg62-turbo-dev=1:1.5.2-2+deb10u1 \
libjpeg62-turbo=1:1.5.2-2+deb10u1 \
libmariadb-dev=1:10.3.25-0+deb10u1 \
libmariadb3=1:10.3.25-0+deb10u1 \
libnginx-mod-http-lua=1.14.2-2+deb10u3 \
libpng-dev=1.6.36-6 \
libpng16-16=1.6.36-6 \
libpq-dev=11.7-0+deb10u1 \
libpq5=11.7-0+deb10u1 \
libssl-dev=1.1.1d-0+deb10u3 \
libpq-dev=11.9-0+deb10u1 \
libpq5=11.9-0+deb10u1 \
libssl-dev=1.1.1d-0+deb10u4 \
libtiff5-dev=4.1.0+git191117-2~deb10u1 \
libxml2-dev=2.9.4+dfsg1-7+b3 \
libxml2=2.9.4+dfsg1-7+b3 \
libxml2-dev=2.9.4+dfsg1-7+deb10u1 \
libxml2=2.9.4+dfsg1-7+deb10u1 \
libxslt1-dev=1.1.32-2.2~deb10u1 \
libxslt1.1=1.1.32-2.2~deb10u1 \
libzmq3-dev=4.3.1-4+deb10u2 \
libzmq5=4.3.1-4+deb10u2 \
luarocks=2.4.2+dfsg-1 \
nginx=1.14.2-2+deb10u3 \
pandoc>=2.2.1-3 \
pkg-config=0.29-6 \
Expand All @@ -54,19 +53,17 @@ RUN \
python3-minimal=3.7.3-1 \
zlib1g-dev=1:1.2.11.dfsg-1 \
\
&& luarocks install lua-resty-http 0.15-0 \
\
&& curl -sL https://deb.nodesource.com/setup_12.x | bash - \
\
&& apt-get install -y --no-install-recommends \
nodejs=12.19.0-1nodesource1 \
nodejs=12.20.1-1nodesource1 \
\
&& curl https://bootstrap.pypa.io/get-pip.py | python3 \
\
&& update-alternatives \
--install /usr/bin/python python /usr/bin/python3 10 \
\
&& pip3 install --no-cache-dir numpy==1.19.4 \
&& pip3 install --no-cache-dir numpy==1.20.0 \
&& pip3 install --no-cache-dir -r /opt/requirements.txt \
\
&& jupyter labextension install \
Expand Down
5 changes: 2 additions & 3 deletions jupyterlab/build.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
{
"build_from": {
"aarch64": "hassioaddons/debian-base-aarch64:3.2.3",
"amd64": "hassioaddons/debian-base-amd64:3.2.3",
"armhf": "hassioaddons/debian-base-armhf:3.2.3"
"aarch64": "ghcr.io/hassio-addons/debian-base/aarch64:4.1.2",
"amd64": "ghcr.io/hassio-addons/debian-base/amd64:4.1.2"
}
}
22 changes: 6 additions & 16 deletions jupyterlab/config.json
Original file line number Diff line number Diff line change
@@ -1,32 +1,22 @@
{
"name": "JupyterLab Lite",
"name": "JupyterLab",
"version": "dev",
"slug": "jupyterlablite",
"description": "Create documents containing live code, equations, visualizations, and explanatory text",
"url": "https://github.com/hassio-addons/addon-jupyterlab-lite",
"webui": "[PROTO:ssl]://[HOST]:[PORT:7777]",
"arch": ["aarch64", "amd64", "armhf"],
"hassio_api": true,
"auth_api": true,
"url": "https://github.com/hassio-addons/addon-jupyterlab",
"ingress": true,
"panel_icon": "mdi:flask-outline",
"arch": ["aarch64", "amd64"],
"homeassistant_api": true,
"ports": {
"7777/tcp": 7777
},
"map": ["config:rw", "share:rw", "ssl"],
"map": ["config:rw", "share:rw"],
"options": {
"github_access_token": "",
"ssl": false,
"certfile": "fullchain.pem",
"keyfile": "privkey.pem",
"system_packages": [],
"init_commands": []
},
"schema": {
"log_level": "list(trace|debug|info|notice|warning|error|fatal)?",
"github_access_token": "password",
"ssl": "bool",
"certfile": "str",
"keyfile": "str",
"system_packages": ["str"],
"init_commands": ["str"]
}
Expand Down
4 changes: 2 additions & 2 deletions jupyterlab/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ jupyterlab==2.2.9
matplotlib==3.3.3
mysqlclient==2.0.3
nbconvert==6.0.7
numpy==1.19.5
numpy==1.20.0
pandas-datareader==0.9.0
pandas==1.2.1
psycopg2==2.8.6
python-dateutil==2.8.1
scrapy==2.4.1
SQLAlchemy==1.3.22
SQLAlchemy==1.3.23
6 changes: 0 additions & 6 deletions jupyterlab/rootfs/etc/cont-init.d/10-requirements.sh

This file was deleted.

24 changes: 0 additions & 24 deletions jupyterlab/rootfs/etc/cont-init.d/11-nginx.sh

This file was deleted.

13 changes: 0 additions & 13 deletions jupyterlab/rootfs/etc/cont-init.d/51-github.sh

This file was deleted.

11 changes: 0 additions & 11 deletions jupyterlab/rootfs/etc/cont-init.d/81-user-scripts.sh

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/with-contenv bashio
# ==============================================================================
# Home Assistant Community Add-on: JupyterLab Lite
# Ensure directories in the persistent storage exists
# Home Assistant Community Add-on: JupyterLab
# Configure JupterLabs
# ==============================================================================
if ! bashio::fs.directory_exists '/data/user-settings'; then
mkdir -p /data/user-settings \
Expand All @@ -20,4 +20,14 @@ if ! bashio::fs.directory_exists '/data/local'; then
|| bashio::exit.nok \
'Failed creating persistent local directory'
fi

ln -s /data/local /root/.local

bashio::var.json \
entry "$(bashio::addon.ingress_entry)" \
token "$(bashio::config 'github_access_token')" \
| tempio \
-template /etc/jupyter/jupyter_notebook_config.gtpl \
-out /etc/jupyter/jupyter_notebook_config.py


Loading

0 comments on commit 5a7eb72

Please sign in to comment.