-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
67 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
# This is the Dockerfile to run Gammapy on Binder. | ||
# | ||
|
||
FROM continuumio/miniconda3:4.5.4 | ||
MAINTAINER Gammapy developers <gammapy@googlegroups.com> | ||
|
||
# compilers | ||
RUN apt-get update && apt-get install -y build-essential | ||
RUN pip install --upgrade pip | ||
|
||
# install dependencies - including the stable version of Gammapy | ||
COPY binder.py tmp/ | ||
RUN curl -o tmp/environment.yml https://gammapy.org/download/install/gammapy-0.8-environment.yml | ||
|
||
WORKDIR tmp/ | ||
RUN conda update conda | ||
RUN conda install -q -y pyyaml | ||
RUN python binder.py | ||
|
||
# add gammapy user running the jupyter notebook process | ||
ENV NB_USER gammapy | ||
ENV NB_UID 1000 | ||
ENV HOME /home/${NB_USER} | ||
|
||
RUN adduser --disabled-password \ | ||
--gecos "Default user" \ | ||
--uid ${NB_UID} \ | ||
${NB_USER} | ||
|
||
# download tutorials and datasets | ||
RUN gammapy download notebooks --out=${HOME}/gammapy-tutorials --release=0.8 | ||
RUN gammapy download datasets --out=${HOME}/gammapy-datasets --release=0.8 | ||
|
||
# setting ownerships | ||
USER root | ||
RUN chown -R gammapy:gammapy ${HOME} | ||
|
||
# start JupyterLab server in tutorials dir | ||
USER ${NB_USER} | ||
WORKDIR ${HOME}/gammapy-tutorials/notebooks-0.8 | ||
|
||
# env vars used in tutorials | ||
ENV GAMMAPY_DATA ${HOME}/gammapy-datasets |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
"""Install code on Binder. | ||
This script is executed from Dockerfile configuration file | ||
It installs software dependencies declared in environment.yml | ||
in the docker container built for the Binder service. | ||
""" | ||
import yaml | ||
import conda.cli | ||
from pip._internal import main as pip_main | ||
|
||
with open("environment.yml") as stream: | ||
content = yaml.load(stream) | ||
|
||
for chan in content['channels']: | ||
print("RUN conda config --add channels {}".format(chan)) | ||
conda.cli.main('conda', 'config', '--add', 'channels', chan) | ||
|
||
for pack in content['dependencies']: | ||
if isinstance(pack, str): | ||
print("RUN conda install -q -y {}".format(pack)) | ||
conda.cli.main('conda', 'install', '-y', '-q', pack) | ||
else: | ||
print("RUN pip install {}".format(pack['pip'][0])) | ||
pip_main(["install", pack['pip'][0]]) |