Created
June 27, 2024 08:24
-
-
Save bibstha/9d76f1fdefe9af89626589df5b0a67ed to your computer and use it in GitHub Desktop.
Ruby Jupyter Notebook with persistent gems folder and jupyter token
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
services: | |
jupyter: | |
build: . | |
image: bibstha/datascience-notebook | |
ports: | |
- 80:8888 | |
environment: | |
GEM_HOME: /home/jovyan/.gems | |
RUBYLIB: /home/jovyan/.gems | |
JUPYTER_TOKEN: this-is-my-token | |
volumes: | |
- jupyter-data:/home/jovyan/work | |
- ./gems_cache:/home/jovyan/.gems | |
volumes: | |
jupyter-data: | |
name: jupyter-data | |
# I tried creating a named volume for gems but it was being mounted as root and the user is jovyan (no write permission) | |
# so I did `cd path-to-docker-compose && chown 1000:100 ./gems_cache` | |
# GEM_HOME makes it so that `gem install xyz` will install it to `/home/jovyan/.gems` | |
# RUBYLIB appends the folder to $LOAD_PATH so anything installed on GEM_HOME is loaded properly | |
# I also had to remove the .gemrc as I wanted gems to be installed into GEM_HOME. Therefore the custom Dockerfile below. |
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
FROM rubydata/datascience-notebook | |
RUN rm /home/jovyan/.gemrc |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Put both docker-compose.yml and Dockerfile in a folder.
Run
docker-compose up -d
Then open localhost:80 and enter token
this-is-my-token
. If you get permission error, try changing ports to8080:8080
and loadlocalhost:8080
.