Skip to content

Commit

Permalink
Merge pull request #154 from nmfs-opensci/eeholmes-patch-1
Browse files Browse the repository at this point in the history
add install vscode extensions
  • Loading branch information
eeholmes authored Nov 7, 2024
2 parents 6eef7eb + 7c93c9b commit 0a642ee
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 6 deletions.
10 changes: 10 additions & 0 deletions appendix
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
LABEL org.opencontainers.image.maintainers="[email protected]"
LABEL org.opencontainers.image.author="[email protected]"
LABEL org.opencontainers.image.source=https://github.com/nmfs-opensci/py-rocket-base
LABEL org.opencontainers.image.description="JupyterHub image with Python 3.11 and Tidyverse based R 4.4 and RStudio"
LABEL org.opencontainers.image.licenses=Apache2.0
LABEL org.opencontainers.image.version=2024.11.06

USER root

# Clean up extra files in ${REPO_DIR}
Expand Down Expand Up @@ -48,6 +55,9 @@ RUN mkdir -p /pyrocket_scripts && cp -r ${REPO_DIR}/scripts/* /pyrocket_scripts/
RUN chown -R root:staff /pyrocket_scripts && \
chmod -R 775 /pyrocket_scripts

# Some basic VS Code extensions
RUN /pyrocket_scripts/install-vscode-ext.sh ${REPO_DIR}/vscode-extensions.txt

# Convert NB_USER to ENV (from ARG) so that it passes to the child dockerfile
ENV NB_USER=${NB_USER}

Expand Down
37 changes: 37 additions & 0 deletions scripts/install-vscode-extensions.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#!/bin/bash

# Install VSCode extensions.
# These get installed to $CONDA_PREFIX/envs/notebook/share/code-server/extensions/

# Check if a filename argument is provided
if [ -z "$1" ]; then
echo "Error: install-vscode-extensions.sh requires an input file of extension names (typically called vscode-extensions.txt)." >&2
echo "Usage: RUN /pyrocket_scripts/install-vscode-extensions.sh <filename>"
exit 1
fi

# Check the user and output which user the script is running as
if [[ $(id -u) -eq 0 ]]; then
echo "Running install-vscode-extensions.sh as root."
else
echo "Running install-vscode-extensions.sh as ${NB_USER}."
fi

ext_file="$1"

# Verify that ext_file exists and is a file
if [ ! -f "${ext_file}" ]; then
echo " Error: Specified file '$ext_file' does not exist."
exit 1
fi

# Install each extension listed in the file
while IFS= read -r EXT; do
if code-server --install-extension "$EXT"; then
echo " Successfully installed extension: $EXT"
else
echo " Failed to install extension: $EXT" >&2
fi
done < "$ext_file"

echo " Success! install-vscode-extensions.sh"
13 changes: 7 additions & 6 deletions scripts/run-postbuild.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,19 @@ fi
# Set SCRIPT_FILE to the provided argument
SCRIPT_FILE="$1"

# Check the user and output which user the script is running as
if [[ $(id -u) -eq 0 ]]; then
echo "Running run-postbuild.sh as root."
else
echo "Running run-postbuild.sh as ${NB_USER}."
fi

# Verify that SCRIPT_FILE exists and is a file
if [ ! -f "${SCRIPT_FILE}" ]; then
echo " Error: Specified script file '${SCRIPT_FILE}' does not exist."
exit 1
fi

# Check the user and output which user the script is running as
if [[ $(id -u) -eq 0 ]]; then
echo " Running run-postbuild.sh as root."
else
echo " Running run-postbuild.sh as ${NB_USER}."
fi

# Make the script executable and run it
chmod +x "${SCRIPT_FILE}"
Expand Down
3 changes: 3 additions & 0 deletions vscode-extensions.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
ms-python.python
ms-toolsai.jupyter
quarto.quarto

0 comments on commit 0a642ee

Please sign in to comment.