Skip to content

Commit fff6020

Browse files
committed
fix: install npm in docker containers
Missing npm has to deal with the underlying debian container, and the way that the third-party repository sometimes isn't picked up (by my understanding it has to do with version overlap). The upgrade to the node major version fixes this issue across both images, while an explicit `apt-get install npm` works only within the php8 container.
1 parent 24107f5 commit fff6020

2 files changed

Lines changed: 4 additions & 2 deletions

File tree

Dockerfile.php7

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,12 @@ RUN apt-get update \
3939
&& rm -rf /var/lib/apt/lists/*
4040

4141

42+
ENV NODE_MAJOR=20
4243
# Based on nodesource installation instructions https://github.com/nodesource/distributions#installation-instructions
4344
RUN mkdir -p /etc/apt/keyrings \
4445
&& curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key \
4546
| gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg \
46-
&& echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_18.x nodistro main" > /etc/apt/sources.list.d/nodesource.list \
47+
&& echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_$NODE_MAJOR.x nodistro main" > /etc/apt/sources.list.d/nodesource.list \
4748
&& apt-get update \
4849
&& apt-get install nodejs -y
4950

Dockerfile.php8

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,12 @@ RUN apt-get update \
3939
&& rm -rf /var/lib/apt/lists/*
4040

4141

42+
ENV NODE_MAJOR=20
4243
# Based on nodesource installation instructions https://github.com/nodesource/distributions#installation-instructions
4344
RUN mkdir -p /etc/apt/keyrings \
4445
&& curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key \
4546
| gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg \
46-
&& echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_18.x nodistro main" > /etc/apt/sources.list.d/nodesource.list \
47+
&& echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_$NODE_MAJOR.x nodistro main" > /etc/apt/sources.list.d/nodesource.list \
4748
&& apt-get update \
4849
&& apt-get install nodejs -y
4950

0 commit comments

Comments
 (0)