Skip to content

Commit 9d0336d

Browse files
authored
Update Dockerfile
fix nvm
1 parent cc8a5b3 commit 9d0336d

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

Dockerfile

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,28 @@
11
# 使用官方的 linuxserver/code-server 基础镜像
22
FROM linuxserver/code-server:latest
33

4+
# Set the SHELL to bash with pipefail option
5+
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
6+
47
# 安装 nvm 所需的依赖
58
RUN apt-get update && apt-get install -y \
69
curl \
710
git \
811
build-essential \
912
libssl-dev \
1013
&& rm -rf /var/lib/apt/lists/*
11-
12-
# 设置环境变量
13-
ENV NVM_DIR=/root/.nvm
14-
15-
# 下载并安装 nvm
16-
RUN curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/master/install.sh | bash
17-
18-
# 配置 nvm 环境变量
19-
ENV PATH=${NVM_DIR}/versions/node/v20.11.1/bin:${PATH}
14+
15+
# Create a script file sourced by both interactive and non-interactive bash shells
16+
ENV BASH_ENV /home/user/.bash_env
17+
RUN touch "${BASH_ENV}"
18+
RUN echo '. "${BASH_ENV}"' >> ~/.bashrc
2019

2120
# 加载 nvm 并安装 Node.js v20.11.1
22-
RUN . $NVM_DIR/nvm.sh \
23-
&& nvm install 20.11.1 \
24-
&& nvm use 20.11.1 \
25-
&& nvm alias default 20.11.1
21+
RUN curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/master/install.sh | PROFILE="${BASH_ENV}" bash
22+
RUN echo node > .nvmrc
23+
RUN nvm install 20.11.1
24+
RUN nvm use 20.11.1
25+
RUN nvm alias default 20.11.1
2626

2727
# 可选:验证 Node.js 和 npm 版本
2828
RUN node -v && npm -v

0 commit comments

Comments
 (0)