Skip to content

Commit 02c0386

Browse files
committed
Add NVM to the image
1 parent fccc39f commit 02c0386

File tree

3 files changed

+29
-0
lines changed

3 files changed

+29
-0
lines changed

Dockerfile

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,13 @@ FROM php:7.1-apache-stretch
22

33
ARG DEBIAN_FRONTEND=noninteractive
44

5+
# Install NVM and the current (as of 26/02/2019) LTS version of Node.
6+
ENV NVM_DIR /usr/local/nvm
7+
ENV NODE_VERSION lts/carbon
8+
RUN mkdir -p $NVM_DIR && \
9+
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.34.0/install.sh | bash && \
10+
. $NVM_DIR/nvm.sh && nvm install $NODE_VERSION && nvm use --delete-prefix $NODE_VERSION
11+
512
# Install the standard PHP extensions.
613
ADD root/tmp/setup/php-extensions.sh /tmp/setup/
714
RUN chmod 777 /tmp && chmod +t /tmp && \

moodle-php-entrypoint

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,15 @@ mkdir /var/www/phpunitdata && chown www-data:www-data /var/www/phpunitdata
99
mkdir /var/www/behatdata && chown www-data:www-data /var/www/behatdata
1010
mkdir /var/www/behatfaildumps && chown www-data:www-data /var/www/behatfaildumps
1111

12+
# Ensure that all users get NVM as standard.
13+
echo '[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"' >> /etc/bash.bashrc
14+
echo 'export NODE_REPL_HISTORY=' >> /etc/bash.bashrc
15+
mkdir /var/www/.config && chown www-data:www-data /var/www/.config
16+
17+
# Ensure that the requested version of node is installed.
18+
source $NVM_DIR/nvm.sh && nvm install $NODE_VERSION && nvm use --delete-prefix $NODE_VERSION
19+
echo 'nvm use "$NODE_VERSION"' >> /etc/bash.bashrc
20+
1221
# Load any additional entrypoint init files.
1322
for f in /docker-entrypoint-initdb.d/*; do
1423
case "$f" in

nvm-wrapper

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/usr/bin/env bash
2+
set -Eeo pipefail
3+
4+
# This is a wrapper around NVM to load the nvm functions, and then run nvm.
5+
6+
if [ -z "$(LC_ALL=C type -t nvm)" ] || [ "$(LC_ALL=C type -t nvm)" != function ]
7+
then
8+
# The `nvm` variable does not exist, or is not a function.
9+
# Source nvm.sh to load it.
10+
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh"
11+
fi
12+
13+
nvm $@

0 commit comments

Comments
 (0)