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
|
||||
|
||||
{% if env -%}
|
||||
# Almost all environment variables
|
||||
{% for item in env -%}
|
||||
{% if build_env -%}
|
||||
# Environment variables required for build
|
||||
{% for item in build_env -%}
|
||||
ENV {{item[0]}} {{item[1]}}
|
||||
{% endfor -%}
|
||||
{% endif -%}
|
||||
|
@ -94,6 +94,14 @@ USER root
|
|||
COPY src/ ${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
|
||||
# in the repository into the image.
|
||||
{% for sd in assemble_script_directives -%}
|
||||
|
@ -182,6 +190,21 @@ class BuildPack:
|
|||
"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):
|
||||
"""
|
||||
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
|
||||
name and the second item being the value.
|
||||
|
||||
These variables will not be available to build.
|
||||
"""
|
||||
return []
|
||||
|
||||
|
@ -322,6 +347,7 @@ class BuildPack:
|
|||
return t.render(
|
||||
packages=sorted(self.get_packages()),
|
||||
path=self.get_path(),
|
||||
build_env=self.get_build_env(),
|
||||
env=self.get_env(),
|
||||
labels=self.get_labels(),
|
||||
build_script_directives=build_script_directives,
|
||||
|
@ -388,11 +414,16 @@ class BuildPack:
|
|||
|
||||
|
||||
class BaseImage(BuildPack):
|
||||
def get_env(self):
|
||||
def get_build_env(self):
|
||||
"""Return env directives required for build"""
|
||||
return [
|
||||
("APP_BASE", "/srv")
|
||||
]
|
||||
|
||||
def get_env(self):
|
||||
"""Return env directives to be set after build"""
|
||||
return []
|
||||
|
||||
def detect(self):
|
||||
return True
|
||||
|
||||
|
|
|
@ -18,14 +18,14 @@ class CondaBuildPack(BaseImage):
|
|||
Uses miniconda since it is more lightweight than Anaconda.
|
||||
|
||||
"""
|
||||
def get_env(self):
|
||||
def get_build_env(self):
|
||||
"""Return environment variables to be set.
|
||||
|
||||
We set `CONDA_DIR` to the conda install directory and
|
||||
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'),
|
||||
('NB_PYTHON_PREFIX', '${CONDA_DIR}'),
|
||||
]
|
||||
|
|
|
@ -12,7 +12,7 @@ class JuliaBuildPack(CondaBuildPack):
|
|||
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
|
||||
|
||||
Returns:
|
||||
|
@ -31,7 +31,7 @@ class JuliaBuildPack(CondaBuildPack):
|
|||
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_HOME', '${JULIA_PATH}/bin'),
|
||||
('JULIA_PKGDIR', '${JULIA_PATH}/pkg'),
|
||||
|
|
|
@ -82,7 +82,7 @@ class RBuildPack(PythonBuildPack):
|
|||
'/usr/lib/rstudio-server/bin/'
|
||||
]
|
||||
|
||||
def get_env(self):
|
||||
def get_build_env(self):
|
||||
"""
|
||||
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
|
||||
variable, so we set that here.
|
||||
"""
|
||||
return super().get_env() + [
|
||||
return super().get_build_env() + [
|
||||
# This is the path where user libraries are installed
|
||||
('R_LIBS_USER', '${APP_BASE}/rlibs')
|
||||
]
|
||||
|
|
|
@ -2,9 +2,7 @@
|
|||
Buildpack for stencila editor for DAR document archives
|
||||
"""
|
||||
|
||||
import re
|
||||
import os
|
||||
import datetime
|
||||
|
||||
from ..conda import CondaBuildPack
|
||||
|
||||
|
@ -38,17 +36,35 @@ class StencilaBuildPack(CondaBuildPack):
|
|||
|
||||
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")
|
||||
|
||||
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):
|
||||
"""
|
||||
Return environment variables to be set.
|
||||
|
||||
Sets STENCILA_DIR
|
||||
Sets STENCILA_ARCHIVE_DIR
|
||||
"""
|
||||
return super().get_env() + [
|
||||
# This is the path where user libraries are installed
|
||||
("STENCILA_DIR", "/opt/stencila")
|
||||
("STENCILA_ARCHIVE_DIR", "${HOME}/" + self.manifest_dir)
|
||||
]
|
||||
|
||||
def get_build_script_files(self):
|
||||
|
@ -69,14 +85,6 @@ class StencilaBuildPack(CondaBuildPack):
|
|||
|
||||
"""
|
||||
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[
|
||||
"stencila/jupyter_notebook_config.py"
|
||||
] = "/etc/jupyter/jupyter_notebook_config.py"
|
||||
|
@ -109,7 +117,7 @@ class StencilaBuildPack(CondaBuildPack):
|
|||
# install stencila
|
||||
r"""
|
||||
cd ${STENCILA_DIR} && \
|
||||
npm install
|
||||
npm install https://github.com/minrk/jupyter-dar
|
||||
""",
|
||||
),
|
||||
]
|
||||
|
|
Ładowanie…
Reference in New Issue