Last active
February 17, 2022 16:15
-
-
Save 0x1b-xyz/57f55a14d3f47931edf03a0dd56a5e83 to your computer and use it in GitHub Desktop.
Launches the jimmysong btc jupyter notebooks in a container
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# To launch blindly and with great trust: | |
# $ bash <(curl -s https://gist.githubusercontent.com/jason-stiefel/57f55a14d3f47931edf03a0dd56a5e83/raw/btc_jimmysong.sh) | |
# Or pass a command and start a shell if you'd rather skip jupyter launch: | |
# $ bash <(curl -s https://gist.githubusercontent.com/jason-stiefel/57f55a14d3f47931edf03a0dd56a5e83/raw/btc_jimmysong.sh) bash | |
set -euox pipefail | |
mkdir -p ${PWD}/sandbox ${PWD}/cache ${PWD}/local | |
cat << EOD > ./Dockerfile | |
# syntax=docker/dockerfile:1.3-labs | |
FROM ubuntu:20.04 | |
ARG UID=14269 | |
ARG GID=14269 | |
RUN <<EOC | |
apt update | |
apt install -y git python3.8-venv pip | |
EOC | |
RUN useradd jimmysong -m -u \${UID} -G \${GID} | |
USER jimmysong | |
RUN <<EOC | |
cat << EOF >> /home/jimmysong/.bashrc | |
echo "Cloning and installing requirements ..." | |
mkdir -p ~/sandbox | |
cd ~/sandbox && git clone https://github.com/jimmysong/pb-exercises || : && cd pb-exercises | |
pip install -r requirements.txt | |
EOF | |
EOC | |
WORKDIR /home/jimmysong/sandbox/pb-exercises | |
ENV PATH=${PATH}:/home/jimmysong/.local/bin | |
CMD ["/bin/bash", "-ic", "jupyter notebook --ip=0.0.0.0"] | |
EOD | |
DOCKER_BUILDKIT=1 docker build . --build-arg UID=$(id -u) --build-arg GID=$(id -g) -t btc_jimmysong | |
docker run -it --user $(id -u):$(id -g) \ | |
-v ${PWD}/sandbox:/home/jimmysong/sandbox \ | |
-v ${PWD}/cache:/home/jimmysong/.cache \ | |
-v ${PWD}/local:/home/jimmysong/.local \ | |
-p 8888:8888 \ | |
btc_jimmysong $@ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment