Skip to content

Commit e218a32

Browse files
authored
Merge pull request #573 from GladysNalvarte/nodejs_inst
npm installation
2 parents 8597520 + 8c6329d commit e218a32

File tree

3 files changed

+30
-2
lines changed

3 files changed

+30
-2
lines changed

repo2docker/buildpacks/base.py

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -356,6 +356,7 @@ def get_build_scripts(self):
356356
You can use environment variable substitutions in both the
357357
username and the execution script.
358358
"""
359+
359360
return []
360361

361362
def get_assemble_scripts(self):
@@ -520,9 +521,35 @@ class BaseImage(BuildPack):
520521
def get_build_env(self):
521522
"""Return env directives required for build"""
522523
return [
523-
("APP_BASE", "/srv")
524+
("APP_BASE", "/srv"),
525+
('NPM_DIR', '${APP_BASE}/npm'),
526+
('NPM_CONFIG_GLOBALCONFIG','${NPM_DIR}/npmrc')
527+
]
528+
529+
def get_path(self):
530+
return super().get_path() + [
531+
'${NPM_DIR}/bin'
524532
]
525533

534+
def get_build_scripts(self):
535+
scripts = [
536+
(
537+
"root",
538+
r"""
539+
mkdir -p ${NPM_DIR} && \
540+
chown -R ${NB_USER}:${NB_USER} ${NPM_DIR}
541+
"""
542+
),
543+
(
544+
"${NB_USER}",
545+
r"""
546+
npm config --global set prefix ${NPM_DIR}
547+
"""
548+
),
549+
]
550+
551+
return super().get_build_scripts() + scripts
552+
526553
def get_env(self):
527554
"""Return env directives to be set after build"""
528555
env = []
@@ -541,7 +568,6 @@ def get_env(self):
541568
])
542569
return env
543570

544-
545571
def detect(self):
546572
return True
547573

tests/venv/postBuild/postBuild

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
#!/bin/bash
22
jupyter nbextension enable --py --sys-prefix ipyleaflet
3+
npm install --global configurable-http-proxy

tests/venv/postBuild/verify

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
#!/bin/bash
22
set -euo pipefail
33
jupyter nbextension list | grep 'jupyter-leaflet' | grep enabled
4+
which configurable-http-proxy

0 commit comments

Comments
 (0)