Skip to content

Commit

Permalink
improve build and init scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
robballantyne committed Dec 17, 2023
1 parent 3971e17 commit 30756a7
Show file tree
Hide file tree
Showing 8 changed files with 41 additions and 66 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/docker-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
#- "3.9"
- "3.10"
- "3.11"
#- "3.12"
- "3.12"
#- "all"
steps:
-
Expand Down Expand Up @@ -85,7 +85,7 @@ jobs:
#- "3.9"
- "3.10"
- "3.11"
#- "3.12"
- "3.12"
#- "all"
cuda:
- "11.7.1"
Expand Down Expand Up @@ -161,7 +161,7 @@ jobs:
#- "3.9"
- "3.10"
- "3.11"
#- "3.12"
- "3.12"
#- "all"
rocm:
- "5.4.2"
Expand Down
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -248,9 +248,6 @@ A python kernel will be installed coresponding with the python version(s) of the

Jupyter's official documentation is available at https://jupyter.org/

>[!NOTE]
>_If you have enabled `CF_QUICK_TUNNELS` a secure `https://[random-auto-generated-sub-domain].trycloudflare.com` link will be created. You can find it at `/var/log/supervisor/quicktunnel-jupyter.log`_
### Caddy

This is a simple webserver acting as a reverse proxy.
Expand Down Expand Up @@ -279,6 +276,8 @@ You can also create a private network to enable remote connecions to the contain

If you do not wish to provide a tunnel token, you could enable `CF_QUICK_TUNNELS` which will create a throwaway tunnel for your web services.

Secure links can be found in the [service portal](#service-portal) and in the log files at `/var/log/supervisor/quicktunnel-*.log`.

Full documentation for Cloudflare tunnels is [here](https://developers.cloudflare.com/cloudflare-one/connections/connect-networks/).

>[!NOTE]
Expand Down
7 changes: 1 addition & 6 deletions build/COPY_ROOT/opt/ai-dock/bin/build/layer0/amd.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
#!/bin/bash

# Must exit and fail to build if any command fails
set -eo pipefail
#!/bin/false

# For ROCm specific logic

exit 0
5 changes: 1 addition & 4 deletions build/COPY_ROOT/opt/ai-dock/bin/build/layer0/clean.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
#!/bin/bash

# Must exit and fail to build if any command fails
set -eo pipefail
#!/bin/false

# Tidy up and keep image small
apt-get clean -y
Expand Down
57 changes: 27 additions & 30 deletions build/COPY_ROOT/opt/ai-dock/bin/build/layer0/common.sh
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
#!/bin/bash

# Must exit and fail to build if any command fails
set -eo pipefail
#!/bin/false

source /opt/ai-dock/etc/environment.sh
kernel_path=/usr/local/share/jupyter/kernels/

main() {
install_jupyter
install_ipykernel
build_common_main() {
build_common_install_jupyter
build_common_install_ipykernel
}

install_jupyter() {
$MAMBA_CREATE -n jupyter -c defaults python=3.10
micromamba -n jupyter install -c defaults -y \
build_common_install_jupyter() {
$MAMBA_CREATE -n jupyter python=3.10
$MAMBA_INSTALL -n jupyter \
jupyter \
jupyterlab \
nodejs=18
Expand All @@ -21,13 +19,13 @@ install_jupyter() {
rm -rf /opt/micromamba/envs/jupyter/share/jupyter/kernels/python3
}

do_mamba_install() {
micromamba -n "$1" install -c defaults -y \
build_common_do_mamba_install() {
$MAMBA_INSTALL -n "$1" \
ipykernel \
ipywidgets
}

do_kernel_install() {
build_common_do_kernel_install() {
if [[ -n $4 ]]; then
# Add a clone, probably the often-present Python3 (ipykernel) pointed to our default python install
dir="${kernel_path}${3}/"
Expand All @@ -45,36 +43,35 @@ do_kernel_install() {
sed -i 's/PYTHON_MAMBA_NAME/'"$1"'/g' ${file}
}

install_ipykernel() {
build_common_install_ipykernel() {
if [[ $PYTHON_VERSION != "all" ]]; then
major=${PYTHON_VERSION:0:1}
do_mamba_install "${PYTHON_MAMBA_NAME}"
do_kernel_install "${PYTHON_MAMBA_NAME}" "${PYTHON_VERSION}" "python${major}" "Python${major} (ipykernel)"
build_common_do_mamba_install "${PYTHON_MAMBA_NAME}"
build_common_do_kernel_install "${PYTHON_MAMBA_NAME}" "${PYTHON_VERSION}" "python${major}" "Python${major} (ipykernel)"
else
# Multi Python - Use $PYTHON_MAMBA_NAME as default kernel

do_mamba_install "python_310"
build_common_do_mamba_install "python_310"
if [[ $PYTHON_MAMBA_NAME = "python_310" ]]; then
do_kernel_install "python_310" "3.10" "python3" "Python3 (ipykernel)"
build_common_do_kernel_install "python_310" "3.10" "python3" "Python3 (ipykernel)"
else
do_kernel_install "python_310" "3.10"
build_common_do_kernel_install "python_310" "3.10"
fi

do_mamba_install "python_311"
build_common_do_mamba_install "python_311"
if [[ $PYTHON_MAMBA_NAME = "python_311" ]]; then
do_kernel_install "python_311" "3.11" "python3" "Python3 (ipykernel)"
build_common_do_kernel_install "python_311" "3.11" "python3" "Python3 (ipykernel)"
else
do_kernel_install "python_311" "3.11"
build_common_do_kernel_install "python_311" "3.11"
fi

## Not yet possible with 'defaults' channel
#do_mamba_install "python_312"
#if [[ $PYTHON_MAMBA_NAME = "python_312" ]]; then
# do_kernel_install "python_312" "3.12" "python3" "Python3 (ipykernel)"
#else
# do_kernel_install "python_312" "3.12"
#fi
build_common_do_mamba_install "python_312"
if [[ $PYTHON_MAMBA_NAME = "python_312" ]]; then
build_common_do_kernel_install "python_312" "3.12" "python3" "Python3 (ipykernel)"
else
build_common_do_kernel_install "python_312" "3.12"
fi
fi
}

main "$@"; exit
build_common_main "$@"
7 changes: 1 addition & 6 deletions build/COPY_ROOT/opt/ai-dock/bin/build/layer0/cpu.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
#!/bin/bash

# Must exit and fail to build if any command fails
set -eo pipefail
#!/bin/false

# For CPU specific processes

exit 0
13 changes: 5 additions & 8 deletions build/COPY_ROOT/opt/ai-dock/bin/build/layer0/init.sh
Original file line number Diff line number Diff line change
@@ -1,19 +1,16 @@
#!/bin/bash

# Must exit and fail to build if any command fails
set -eo pipefail

/opt/ai-dock/bin/build/layer0/common.sh
source /opt/ai-dock/bin/build/layer0/common.sh

if [[ "$XPU_TARGET" == "NVIDIA_GPU" ]]; then
/opt/ai-dock/bin/build/layer0/nvidia.sh
source /opt/ai-dock/bin/build/layer0/nvidia.sh
elif [[ "$XPU_TARGET" == "AMD_GPU" ]]; then
/opt/ai-dock/bin/build/layer0/amd.sh
source /opt/ai-dock/bin/build/layer0/amd.sh
elif [[ "$XPU_TARGET" == "CPU" ]]; then
/opt/ai-dock/bin/build/layer0/cpu.sh
source /opt/ai-dock/bin/build/layer0/cpu.sh
else
printf "No valid XPU_TARGET specified\n" >&2
exit 1
fi

/opt/ai-dock/bin/build/layer0/clean.sh
source /opt/ai-dock/bin/build/layer0/clean.sh
7 changes: 1 addition & 6 deletions build/COPY_ROOT/opt/ai-dock/bin/build/layer0/nvidia.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
#!/bin/bash

# Must exit and fail to build if any command fails
set -eo pipefail
#!/bin/false

# For CUDA specific logic

exit 0

0 comments on commit 30756a7

Please sign in to comment.