kopia lustrzana https://github.com/jupyterhub/repo2docker
separate get_build_env from get_env
so that runtime environment variables don’t trigger rebuildpull/309/head
rodzic
a61d9253a4
commit
cce1a47b09
|
@ -65,9 +65,9 @@ RUN apt-get update && \
|
||||||
|
|
||||||
EXPOSE 8888
|
EXPOSE 8888
|
||||||
|
|
||||||
{% if env -%}
|
{% if build_env -%}
|
||||||
# Almost all environment variables
|
# Environment variables required for build
|
||||||
{% for item in env -%}
|
{% for item in build_env -%}
|
||||||
ENV {{item[0]}} {{item[1]}}
|
ENV {{item[0]}} {{item[1]}}
|
||||||
{% endfor -%}
|
{% endfor -%}
|
||||||
{% endif -%}
|
{% endif -%}
|
||||||
|
@ -94,6 +94,14 @@ USER root
|
||||||
COPY src/ ${HOME}
|
COPY src/ ${HOME}
|
||||||
RUN chown -R ${NB_USER}:${NB_USER} ${HOME}
|
RUN chown -R ${NB_USER}:${NB_USER} ${HOME}
|
||||||
|
|
||||||
|
{% if env -%}
|
||||||
|
# The rest of the environment
|
||||||
|
{% for item in env -%}
|
||||||
|
ENV {{item[0]}} {{item[1]}}
|
||||||
|
{% endfor -%}
|
||||||
|
{% endif -%}
|
||||||
|
|
||||||
|
|
||||||
# Run assemble scripts! These will actually build the specification
|
# Run assemble scripts! These will actually build the specification
|
||||||
# in the repository into the image.
|
# in the repository into the image.
|
||||||
{% for sd in assemble_script_directives -%}
|
{% for sd in assemble_script_directives -%}
|
||||||
|
@ -182,6 +190,21 @@ class BuildPack:
|
||||||
"unzip",
|
"unzip",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
def get_build_env(self):
|
||||||
|
"""
|
||||||
|
Ordered list of environment variables to be set for this image.
|
||||||
|
|
||||||
|
Ordered so that environment variables can use other environment
|
||||||
|
variables in their values.
|
||||||
|
|
||||||
|
Expects tuples, with the first item being the environment variable
|
||||||
|
name and the second item being the value.
|
||||||
|
|
||||||
|
These environment variables will be set prior to build.
|
||||||
|
Use .get_env() to set environment variables after build.
|
||||||
|
"""
|
||||||
|
return []
|
||||||
|
|
||||||
def get_env(self):
|
def get_env(self):
|
||||||
"""
|
"""
|
||||||
Ordered list of environment variables to be set for this image.
|
Ordered list of environment variables to be set for this image.
|
||||||
|
@ -191,6 +214,8 @@ class BuildPack:
|
||||||
|
|
||||||
Expects tuples, with the first item being the environment variable
|
Expects tuples, with the first item being the environment variable
|
||||||
name and the second item being the value.
|
name and the second item being the value.
|
||||||
|
|
||||||
|
These variables will not be available to build.
|
||||||
"""
|
"""
|
||||||
return []
|
return []
|
||||||
|
|
||||||
|
@ -322,6 +347,7 @@ class BuildPack:
|
||||||
return t.render(
|
return t.render(
|
||||||
packages=sorted(self.get_packages()),
|
packages=sorted(self.get_packages()),
|
||||||
path=self.get_path(),
|
path=self.get_path(),
|
||||||
|
build_env=self.get_build_env(),
|
||||||
env=self.get_env(),
|
env=self.get_env(),
|
||||||
labels=self.get_labels(),
|
labels=self.get_labels(),
|
||||||
build_script_directives=build_script_directives,
|
build_script_directives=build_script_directives,
|
||||||
|
@ -388,11 +414,16 @@ class BuildPack:
|
||||||
|
|
||||||
|
|
||||||
class BaseImage(BuildPack):
|
class BaseImage(BuildPack):
|
||||||
def get_env(self):
|
def get_build_env(self):
|
||||||
|
"""Return env directives required for build"""
|
||||||
return [
|
return [
|
||||||
("APP_BASE", "/srv")
|
("APP_BASE", "/srv")
|
||||||
]
|
]
|
||||||
|
|
||||||
|
def get_env(self):
|
||||||
|
"""Return env directives to be set after build"""
|
||||||
|
return []
|
||||||
|
|
||||||
def detect(self):
|
def detect(self):
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
|
@ -18,14 +18,14 @@ class CondaBuildPack(BaseImage):
|
||||||
Uses miniconda since it is more lightweight than Anaconda.
|
Uses miniconda since it is more lightweight than Anaconda.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
def get_env(self):
|
def get_build_env(self):
|
||||||
"""Return environment variables to be set.
|
"""Return environment variables to be set.
|
||||||
|
|
||||||
We set `CONDA_DIR` to the conda install directory and
|
We set `CONDA_DIR` to the conda install directory and
|
||||||
the `NB_PYTHON_PREFIX` to the location of the jupyter binary.
|
the `NB_PYTHON_PREFIX` to the location of the jupyter binary.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
env = super().get_env() + [
|
env = super().get_build_env() + [
|
||||||
('CONDA_DIR', '${APP_BASE}/conda'),
|
('CONDA_DIR', '${APP_BASE}/conda'),
|
||||||
('NB_PYTHON_PREFIX', '${CONDA_DIR}'),
|
('NB_PYTHON_PREFIX', '${CONDA_DIR}'),
|
||||||
]
|
]
|
||||||
|
|
|
@ -12,7 +12,7 @@ class JuliaBuildPack(CondaBuildPack):
|
||||||
See https://github.com/JuliaPy/PyCall.jl/issues/410
|
See https://github.com/JuliaPy/PyCall.jl/issues/410
|
||||||
|
|
||||||
"""
|
"""
|
||||||
def get_env(self):
|
def get_build_env(self):
|
||||||
"""Get additional environment settings for Julia and Jupyter
|
"""Get additional environment settings for Julia and Jupyter
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
|
@ -31,7 +31,7 @@ class JuliaBuildPack(CondaBuildPack):
|
||||||
For example, a tuple may be `('JULIA_VERSION', '0.6.0')`.
|
For example, a tuple may be `('JULIA_VERSION', '0.6.0')`.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
return super().get_env() + [
|
return super().get_build_env() + [
|
||||||
('JULIA_PATH', '${APP_BASE}/julia'),
|
('JULIA_PATH', '${APP_BASE}/julia'),
|
||||||
('JULIA_HOME', '${JULIA_PATH}/bin'),
|
('JULIA_HOME', '${JULIA_PATH}/bin'),
|
||||||
('JULIA_PKGDIR', '${JULIA_PATH}/pkg'),
|
('JULIA_PKGDIR', '${JULIA_PATH}/pkg'),
|
||||||
|
|
|
@ -82,7 +82,7 @@ class RBuildPack(PythonBuildPack):
|
||||||
'/usr/lib/rstudio-server/bin/'
|
'/usr/lib/rstudio-server/bin/'
|
||||||
]
|
]
|
||||||
|
|
||||||
def get_env(self):
|
def get_build_env(self):
|
||||||
"""
|
"""
|
||||||
Return environment variables to be set.
|
Return environment variables to be set.
|
||||||
|
|
||||||
|
@ -90,7 +90,7 @@ class RBuildPack(PythonBuildPack):
|
||||||
without needing root. This is set via the `R_LIBS_USER` environment
|
without needing root. This is set via the `R_LIBS_USER` environment
|
||||||
variable, so we set that here.
|
variable, so we set that here.
|
||||||
"""
|
"""
|
||||||
return super().get_env() + [
|
return super().get_build_env() + [
|
||||||
# This is the path where user libraries are installed
|
# This is the path where user libraries are installed
|
||||||
('R_LIBS_USER', '${APP_BASE}/rlibs')
|
('R_LIBS_USER', '${APP_BASE}/rlibs')
|
||||||
]
|
]
|
||||||
|
|
|
@ -2,9 +2,7 @@
|
||||||
Buildpack for stencila editor for DAR document archives
|
Buildpack for stencila editor for DAR document archives
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import re
|
|
||||||
import os
|
import os
|
||||||
import datetime
|
|
||||||
|
|
||||||
from ..conda import CondaBuildPack
|
from ..conda import CondaBuildPack
|
||||||
|
|
||||||
|
@ -38,17 +36,35 @@ class StencilaBuildPack(CondaBuildPack):
|
||||||
|
|
||||||
Currently only checks for 'stencila' in runtime.txt
|
Currently only checks for 'stencila' in runtime.txt
|
||||||
"""
|
"""
|
||||||
|
self.manifest_dir = ''
|
||||||
|
for root, dirs, files in os.walk('.'):
|
||||||
|
print(root, dirs, files)
|
||||||
|
for f in files:
|
||||||
|
if f == 'manifest.xml':
|
||||||
|
self.manifest_dir = os.path.dirname(root)
|
||||||
|
return True
|
||||||
return self.runtime.startswith("stencila")
|
return self.runtime.startswith("stencila")
|
||||||
|
|
||||||
|
def get_build_env(self):
|
||||||
|
"""
|
||||||
|
Return build environment variables to be set.
|
||||||
|
|
||||||
|
Sets STENCILA_DIR
|
||||||
|
"""
|
||||||
|
return super().get_build_env() + [
|
||||||
|
# This is the path where stencila is installed
|
||||||
|
("STENCILA_DIR", "/opt/stencila"),
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
def get_env(self):
|
def get_env(self):
|
||||||
"""
|
"""
|
||||||
Return environment variables to be set.
|
Return environment variables to be set.
|
||||||
|
|
||||||
Sets STENCILA_DIR
|
Sets STENCILA_ARCHIVE_DIR
|
||||||
"""
|
"""
|
||||||
return super().get_env() + [
|
return super().get_env() + [
|
||||||
# This is the path where user libraries are installed
|
("STENCILA_ARCHIVE_DIR", "${HOME}/" + self.manifest_dir)
|
||||||
("STENCILA_DIR", "/opt/stencila")
|
|
||||||
]
|
]
|
||||||
|
|
||||||
def get_build_script_files(self):
|
def get_build_script_files(self):
|
||||||
|
@ -69,14 +85,6 @@ class StencilaBuildPack(CondaBuildPack):
|
||||||
|
|
||||||
"""
|
"""
|
||||||
files = super().get_build_script_files()
|
files = super().get_build_script_files()
|
||||||
for f in [
|
|
||||||
"index.html",
|
|
||||||
"stencila.js",
|
|
||||||
"stencila-host.js",
|
|
||||||
"package.json",
|
|
||||||
"package-lock.json",
|
|
||||||
]:
|
|
||||||
files["stencila/" + f] = "${STENCILA_DIR}/" + f
|
|
||||||
files[
|
files[
|
||||||
"stencila/jupyter_notebook_config.py"
|
"stencila/jupyter_notebook_config.py"
|
||||||
] = "/etc/jupyter/jupyter_notebook_config.py"
|
] = "/etc/jupyter/jupyter_notebook_config.py"
|
||||||
|
@ -109,7 +117,7 @@ class StencilaBuildPack(CondaBuildPack):
|
||||||
# install stencila
|
# install stencila
|
||||||
r"""
|
r"""
|
||||||
cd ${STENCILA_DIR} && \
|
cd ${STENCILA_DIR} && \
|
||||||
npm install
|
npm install https://github.com/minrk/jupyter-dar
|
||||||
""",
|
""",
|
||||||
),
|
),
|
||||||
]
|
]
|
||||||
|
|
Ładowanie…
Reference in New Issue