Skip to content
This repository has been archived by the owner on Mar 14, 2024. It is now read-only.

Commit

Permalink
新增 GoLang 支持
Browse files Browse the repository at this point in the history
  • Loading branch information
星冉 committed May 4, 2022
1 parent ce1a5a7 commit 833f4d1
Show file tree
Hide file tree
Showing 4 changed files with 166 additions and 120 deletions.
35 changes: 19 additions & 16 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -64,41 +64,44 @@ RUN apt-get -qq install \
&& pip install jupyterlab-language-pack-zh-CN jupyter_contrib_nbextensions \
&& rm -rf /var/lib/apt/lists/* \
# RUST
&& bash <(curl --proto '=https' --tlsv1.2 https://sh.rustup.rs -sSf) -y
&& bash <(curl --proto '=https' --tlsv1.2 https://sh.rustup.rs -sSf) -y \
# ZSH
&& curl -s https://mirror.ghproxy.com/https://gist.githubusercontent.com/XRSec/0e47c9b793887d201bab9de2a07a740c/raw/e832430bfe70e6960cf583e0b1b00ab5c22cd15e/zsh_init.sh | bash || echo "ok!"

# ENV
RUN echo "export PATH=\$PATH:/root/go/bin/" >> /root/.bashrc \
&& echo "export PATH=\$PATH:$HOME/.cargo/bin" >> /root/.bashrc \
&& export PATH="\$PATH:/root/go/bin/" \
&& export PATH="\$PATH:$HOME/.cargo/bin" \
RUN echo 'export PATH="$PATH:$HOME/go/bin/"' >> /root/.bashrc \
&& echo 'export PATH="$PATH:$HOME/go/bin/"' >> /root/.zshrc \
&& echo 'export PATH="$PATH:$HOME/.cargo/bin/"' >> /root/.bashrc \
&& echo 'export PATH="$PATH:$HOME/.cargo/bin/"' >> /root/.zshrc \
&& export PATH="\$PATH:\$HOME/go/bin/" \
&& export PATH="\$PATH:\$HOME/.cargo/bin/" \
&& echo "$PATH"

# Rust
# Rust Kernel Config
RUN /root/.cargo/bin/rustup component add rust-src \
&& /root/.cargo/bin/cargo install evcxr_jupyter cargo-edit \
&& /root/.cargo/bin/evcxr_jupyter --install \
&& jupyter notebook --generate-config \
&& jupyter contrib nbextension install
&& jupyter contrib nbextension install \
&& cargo init /root/notebook

# Go
# Go Kernel Config
RUN env GO111MODULE=on go install github.com/gopherdata/gophernotes@latest \
&& mkdir -p ~/.local/share/jupyter/kernels/gophernotes \
&& cd ~/.local/share/jupyter/kernels/gophernotes \
&& cp "$(go env GOPATH)"/pkg/mod/github.com/gopherdata/gophernotes@v0.7.4/kernel/* "." \
&& chmod +w ./kernel.json # in case copied kernel.json has no write permission \
&& sed "s|gophernotes|$(go env GOPATH)/bin/gophernotes|" < kernel.json.in > kernel.json
&& chmod +w ./kernel.json \
&& sed "s|gophernotes|$(go env GOPATH)/bin/gophernotes|" < kernel.json.in > kernel.json \
&& cd /root/notebook \
&& go mod init notebook

# Jupyter
# Jupyter Set Config
RUN sed -i "s|# c.NotebookApp.ip = 'localhost'|c.NotebookApp.ip = '*'|g" /root/.jupyter/jupyter_notebook_config.py \
&& sed -i "s|# c.NotebookApp.allow_remote_access = False|c.NotebookApp.allow_remote_access = True|g" /root/.jupyter/jupyter_notebook_config.py \
&& sed -i "s|# c.NotebookApp.notebook_dir = ''|c.NotebookApp.notebook_dir = '/root/notebook'|g" /root/.jupyter/jupyter_notebook_config.py \
&& sed -i "s|# c.NotebookApp.terminado_settings = {}|c.NotebookApp.terminado_settings = {'shell_command': ['/bin/zsh']}|g" /root/.jupyter/jupyter_notebook_config.py \
&& echo "zh_CN.UTF-8 UTF-8" > /etc/locale.gen \
&& sudo locale-gen \
&& ln -sf /root/.jupyter/ /root/notebook/.jupyter

# ZSH
RUN curl -s https://mirror.ghproxy.com/https://gist.githubusercontent.com/XRSec/0e47c9b793887d201bab9de2a07a740c/raw/e832430bfe70e6960cf583e0b1b00ab5c22cd15e/zsh_init.sh | bash || echo "ok!"
&& sudo locale-gen

EXPOSE 8888
ENV TZ='Asia/Shanghai'
Expand Down
103 changes: 0 additions & 103 deletions README.ipynb

This file was deleted.

7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ docker run -it -d --name jupyter --rm xrsec/jupyter:latest
docker cp jupyter:/root/notebook /docker/jupyter
docker stop jupyter

# RUN

docker run -it -d \
--restart=always \
--name jupyter \
Expand All @@ -25,5 +27,8 @@ docker run -it -d \
# Get Tocken
docker logs jupyter
# Ather Setting
click web:jupyter/upyter_notebook_config.py
## jupyter => new => terminals
cp /root/.jupyter/jupyter_notebook_config.py /root/notebook/jupyter_notebook_config.py
## Edit & Save
cp -rf /root/notebook/jupyter_notebook_config.py /root/.jupyter/jupyter_notebook_config.py
```
141 changes: 141 additions & 0 deletions README.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
{
"cells": [
{
"cell_type": "markdown",
"id": "directed-subsection",
"metadata": {},
"source": [
"# [Jupyter Go Rust](https://jupyters.vercel.app/)\n",
"\n",
"![version](https://img.shields.io/badge/Date-2022_05_02-da282a) [![Docker Automated Build](https://img.shields.io/docker/automated/xrsec/jupyter?label=Build&logo=docker&style=flat-square)](https://hub.docker.com/r/xrsec/jupyter) [![Jupyter Docker Build](https://github.com/XRSec/Jupyter/actions/workflows/jupyter.yml/badge.svg)](https://github.com/XRSec/Jupyter/actions/workflows/jupyter.yml) [![version](https://img.shields.io/badge/From-google/evcxr-da282a)](https://github.com/google/evcxr)\n",
"\n",
"- use [google/evcxr](https://github.com/google/evcxr)\n",
"- use [gopherdata/gophernotes](https://github.com/gopherdata/gophernotes)\n",
"- use [ohmyzsh](https://gist.github.com/XRSec/0e47c9b793887d201bab9de2a07a740c)\n",
"\n",
"## Run\n",
"\n",
"```bash\n",
"# GET FILE\n",
"## AliYun: registry.cn-hangzhou.aliyuncs.com/xrsec/jupyter:latest\n",
"docker run -it -d --name jupyter --rm xrsec/jupyter:latest\n",
"docker cp jupyter:/root/notebook /docker/jupyter\n",
"docker stop jupyter\n",
"\n",
"# RUN\n",
"\n",
"docker run -it -d \\\n",
" --restart=always \\\n",
" --name jupyter \\\n",
" -v \"/docker/jupyter:/root/notebook\" \\\n",
" -p 8888:8888 \\\n",
" xrsec/jupyter\n",
"\n",
"# Get Tocken\n",
"docker logs jupyter\n",
"# Ather Setting\n",
"## jupyter => new => terminals\n",
"cp /root/.jupyter/jupyter_notebook_config.py /root/notebook/jupyter_notebook_config.py\n",
"## Edit & Save\n",
"cp -rf /root/notebook/jupyter_notebook_config.py /root/.jupyter/jupyter_notebook_config.py\n",
"```"
]
},
{
"cell_type": "markdown",
"id": "comparative-member",
"metadata": {},
"source": [
"## Play Game"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "optimum-dominant",
"metadata": {
"scrolled": true,
"vscode": {
"languageId": "rust"
}
},
"outputs": [],
"source": [
"# 服务切换 Python 运行自定义命令\n",
"!which pip3\n",
"!pip3 install requests"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "strategic-application",
"metadata": {
"vscode": {
"languageId": "rust"
}
},
"outputs": [],
"source": [
"import requests\n",
"requests.get(\"https://www.baidu.com\").text"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "regulated-riverside",
"metadata": {
"vscode": {
"languageId": "rust"
}
},
"outputs": [],
"source": [
"// 服务切换 Rust 运行自定义命令\n",
"println!(\"Hello Jupyter Book!\");\n",
"println!(\"作者刚开始学习Rust,所以只会 println!\");"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "viral-print",
"metadata": {
"vscode": {
"languageId": "shellscript"
}
},
"outputs": [],
"source": [
"!curl ip.cip.cc"
]
},
{
"cell_type": "markdown",
"id": "62f45ed7",
"metadata": {},
"source": [
"## Jupyter LAB\n",
"URL: http://localhost:8888/lab"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Rust",
"language": "rust",
"name": "rust"
},
"language_info": {
"codemirror_mode": "rust",
"file_extension": ".rs",
"mimetype": "text/rust",
"name": "Rust",
"pygment_lexer": "rust",
"version": ""
}
},
"nbformat": 4,
"nbformat_minor": 5
}

1 comment on commit 833f4d1

@vercel
Copy link

@vercel vercel bot commented on 833f4d1 May 4, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

jupyter – ./

jupyter-xr-sec.vercel.app
jupyters.vercel.app
jupyter-git-main-xr-sec.vercel.app

Please sign in to comment.