Skip to content

Commit c03df7b

Browse files
committed
install npm packages in container
1 parent 9772328 commit c03df7b

File tree

4 files changed

+17
-9
lines changed

4 files changed

+17
-9
lines changed

.devcontainer/Dockerfile

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,4 +49,12 @@ RUN /usr/bin/python3 -m venv /opt/venv && \
4949
rm /tmp/requirements.txt
5050
ENV PATH="/opt/venv/bin:$PATH"
5151

52+
# Install npm packages globally in the container
53+
COPY package.json package-lock.json /opt/node/
54+
RUN cd /opt/node && \
55+
/usr/bin/npm ci && \
56+
rm /opt/node/package.json /opt/node/package-lock.json
57+
ENV NODE_PATH="/opt/node/node_modules"
58+
ENV PATH="/opt/node/node_modules/.bin:$PATH"
59+
5260
WORKDIR /workspace

.devcontainer/onCreateCommand.sh

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
#!/bin/bash
22

3-
npm i
43
bundle install

bin/setup

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -209,10 +209,6 @@ if [[ ! -z "$DEVELOPMENT" && $DEVELOPMENT -eq 1 ]]; then
209209
fi
210210
fi
211211

212-
if [ ! -d ${ROOT}/node_modules ]; then
213-
${RUN} npm i
214-
fi
215-
216212
if [ "${CONTAINER_TYPE}" == "devcontainer" ]; then
217213
BUNDLE="bundle"
218214
RUBY="bundle exec ruby"

container.def

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ From: ubuntu:24.04
33

44
%files
55
requirements.txt /tmp/requirements.txt
6+
package.json /opt/node/package.json
7+
package-lock.json /opt/node/package-lock.json
68

79
%post
810
export DEBIAN_FRONTEND=noninteractive
@@ -49,11 +51,14 @@ From: ubuntu:24.04
4951
/opt/venv/bin/pip install -r /tmp/requirements.txt
5052
rm /tmp/requirements.txt
5153

54+
# Install npm packages globally in the container
55+
cd /opt/node
56+
/usr/bin/npm ci
57+
rm /opt/node/package.json /opt/node/package-lock.json
58+
5259
# cd $HOME
5360
# bundle install
5461

55-
# npm i wavedrom-cli
56-
# npm i i -E @antora/[email protected] @antora/[email protected] @antora/lunr-extension asciidoctor-kroki
57-
5862
%environment
59-
export PATH="/opt/venv/bin:$PATH"
63+
export PATH="/opt/venv/bin:/opt/node/node_modules/.bin:$PATH"
64+
export NODE_PATH="/opt/node/node_modules"

0 commit comments

Comments
 (0)