add jupyter notebook (#59)
This commit is contained in:
committed by
GitHub
parent
d9d646098e
commit
5e805fef02
BIN
.images/jupyter-notebook.png
Normal file
BIN
.images/jupyter-notebook.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 654 KiB |
@@ -1,7 +1,7 @@
|
||||
#!/usr/bin/env sh
|
||||
|
||||
BOLD='\033[0;1m'
|
||||
echo "$${BOLD}Installing MODULE_NAME..."
|
||||
printf "$${BOLD}Installing MODULE_NAME..."
|
||||
# Add code here
|
||||
# Use varibles from the templatefile function in main.tf
|
||||
# e.g. LOG_PATH, PORT, etc.
|
||||
|
||||
@@ -41,9 +41,9 @@ done
|
||||
if [ ! -f ~/.local/share/code-server/Machine/settings.json ]; then
|
||||
echo "⚙️ Creating settings file..."
|
||||
mkdir -p ~/.local/share/code-server/Machine
|
||||
echo "${SETTINGS}" > ~/.local/share/code-server/Machine/settings.json
|
||||
echo "${SETTINGS}" >~/.local/share/code-server/Machine/settings.json
|
||||
fi
|
||||
|
||||
echo "👷 Running code-server in the background..."
|
||||
echo "Check logs at ${LOG_PATH}!"
|
||||
$CODE_SERVER --auth none --port ${PORT} >${LOG_PATH} 2>&1 &
|
||||
$CODE_SERVER --auth none --port ${PORT} >${LOG_PATH} 2>&1 &
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#!/usr/bin/env sh
|
||||
|
||||
BOLD='\033[0;1m'
|
||||
echo "$${BOLD}Installing filebrowser \n\n"
|
||||
printf "$${BOLD}Installing filebrowser \n\n"
|
||||
|
||||
curl -fsSL https://raw.githubusercontent.com/filebrowser/get/master/get.sh | bash
|
||||
|
||||
|
||||
10
jfrog/run.sh
10
jfrog/run.sh
@@ -1,7 +1,7 @@
|
||||
#!/usr/bin/env sh
|
||||
|
||||
BOLD='\033[0;1m'
|
||||
echo "$${BOLD}Installing JFrog CLI..."
|
||||
printf "$${BOLD}Installing JFrog CLI..."
|
||||
|
||||
# Install the JFrog CLI.
|
||||
curl -fL https://install-cli.jfrog.io | sudo sh
|
||||
@@ -20,11 +20,11 @@ if [ -z "${REPOSITORY_NPM}" ]; then
|
||||
else
|
||||
echo "📦 Configuring npm..."
|
||||
jf npmc --global --repo-resolve "${JFROG_URL}/artifactory/api/npm/${REPOSITORY_NPM}"
|
||||
cat << EOF > ~/.npmrc
|
||||
cat <<EOF >~/.npmrc
|
||||
email = ${ARTIFACTORY_USERNAME}
|
||||
registry = ${JFROG_URL}/artifactory/api/npm/${REPOSITORY_NPM}
|
||||
EOF
|
||||
jf rt curl /api/npm/auth >> ~/.npmrc
|
||||
jf rt curl /api/npm/auth >>~/.npmrc
|
||||
fi
|
||||
|
||||
# Configure the `pip` to use the Artifactory "python" repository.
|
||||
@@ -33,7 +33,7 @@ if [ -z "${REPOSITORY_PYPI}" ]; then
|
||||
else
|
||||
echo "🐍 Configuring pip..."
|
||||
mkdir -p ~/.pip
|
||||
cat << EOF > ~/.pip/pip.conf
|
||||
cat <<EOF >~/.pip/pip.conf
|
||||
[global]
|
||||
index-url = https://${ARTIFACTORY_USERNAME}:${ARTIFACTORY_ACCESS_TOKEN}@${JFROG_HOST}/artifactory/api/pypi/${REPOSITORY_PYPI}/simple
|
||||
EOF
|
||||
@@ -46,4 +46,4 @@ else
|
||||
echo "🐹 Configuring go..."
|
||||
export GOPROXY="https://${ARTIFACTORY_USERNAME}:${ARTIFACTORY_ACCESS_TOKEN}@${JFROG_HOST}/artifactory/api/go/${REPOSITORY_GO}"
|
||||
fi
|
||||
echo "🥳 Configuration complete!"
|
||||
echo "🥳 Configuration complete!"
|
||||
|
||||
21
jupyter-notebook/README.md
Normal file
21
jupyter-notebook/README.md
Normal file
@@ -0,0 +1,21 @@
|
||||
---
|
||||
display_name: Jupyter Notebook
|
||||
description: A module that adds Jupyter Notebook in your Coder template.
|
||||
icon: ../.icons/jupyter.svg
|
||||
maintainer_github: coder
|
||||
verified: true
|
||||
tags: [jupyter, helper, ide, web]
|
||||
---
|
||||
|
||||
# Jupyter Notebook
|
||||
|
||||
A module that adds Jupyter Notebook in your Coder template.
|
||||
|
||||

|
||||
|
||||
```hcl
|
||||
module "jupyter-notebook" {
|
||||
source = "https://registry.coder.com/modules/jupyter-notebook"
|
||||
agent_id = coder_agent.example.id
|
||||
}
|
||||
```
|
||||
49
jupyter-notebook/main.tf
Normal file
49
jupyter-notebook/main.tf
Normal file
@@ -0,0 +1,49 @@
|
||||
terraform {
|
||||
required_version = ">= 1.0"
|
||||
|
||||
required_providers {
|
||||
coder = {
|
||||
source = "coder/coder"
|
||||
version = ">= 0.12"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# Add required variables for your modules and remove any unneeded variables
|
||||
variable "agent_id" {
|
||||
type = string
|
||||
description = "The ID of a Coder agent."
|
||||
}
|
||||
|
||||
variable "log_path" {
|
||||
type = string
|
||||
description = "The path to log jupyter notebook to."
|
||||
default = "/tmp/jupyter-notebook.log"
|
||||
}
|
||||
|
||||
variable "port" {
|
||||
type = number
|
||||
description = "The port to run jupyter-notebook on."
|
||||
default = 19999
|
||||
}
|
||||
|
||||
resource "coder_script" "jupyter-notebook" {
|
||||
agent_id = var.agent_id
|
||||
display_name = "jupyter-notebook"
|
||||
icon = "/icon/jupyter.svg"
|
||||
script = templatefile("${path.module}/run.sh", {
|
||||
LOG_PATH : var.log_path,
|
||||
PORT : var.port
|
||||
})
|
||||
run_on_start = true
|
||||
}
|
||||
|
||||
resource "coder_app" "jupyter-notebook" {
|
||||
agent_id = var.agent_id
|
||||
slug = "jupyter-notebook"
|
||||
display_name = "Jupyter Notebook"
|
||||
url = "http://localhost:${var.port}"
|
||||
icon = "/icon/jupyter.svg"
|
||||
subdomain = true
|
||||
share = "owner"
|
||||
}
|
||||
25
jupyter-notebook/run.sh
Executable file
25
jupyter-notebook/run.sh
Executable file
@@ -0,0 +1,25 @@
|
||||
#!/usr/bin/env sh
|
||||
|
||||
BOLD='\033[0;1m'
|
||||
|
||||
printf "$${BOLD}Installing jupyter-notebook!\n"
|
||||
|
||||
# check if jupyter-notebook is installed
|
||||
if ! command -v jupyter-notebook >/dev/null 2>&1; then
|
||||
# install jupyter-notebook
|
||||
# check if python3 pip is installed
|
||||
if ! command -v pip3 >/dev/null 2>&1; then
|
||||
echo "pip3 is not installed"
|
||||
echo "Please install pip3 in your Dockerfile/VM image before running this script"
|
||||
exit 1
|
||||
fi
|
||||
# install jupyter-notebook
|
||||
pip3 install --upgrade --no-cache-dir --no-warn-script-location jupyter
|
||||
echo "🥳 jupyter-notebook has been installed\n\n"
|
||||
else
|
||||
echo "🥳 jupyter-notebook is already installed\n\n"
|
||||
fi
|
||||
|
||||
echo "👷 Starting jupyter-notebook in background..."
|
||||
echo "check logs at ${LOG_PATH}"
|
||||
$HOME/.local/bin/jupyter notebook --NotebookApp.ip='0.0.0.0' --ServerApp.port=${PORT} --no-browser --ServerApp.token='' --ServerApp.password='' >${LOG_PATH} 2>&1 &
|
||||
@@ -2,13 +2,13 @@
|
||||
|
||||
BOLD='\033[0;1m'
|
||||
|
||||
echo "$${BOLD}Installing jupyterlab!\n"
|
||||
printf "$${BOLD}Installing jupyterlab!\n"
|
||||
|
||||
# check if jupyterlab is installed
|
||||
if ! command -v jupyterlab > /dev/null 2>&1; then
|
||||
if ! command -v jupyterlab >/dev/null 2>&1; then
|
||||
# install jupyterlab
|
||||
# check if python3 pip is installed
|
||||
if ! command -v pip3 > /dev/null 2>&1; then
|
||||
if ! command -v pip3 >/dev/null 2>&1; then
|
||||
echo "pip3 is not installed"
|
||||
echo "Please install pip3 in your Dockerfile/VM image before running this script"
|
||||
exit 1
|
||||
@@ -22,4 +22,4 @@ fi
|
||||
|
||||
echo "👷 Starting jupyterlab in background..."
|
||||
echo "check logs at ${LOG_PATH}"
|
||||
$HOME/.local/bin/jupyter lab --ServerApp.ip='0.0.0.0' --ServerApp.port=${PORT} --no-browser --ServerApp.token='' --ServerApp.password='' >${LOG_PATH} 2>&1 &
|
||||
$HOME/.local/bin/jupyter lab --ServerApp.ip='0.0.0.0' --ServerApp.port=${PORT} --no-browser --ServerApp.token='' --ServerApp.password='' >${LOG_PATH} 2>&1 &
|
||||
|
||||
Reference in New Issue
Block a user