Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
[submodule "test/bats"]
path = test/bats
url = https://github.com/bats-core/bats-core.git
branch = master
[submodule "test/test_helper/bats-support"]
path = test/test_helper/bats-support
url = https://github.com/bats-core/bats-support.git
branch = master
[submodule "test/test_helper/bats-assert"]
path = test/test_helper/bats-assert
url = https://github.com/bats-core/bats-assert.git
branch = master

15 changes: 15 additions & 0 deletions devcontainers/conda-jupyter-node/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Conda Juptyer Node
*
```bash
cd devcontainers/conda-jupyter-node
code devcontainers/conda-jupyter-node
```
```bash
docker compose -f ./docker/docker-compose.yml up -d # detached
docker compose -f ./docker/docker-compose.yml up -d --build #

docker compose -f ./docker/docker-compose.yml start
docker compose -f ./docker/docker-compose.yml attach webapp # will kill if exit

docker compose -f ./docker/docker-compose.yml exec webapp /bin/zsh
```
39 changes: 39 additions & 0 deletions devcontainers/conda-jupyter-node/docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
FROM debian:bookworm-slim
# https://docs.docker.com/reference/dockerfile/

# known dependencies: curl
# dev dependencies: zsh tree tldr git wget
# omz: git ca-certificates procps (ps)
RUN apt-get update && apt-get install -y \
curl \
zsh tree wget git ca-certificates procps tar bzip2 \
&& rm -rf /var/lib/apt/lists/*
# rm -rf /var/lib/apt/lists/* is to clean up after apt-get
# maybe add tmux etc. only

# assume mounted docker to /webapp using compose
SHELL ["/bin/bash", "-c"]

# won't actually mount anything. it's for documentation
VOLUME ["/webapp"]
WORKDIR /webapp
# COPY . /webapp
# using compose to mount
# copy lib over for zsh? or nah
# default port for jupterlab
EXPOSE 8888

HEALTHCHECK --interval=5m --timeout=3s \
CMD set -euxo pipefail; printenv SHELL | grep -i zsh ; \
curl -f http://localhost:8888/ || exit 1

# entrypoint if mounting using compose has to be in compose
# ENTRYPOINT [ "./entrypoints/smoke-tests.sh" ]
# cmd is also overided by compose since entrypoint was declared there
SHELL ["/bin/zsh", "-c"]
ENV SHELL=/usr/bin/zsh
ENV LANG=en_CA.UTF-8
ENV TERM=xterm-256color
COPY ./lib/*.sh ./lib/
RUN set -x ; chsh -s $(which zsh) && ./lib/readme_zsh_plugin_copy.md.sh
CMD /bin/zsh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Docker Compose for mounting volumes during build
version: "3.8"
services:
webapp:
# entrypoint: ./entrypoints/smoke-tests.sh # defn worked
entrypoint: ./entrypoints/labs/conda-micromamba.sh


# ports is it annray... gest appendd
# ports:
# - "8888:8888"
26 changes: 26 additions & 0 deletions devcontainers/conda-jupyter-node/docker/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Docker Compose for mounting volumes during build
version: "3.8"
name: conda-jupyter-node
# i guess proper name would be conda-node-jupyter so
# compose would auto append
services:
webapp:
# comment out to skip build
# called docker-webapp for some reason
container_name: jupyter-webapp
hostname: jupyter-webapp
# for dev: maybe should add a dev env file
stdin_open: true # docker run -i. needed until a service is running
tty: true # docker run -t. instead of bash... cuz bash is not a service

build:
context: .
dockerfile: ./Dockerfile
entrypoint: ./entrypoints/smoke-tests.sh # defn worked
command: /bin/zsh # since entrypoint is defined
# image: jchan48h/conda-jupyter-node
volumes:
- .:/webapp

ports:
- "8888:8888"
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/usr/bin/env bash
## note entry points run everytime the container starts
set -euxo pipefail
USER=${USERNAME:-root}
cat /etc/os-release | grep ID # ID=debian
printenv | grep -i home
getent passwd $USER | head -n 1 | cut -d: -f7 # check which is the default shell
getent passwd $USER | head -n 1 | cut -d: -f7 | grep -i zsh
printenv SHELL | grep -i zsh


exec "$@"
17 changes: 17 additions & 0 deletions devcontainers/conda-jupyter-node/docker/entrypoints/smoke-tests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/usr/bin/env bash
## note entry points run everytime the container starts
set -euxo pipefail
# LOGNAME=root
# USER=${USERNAME:LOGNAME:-root}
USER=${USERNAME:-root}
# USER=${LOGNAM:-root}
cat /etc/os-release | grep ID # ID=debian
printenv | grep -i home
getent passwd $USER | head -n 1 | cut -d: -f7 # check which is the default shell
getent passwd $USER | head -n 1 | cut -d: -f7 | grep -i zsh
printenv SHELL | grep -i zsh
# doesn't need to be bash even
# using healthcheck as well
# lib/readme_zsh_plugin_copy.md.sh

exec "$@"
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
#!/usr/bin/env zsh
set -euxo pipefail

# copied
# Checks if packages are installed and installs them if not
check_packages() {
if ! dpkg -s "$@" >/dev/null 2>&1; then
if [ "$(find /var/lib/apt/lists/* | wc -l)" = "0" ]; then
echo "Running apt-get update..."
apt-get update -y
fi
apt-get -y install --no-install-recommends "$@"
fi
}

cd $HOME
# mkdir -p $HOME/bin
# curl -Ls https://micro.mamba.pm/api/micromamba/linux-64/latest
# https://mamba.readthedocs.io/en/latest/installation/micromamba-installation.html#linux-and-macos
# apt update # needed bzip2
# apt install -y bzip2
curl -Ls https://micro.mamba.pm/api/micromamba/linux-64/latest | tar -xvj bin/micromamba
# curl -Ls https://micro.mamba.pm/api/micromamba/linux-64/latest | tar -xvj -C bin/micromamba
eval "$(./bin/micromamba shell hook -s posix)"
# assuming zsh... should maybe should change that
./bin/micromamba shell init -s zsh -p ~/micromamba
source ~/.zshrc
alias conda=micromamba

# set default
micromamba config append channels conda-forge
micromamba config set channel_priority strict

# this might not work... because it might create a new shell
# right... that's why i think the instructions told us to use the bin
micromamba activate # this activates the base environment
micromamba create -y --name 311 python=3.11 pipx poetry
micromamba activate 311
micromamba create -y --name 312 python=3.12 pipx poetry
micromamba activate 312

pipx install pipx
pipx ensurepath
pipx completion

conda install -y jupyterlab nodejs

# conda env export --no-prefix > environment.yml
# conda env export > environment.yml
# conda env export
conda env export --from-history
# node --version
# this is going to take a bit of time to try...

# should check if it set
exit 0
/webapp/tests/smoke-test-0.sh
./lib/readme_micromamba_conda_install.md.zsh
###### jupyter lab --no-browser
jupyter lab
jupyter lab --no-browser
jupyter lab --no-browser --allow-root


# figure out later
# jupyter lab --no-browser --allow-root --no-token
jupyter lab --help-all |grep -i token
jupyter lab --help-all |grep -i no
jupyter lab --help-all |grep -i pass
jupyter lab --help-all |grep -i auth

### conda aliased
conda env list
# use port forward
# localhost:8888
# by attaching if forgot
# file:///root/.local/share/jupyter/runtime/jpserver-4201-open.html
103 changes: 103 additions & 0 deletions devcontainers/conda-jupyter-node/docker/lib/readme_zsh_plugin_copy.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
# Useful stuff
* should have the command to download these two files
* and run
* `check_packages`
* it's legit
* it checks the lists before doing apt update
* but it should probably clean up after itself being inside of a docker

## zsh plugins
* https://github.com/zsh-users?q=&type=all&language=&sort=
* omz plugins are here
* plugins are the official ones?
* https://github.com/ohmyzsh/ohmyzsh/wiki/Plugins

# Check Shell
```bash
cat /etc/shells
printenv SHELL
echo $SHELL
getent passwd $USER | cut -d: -f7
getent passwd $USER | cut -d: -f7 | head -n 1 # probably most accurate one
getent passwd $USER |grep -i zsh #aaaa
getent passwd $USER | head -n 1 | cut -d: -f7 # this ? unless it's different shoudl try
# after set
SHELL=/usr/bin/zsh
chsh -s $(which zsh)
chsh -s /usr/bin/zsh
# set -x is to print each command. set +x
set +x
echo chsh -s $(which zsh)
set -x ; chsh -s $(which zsh)
ps -p $$ #
# interesting
# install ps
apt install procps
sudo apt-get update && apt-get install -y procps

# optional installs
# or i should have slim and non slim?
# feels more liek a packer thing here
```

# todo
* [ ] add sudo
* [ ] rsync?

# Schema here
```jsonc
{
"name": "ZSH Plugins",
"id": "zsh-plugins",
"version": "0.0.4",
"description": "Install (Oh-My-)ZSH plugins",
"documentationURL": "http://github.com/devcontainers-contrib/features/tree/main/src/zsh-plugins",
"installsAfter": [
"ghcr.io/devcontainers/features/common-utils",
"ghcr.io/devcontainers/features/git"
],
"options": {
"plugins": {
"type": "string",
"default": "",
"proposals": [
"ssh-agent npm"
],
"description": "Space separated list of ZSH plugin names that will be added to .zshrc"
},
"omzPlugins": {
"type": "string",
"default": "",
"proposals": [
"https://github.com/zsh-users/zsh-autosuggestions"
],
"description": "Space separated list of Oh-My-ZSH custom plugin Git URLs that will be cloned"
},
"username": {
"type": "string",
"default": "",
"proposals": [
"root",
"node",
"vscode"
],
"description": "For which user to setup ZSH plugins, by default uses 'remoteUser' or 'containerUser' from config"
}
}
}
```
```bash
#!/usr/bin/env bash
# my install and experiment
# check envs
printenv USERNAME
printenv $_REMOTE_USER
printenv _REMOTE_USER
printenv USER
echo $USER

export USERNAME=${USERNAME:-root}
printenv USERNAME
unset USERNAME

```
Loading