Small updates#3
Small updates#3PeterSomkuti wants to merge 4 commits intoUS-GHG-Center:chuckwondo/julia/retrievaltoolkit-dockerfrom
Conversation
Dockerfile
Outdated
| RUN julia -e 'using Pkg; Pkg.add(url="https://github.com/US-GHG-Center/RetrievalToolbox.jl");' | ||
|
|
||
| # Add the demo notebook | ||
| RUN git clone https://github.com/US-GHG-Center/IWGGMS21-Demo ~/IWGGMS21-Demo |
There was a problem hiding this comment.
Recall that we cannot put thing into the home dir. That's part of the issue we're having to deal with. Nothing placed into the home directory shows up in the hub sessions.
Does this demo repo need to be in the home dir? If so, then you simply need to clone it after your initial hub session starts.
Anything you place in your home directory during a hub session will remain in your home directory from session to session. We simply cannot populate the home directory during building of the image.
There was a problem hiding this comment.
The idea for this image is that users at the conference can dig straight in, there should be no additional user commands needed to get into the notebook and execute the cells in the demo.
The location of the repo (I think) is not important; ideally the users thrown into this will see the opened notebook already. I'll investigate.
There was a problem hiding this comment.
@PeterSomkuti we're going to achieve that through Binderhub launch link, not via the docker configuration. The Docker just needs the right environment. If the notebook repo is now public we should move this dockerfile into that repo and test with Binder.
There was a problem hiding this comment.
@wildintellect I can move the Dockerfile (and the additional files needed) to the IWGGMS21-Demo repo. Does the Binder environment keep the AWS credentials as present in the "other" environment? The demo currently pulls the 3 big files from the S3 bucket right at the start.
There was a problem hiding this comment.
Yes bucket access should work.
Dockerfile
Outdated
| RUN <<EOT | ||
| curl -OL https://github.com/cormullion/juliamono/releases/download/v0.060/JuliaMono-ttf.tar.gz | ||
| mkdir ~/.fonts | ||
| cd ~/.fonts | ||
| tar -xvzf ~/JuliaMono-ttf.tar.gz | ||
| rm ~/JuliaMono-ttf.tar.gz | ||
| EOT |
There was a problem hiding this comment.
Again, we cannot place anything in the home dir. I suggest determining where else you can install fonts in the system so that they can be discovered. This may also require moving this block before the line USER ${NB_USER}, as I suspect installing fonts in some recognized system location may require root permissions.
|
|
||
| # Run the precompile/build within Jupyter (somehow that is necessary) | ||
| COPY precompile_build.ipynb ./ | ||
| RUN jupyter execute precompile_build.ipynb && rm precompile_build.ipynb |
There was a problem hiding this comment.
Why do you need a notebook file to do this? Won't the following work?
RUN julia -e 'using Pkg; Pkg.precompile(); Pkg.build();'
That's similar to what I added only a few lines above.
There was a problem hiding this comment.
I couldn't find out the reason why this is needed, but I'm not the only one seeing this link. The tiny notebook seems to solve the problem, though. Without this, another precompilation is triggered when users load any modules from a fresh session, so this cuts down the initial runtime of the whole demo notebook quite significantly.
There was a problem hiding this comment.
I'm trying to see this impact, but can't. We can keep this for now, but I would like to explore this a bit more later, because I suspect there's a better way to address this.
There was a problem hiding this comment.
I don't think this file is necessary. See my comment in the Dockerfile about adding the command there.
There was a problem hiding this comment.
This step is required: one can easily test this by spawning a new session with custom image from chuckwondo/julia/retrievaltoolkit-docker and then typing using Plots in a notebook (not from the REPL!). One is greeted with an error related to "world age", that must be fixed through re-compilation within a notebook (though I do not know why), and this little notebook takes care of that.
Dockerfile
Outdated
| # Comment Peter: this is no longer necessary, I fixed my repo | ||
| # git -C xrtm reset --hard b3aeace |
There was a problem hiding this comment.
Nice to see you fixed your repo. You can remove these comment lines.
| # Comment Peter: this is no longer necessary, I fixed my repo | |
| # git -C xrtm reset --hard b3aeace |
|
@chuckwondo |
Dockerfile
Outdated
| EOT | ||
|
|
||
| # Add the RetrivalToolbox package | ||
| RUN julia -e 'using Pkg; Pkg.add(url="https://github.com/US-GHG-Center/RetrievalToolbox.jl");' |
There was a problem hiding this comment.
Let's just add Pkg.add(url="https://github.com/US-GHG-Center/RetrievalToolbox.jl"); to the preceding julia command. No need to use 2 separate julia commands. Combining with the other will also avoid needlessly adding another layer to the Docker image.
Dockerfile
Outdated
| # Add the demo notebook into /opt/IWGGMS21-Demo | ||
| USER root | ||
| RUN git clone https://github.com/US-GHG-Center/IWGGMS21-Demo /opt/IWGGMS21-Demo && chown -R jovyan /opt/IWGGMS21-Demo |
There was a problem hiding this comment.
No need to switch back to root again. Simply move this git clone command up in the file, right after the block dealing with xrtm, before switching to NB_USER, since the root user will already be the current user.
Also, use ${NB_USER} instead of hard-coding jovyan.
There was a problem hiding this comment.
We can also use git clone --depth 1 ... to reduce space requirements, unless you expect users to commit changes to the repo.
There was a problem hiding this comment.
And the same can be done on the clone of the xrtm repo as well.
Dockerfile
Outdated
| RUN git clone https://github.com/US-GHG-Center/IWGGMS21-Demo /opt/IWGGMS21-Demo && chown -R jovyan /opt/IWGGMS21-Demo | ||
|
|
||
| # Run the precompile/build within Jupyter (somehow that is necessary) | ||
| USER ${NB_USER} |
There was a problem hiding this comment.
No need to switch back to NB_USER once you remove the preceeding USER root line, based upon my preceding comment.
|
|
||
| # Run the precompile/build within Jupyter (somehow that is necessary) | ||
| COPY precompile_build.ipynb ./ | ||
| RUN jupyter execute precompile_build.ipynb && rm precompile_build.ipynb |
There was a problem hiding this comment.
I'm trying to see this impact, but can't. We can keep this for now, but I would like to explore this a bit more later, because I suspect there's a better way to address this.
Dockerfile
Outdated
| ENV NOTEBOOK_ARGS=/opt/IWGGMS21-Demo/IWGGMS-demonstration.ipynb | ||
|
|
||
| # Clean up conda cache to reduce image size a little bit | ||
| RUN conda clean --all -f -y |
There was a problem hiding this comment.
No sense in adding another layer to the image. Please just add this conda command up into the RUN block near the top of the file, where the other conda command is. Reducing the number of layers also helps reduce image size.
Dockerfile
Outdated
| # NOTEBOOK_ARGS set to this path will cause the Jupyter Lab environment | ||
| # to start in this folder, so users will see only this Notebook and thus | ||
| # know which one to use. | ||
| ENV NOTEBOOK_ARGS=/opt/IWGGMS21-Demo/IWGGMS-demonstration.ipynb |
There was a problem hiding this comment.
Let's move this up where the rest of the ENV directives are at the top of the file.
| # Download and install JuliaMono font for good rendering of plotting text | ||
| RUN <<EOT | ||
| curl -OL https://github.com/cormullion/juliamono/releases/download/v0.060/JuliaMono-ttf.tar.gz | ||
| cd /usr/share/fonts | ||
| tar -xvzf /opt/JuliaMono-ttf.tar.gz | ||
| rm /opt/JuliaMono-ttf.tar.gz | ||
| chmod ugo+r /usr/share/fonts/* | ||
| EOT |
There was a problem hiding this comment.
| # Download and install JuliaMono font for good rendering of plotting text | |
| RUN <<EOT | |
| curl -OL https://github.com/cormullion/juliamono/releases/download/v0.060/JuliaMono-ttf.tar.gz | |
| cd /usr/share/fonts | |
| tar -xvzf /opt/JuliaMono-ttf.tar.gz | |
| rm /opt/JuliaMono-ttf.tar.gz | |
| chmod ugo+r /usr/share/fonts/* | |
| EOT | |
| # Download and install JuliaMono font for good rendering of plotting text | |
| RUN <<EOT | |
| #!/bin/bash | |
| set -e | |
| fonts_dir=/usr/share/fonts/truetype/julia | |
| curl -OLs https://github.com/cormullion/juliamono/releases/download/v0.060/JuliaMono-ttf.tar.gz | |
| mkdir -p "${fonts_dir}" | |
| tar -xzf JuliaMono-ttf.tar.gz -C "${fonts_dir}" | |
| rm JuliaMono-ttf.tar.gz | |
| EOT |
|
Re-shuffled the Dockerfile, not tested in the US-GHG-Center jhub environment which seems to be different enough that the |
I've added/modified the following:
Again - tested this in my local machine, but not yet on the hub.