Skip to content

Commit

Permalink
major clean-up
Browse files Browse the repository at this point in the history
* move the dev images into draft_images
* create all the devcontainer files
  • Loading branch information
eeholmes committed Jun 4, 2024
1 parent eb85b30 commit e5b4b0b
Show file tree
Hide file tree
Showing 48 changed files with 319 additions and 165 deletions.
23 changes: 21 additions & 2 deletions .devcontainer/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,24 @@ Some notes regarding working with the nmfs-opensci jupyter lab images in codespa

Many of these images include the RStudio server and jupyter-rsession-proxy. There are a number of oddies that occur when launching the RStudio server (via the button in JupyterLab)

* When a Dockerfile and `"build":` or docker compose is used, the PWD is changed to `/workspaces/<reponame>` in the terminal tab of RStudio. If the image is used as-is with `"image": ` in the devcontainer.json file, this does not happen.
* In the images, port 8888 is exposed. If `jupyter lab --ip=0.0.0.0 --port=8888 --allow-root --no-browser` is used to start Jupyter Lab, then RStudio will not launch. There is some weird re-directing of the url. Instead use
* In RStudio, the PWD is changed to `/workspaces/<reponame>` in the terminal tab of RStudio. If the image is used as-is with `"image": ` in the devcontainer.json file, this does not happen. https://github.com/jupyterhub/jupyter-rsession-proxy/issues/145. This terminal is opened with `bash --login` so this tells it to use the right PWD `echo PWD=/home/jovyan\ncd $PWD >> ~/.bash_login`
* In the images, port 8888 is exposed. If `jupyter lab --ip=0.0.0.0 --port=8888 --allow-root --no-browser` is used to start Jupyter Lab, then RStudio will not launch. There is some weird re-directing of the url. Instead use a different port. I use 8889

Other oddities.

* Rebuilding the devcontainer from a running devcontainer doesn't work because because the working directory is /home/jovyan and that does not have a devcontainer.json file.
* If a README.md file is in the working directory (set to /home/jovyan), then that is displayed automatically with preview. If a README.md file is created and opened with
```
"customizations": {
"codespaces": {
"openFiles": [ "README.md" ],
},
"vscode": {
"settings": {
"workbench.editorAssociations": { "*.md": "vscode.markdown.preview.editor", },
},
}
},
```
it will open in the editor not preview. My solution is to create a README.md in \home\jovyan after the container is started.

21 changes: 21 additions & 0 deletions .devcontainer/aomlomics-jh/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"name": "aomlomics-jh",
"workspaceFolder": "/home/jovyan",
"image": "ghcr.io/nmfs-opensci/container-images/aomlomics-jh:latest",

// Ports to be forwarded from the container to the host
"forwardPorts": [8889],
"portsAttributes": {
"8889": {
"label": "Jupyter Lab",
"onAutoForward": "notify"
}
},

// Create a README that is automatically opened in preview mode
// the echo bit is to fix pwd in bash terminal in RStudio
"postCreateCommand": "echo '[![](https://img.shields.io/badge/Open%20Jupyter%20Lab-37a779?style=for-the-badge)](https://''-8889.app.github.dev)' > README.md && echo PWD=/home/jovyan\ncd /Users/eli.holmes/Documents/GitHub/container-images >> ~/.bash_login",

// Start Jupyter Lab
"postStartCommand": "jupyter lab --ip=0.0.0.0 --port=8889 --allow-root --no-browser --notebook-dir=/home/jovyan --NotebookApp.token='' --NotebookApp.password=''",
}
21 changes: 21 additions & 0 deletions .devcontainer/arcgis/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"name": "arcgis",
"workspaceFolder": "/home/jovyan",
"image": "ghcr.io/nmfs-opensci/container-images/arcgis:latest",

// Ports to be forwarded from the container to the host
"forwardPorts": [8889],
"portsAttributes": {
"8889": {
"label": "Jupyter Lab",
"onAutoForward": "notify"
}
},

// Create a README that is automatically opened in preview mode
// the echo bit is to fix pwd in bash terminal in RStudio
"postCreateCommand": "echo '[![](https://img.shields.io/badge/Open%20Jupyter%20Lab-37a779?style=for-the-badge)](https://''-8889.app.github.dev)' > README.md && echo PWD=/home/jovyan\ncd /Users/eli.holmes/Documents/GitHub/container-images >> ~/.bash_login",

// Start Jupyter Lab
"postStartCommand": "jupyter lab --ip=0.0.0.0 --port=8889 --allow-root --no-browser --notebook-dir=/home/jovyan --NotebookApp.token='' --NotebookApp.password=''",
}
21 changes: 21 additions & 0 deletions .devcontainer/cmip6-cookbook/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"name": "cmip6-cookbook",
"workspaceFolder": "/home/jovyan",
"image": "ghcr.io/nmfs-opensci/container-images/cmip6-cookbook:latest",

// Ports to be forwarded from the container to the host
"forwardPorts": [8889],
"portsAttributes": {
"8889": {
"label": "Jupyter Lab",
"onAutoForward": "notify"
}
},

// Create a README that is automatically opened in preview mode
// the echo bit is to fix pwd in bash terminal in RStudio
"postCreateCommand": "echo '[![](https://img.shields.io/badge/Open%20Jupyter%20Lab-37a779?style=for-the-badge)](https://''-8889.app.github.dev)' > README.md && echo PWD=/home/jovyan\ncd /Users/eli.holmes/Documents/GitHub/container-images >> ~/.bash_login",

// Start Jupyter Lab
"postStartCommand": "jupyter lab --ip=0.0.0.0 --port=8889 --allow-root --no-browser --notebook-dir=/home/jovyan --NotebookApp.token='' --NotebookApp.password=''",
}
21 changes: 21 additions & 0 deletions .devcontainer/coastwatch/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"name": "coastwatch",
"workspaceFolder": "/home/jovyan",
"image": "ghcr.io/nmfs-opensci/container-images/coastwatch:latest",

// Ports to be forwarded from the container to the host
"forwardPorts": [8889],
"portsAttributes": {
"8889": {
"label": "Jupyter Lab",
"onAutoForward": "notify"
}
},

// Create a README that is automatically opened in preview mode
// the echo bit is to fix pwd in bash terminal in RStudio
"postCreateCommand": "echo '[![](https://img.shields.io/badge/Open%20Jupyter%20Lab-37a779?style=for-the-badge)](https://''-8889.app.github.dev)' > README.md && echo PWD=/home/jovyan\ncd /Users/eli.holmes/Documents/GitHub/container-images >> ~/.bash_login",

// Start Jupyter Lab
"postStartCommand": "jupyter lab --ip=0.0.0.0 --port=8889 --allow-root --no-browser --notebook-dir=/home/jovyan --NotebookApp.token='' --NotebookApp.password=''",
}
26 changes: 26 additions & 0 deletions .devcontainer/codespace/devcontainer_template.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/bin/bash

# Construct the message
message="{
\"name\": \"$1\",
\"workspaceFolder\": \"/home/jovyan\",
\"image\": \"ghcr.io/nmfs-opensci/container-images/$1:latest\",
// Ports to be forwarded from the container to the host
\"forwardPorts\": [8889],
\"portsAttributes\": {
\"8889\": {
\"label\": \"Jupyter Lab\",
\"onAutoForward\": \"notify\"
}
},
// Create a README that is automatically opened in preview mode
// the echo bit is to fix pwd in bash terminal in RStudio
\"postCreateCommand\": \"echo '[![](https://img.shields.io/badge/Open%20Jupyter%20Lab-37a779?style=for-the-badge)](https://'${CODESPACE_NAME}'-8889.app.github.dev)' > README.md && echo PWD=/home/jovyan\ncd $PWD >> ~/.bash_login\",
// Start Jupyter Lab
\"postStartCommand\": \"jupyter lab --ip=0.0.0.0 --port=8889 --allow-root --no-browser --notebook-dir=/home/jovyan --NotebookApp.token='' --NotebookApp.password=''\",
}"

echo "$message" > ./.devcontainer/$1/devcontainer.json
15 changes: 15 additions & 0 deletions .devcontainer/codespace/make_devcontainers.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/bash

# cd .devcontainer/codespace
# chmod +x ./make_devcontainers.sh
# ./.devcontainer/codespace/make_devcontainers.sh
a=$(Rscript -e 'cat(here::here())')
cd $a
chmod +x ./.devcontainer/codespace/devcontainer_template.sh
fils="$(ls ./images)"
for i in $fils
do
echo $i
mkdir ../$i
./.devcontainer/codespace/devcontainer_template.sh $i
done
21 changes: 21 additions & 0 deletions .devcontainer/codespace/test.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"name": "vast",
"workspaceFolder": "/home/jovyan",
"image": "ghcr.io/nmfs-opensci/container-images/vast:latest",

// Ports to be forwarded from the container to the host
"forwardPorts": [8889],
"portsAttributes": {
"8889": {
"label": "Jupyter Lab",
"onAutoForward": "notify"
}
},

// Create a README that is automatically opened in preview mode
// the echo bit is to fix pwd in bash terminal in RStudio
"postCreateCommand": "echo '[![](https://img.shields.io/badge/Open%20Jupyter%20Lab-37a779?style=for-the-badge)](https://''-8889.app.github.dev)' > README.md && echo PWD=/home/jovyan\ncd /Users/eli.holmes/Documents/GitHub/container-images/.devcontainer/codespace >> ~/.bash_login",

// Start Jupyter Lab
"postStartCommand": "jupyter lab --ip=0.0.0.0 --port=8889 --allow-root --no-browser --notebook-dir=/home/jovyan --NotebookApp.token='' --NotebookApp.password=''",
}
8 changes: 8 additions & 0 deletions .devcontainer/codespace/test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/bash

# Construct the message
message="{
\"name\": $1,
\"workspaceFolder\": \"/home/jovyan\",
\"image\": \"ghcr.io/nmfs-opensci/container-images/\"$1\":latest\",
"
21 changes: 21 additions & 0 deletions .devcontainer/echopype/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"name": "echopype",
"workspaceFolder": "/home/jovyan",
"image": "ghcr.io/nmfs-opensci/container-images/echopype:latest",

// Ports to be forwarded from the container to the host
"forwardPorts": [8889],
"portsAttributes": {
"8889": {
"label": "Jupyter Lab",
"onAutoForward": "notify"
}
},

// Create a README that is automatically opened in preview mode
// the echo bit is to fix pwd in bash terminal in RStudio
"postCreateCommand": "echo '[![](https://img.shields.io/badge/Open%20Jupyter%20Lab-37a779?style=for-the-badge)](https://''-8889.app.github.dev)' > README.md && echo PWD=/home/jovyan\ncd /Users/eli.holmes/Documents/GitHub/container-images >> ~/.bash_login",

// Start Jupyter Lab
"postStartCommand": "jupyter lab --ip=0.0.0.0 --port=8889 --allow-root --no-browser --notebook-dir=/home/jovyan --NotebookApp.token='' --NotebookApp.password=''",
}
21 changes: 21 additions & 0 deletions .devcontainer/jupyter-base-notebook/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"name": "jupyter-base-notebook",
"workspaceFolder": "/home/jovyan",
"image": "ghcr.io/nmfs-opensci/container-images/jupyter-base-notebook:latest",

// Ports to be forwarded from the container to the host
"forwardPorts": [8889],
"portsAttributes": {
"8889": {
"label": "Jupyter Lab",
"onAutoForward": "notify"
}
},

// Create a README that is automatically opened in preview mode
// the echo bit is to fix pwd in bash terminal in RStudio
"postCreateCommand": "echo '[![](https://img.shields.io/badge/Open%20Jupyter%20Lab-37a779?style=for-the-badge)](https://''-8889.app.github.dev)' > README.md && echo PWD=/home/jovyan\ncd /Users/eli.holmes/Documents/GitHub/container-images >> ~/.bash_login",

// Start Jupyter Lab
"postStartCommand": "jupyter lab --ip=0.0.0.0 --port=8889 --allow-root --no-browser --notebook-dir=/home/jovyan --NotebookApp.token='' --NotebookApp.password=''",
}
21 changes: 21 additions & 0 deletions .devcontainer/py-geospatial/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"name": "py-geospatial",
"workspaceFolder": "/home/jovyan",
"image": "ghcr.io/nmfs-opensci/container-images/py-geospatial:latest",

// Ports to be forwarded from the container to the host
"forwardPorts": [8889],
"portsAttributes": {
"8889": {
"label": "Jupyter Lab",
"onAutoForward": "notify"
}
},

// Create a README that is automatically opened in preview mode
// the echo bit is to fix pwd in bash terminal in RStudio
"postCreateCommand": "echo '[![](https://img.shields.io/badge/Open%20Jupyter%20Lab-37a779?style=for-the-badge)](https://''-8889.app.github.dev)' > README.md && echo PWD=/home/jovyan\ncd /Users/eli.holmes/Documents/GitHub/container-images >> ~/.bash_login",

// Start Jupyter Lab
"postStartCommand": "jupyter lab --ip=0.0.0.0 --port=8889 --allow-root --no-browser --notebook-dir=/home/jovyan --NotebookApp.token='' --NotebookApp.password=''",
}
46 changes: 10 additions & 36 deletions .devcontainer/py-rocket-base/devcontainer.json
Original file line number Diff line number Diff line change
@@ -1,47 +1,21 @@
{
// Name of the Dev Container
"name": "Py-Rocket Base Codespace",

// Path to the Docker file
"name": "py-rocket-base",
"workspaceFolder": "/home/jovyan",
"image": "ghcr.io/nmfs-opensci/container-images/py-rocket-base:latest",

// Mount a folder with the post_start.sh script to /home/jovyan/codespace
// Don't use /home/jovyan as that would wipe out files there
// We need post_start.sh in our container
"workspaceMount": "source=${localWorkspaceFolder}/.devcontainer/codespace,target=/home/jovyan/codespace,type=bind,consistency=delegated",

// Default workspace folder within the container
"workspaceFolder": "/home/jovyan/codespace",

// Required for Jupyter Lab
"customizations": {
"vscode": {
"extensions": [
"ms-toolsai.jupyter",
"ms-python.python",
]
},
},

// Settings for the VS Code
"settings": {
"terminal.integrated.shell.linux": "/bin/bash",
},

// Ports to be forwarded from the container to the host
"forwardPorts": [8889],

// Attributes for the forwarded ports
"portsAttributes": {
"8889": {
"label": "Jupyter Lab",
"onAutoForward": "openBrowser"
"onAutoForward": "notify"
}
},

// Command to run after the container starts. Runs script to add a link to the Jupyter Lab
"postStartCommand": "chmod +x /home/jovyan/codespace/post_start.sh && /home/jovyan/codespace/post_start.sh && rm /home/jovyan/codespace/post_start.sh && jupyter lab --ip=0.0.0.0 --port=8889 --allow-root --no-browser --NotebookApp.token='' --NotebookApp.password=''",

// List of extensions to be installed
"extensions": []

// Create a README that is automatically opened in preview mode
// the echo bit is to fix pwd in bash terminal in RStudio
"postCreateCommand": "echo '[![](https://img.shields.io/badge/Open%20Jupyter%20Lab-37a779?style=for-the-badge)](https://''-8889.app.github.dev)' > README.md && echo PWD=/home/jovyan\ncd /Users/eli.holmes/Documents/GitHub/container-images >> ~/.bash_login",

// Start Jupyter Lab
"postStartCommand": "jupyter lab --ip=0.0.0.0 --port=8889 --allow-root --no-browser --notebook-dir=/home/jovyan --NotebookApp.token='' --NotebookApp.password=''",
}
43 changes: 10 additions & 33 deletions .devcontainer/py-rocket-geospatial/devcontainer.json
Original file line number Diff line number Diff line change
@@ -1,44 +1,21 @@
{
// Name of the Dev Container
"name": "Py-Rocket Geospatial Codespace",

// Path to the Docker file
"name": "py-rocket-geospatial",
"workspaceFolder": "/home/jovyan",
"image": "ghcr.io/nmfs-opensci/container-images/py-rocket-geospatial:latest",

"workspaceMount": "source=${localWorkspaceFolder}/.devcontainer/codespace,target=/home/jovyan/codespace,type=bind,consistency=delegated",

// Default workspace folder within the container
"workspaceFolder": "/home/jovyan/codespace",

// Required for Jupyter Lab
"customizations": {
"vscode": {
"extensions": [
"ms-toolsai.jupyter",
"ms-python.python",
]
}
},

// Settings for the integrated terminal
"settings": {
"terminal.integrated.shell.linux": "/bin/bash"
},

// Ports to be forwarded from the container to the host
"forwardPorts": [8889],

// Attributes for the forwarded ports
"portsAttributes": {
"8889": {
"label": "Jupyter Lab",
"onAutoForward": "openPreview"
"onAutoForward": "notify"
}
},

// Command to run after the container starts. Runs script to add a link to the RStudio
"postStartCommand": "chmod +x /home/jovyan/codespace/post_start.sh && /home/jovyan/codespace/post_start.sh && rm /home/jovyan/codespace/post_start.sh",

// List of extensions to be installed
"extensions": []

// Create a README that is automatically opened in preview mode
// the echo bit is to fix pwd in bash terminal in RStudio
"postCreateCommand": "echo '[![](https://img.shields.io/badge/Open%20Jupyter%20Lab-37a779?style=for-the-badge)](https://''-8889.app.github.dev)' > README.md && echo PWD=/home/jovyan\ncd /Users/eli.holmes/Documents/GitHub/container-images >> ~/.bash_login",

// Start Jupyter Lab
"postStartCommand": "jupyter lab --ip=0.0.0.0 --port=8889 --allow-root --no-browser --notebook-dir=/home/jovyan --NotebookApp.token='' --NotebookApp.password=''",
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
},

// Create a README that is automatically opened in preview mode
// the echo bit is to fix pwd in bash terminal in RStudio
"postCreateCommand": "echo '[![](https://img.shields.io/badge/Open%20Jupyter%20Lab-37a779?style=for-the-badge)](https://'${CODESPACE_NAME}'-8889.app.github.dev)' > README.md && echo PWD=/home/jovyan\ncd $PWD >> ~/.bash_login",

// Start Jupyter Lab
Expand Down
10 changes: 10 additions & 0 deletions .devcontainer/template_works/junk
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
"customizations": {
"codespaces": {
"openFiles": [ "README.md" ],
},
"vscode": {
"settings": {
"workbench.editorAssociations": { "*.md": "vscode.markdown.preview.editor", },
},
}
},
3 changes: 0 additions & 3 deletions .devcontainer/test2/Dockerfile

This file was deleted.

Loading

0 comments on commit e5b4b0b

Please sign in to comment.