File tree Expand file tree Collapse file tree 1 file changed +15
-7
lines changed Expand file tree Collapse file tree 1 file changed +15
-7
lines changed Original file line number Diff line number Diff line change @@ -11,15 +11,23 @@ RUN apt-get update && apt-get install -y \
11
11
ENV NVM_DIR=/usr/local/nvm
12
12
ENV NODE_VERSION=20.11.1
13
13
14
- # 安装 nvm
15
- RUN curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.5/install.sh | bash \
16
- && source $NVM_DIR/nvm.sh \
17
- && nvm install $NODE_VERSION \
18
- && nvm alias default $NODE_VERSION \
19
- && nvm use default
14
+ # Use bash for the shell
15
+ SHELL ["/bin/bash" , "-o" , "pipefail" , "-c" ]
16
+
17
+ # Create a script file sourced by both interactive and non-interactive bash shells
18
+ ENV BASH_ENV /home/user/.bash_env
19
+ RUN touch "${BASH_ENV}"
20
+ RUN echo '. "${BASH_ENV}"' >> ~/.bashrc
21
+
22
+ # Download and install nvm
23
+ RUN curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.2/install.sh | PROFILE="${BASH_ENV}" bash
24
+ RUN echo node > .nvmrc
25
+ RUN nvm install $NODE_VERSION
26
+ RUN nvm alias default $NODE_VERSION
27
+ RUN nvm use default
20
28
21
29
# 确保后续命令可以使用 nvm 和 node
22
30
ENV PATH=$NVM_DIR/versions/node/v$NODE_VERSION/bin:$PATH
23
31
24
32
# 可选:验证 Node.js 和 npm 版本
25
- RUN node -v && npm -v
33
+ RUN node -v && npm -v
You can’t perform that action at this time.
0 commit comments