File tree Expand file tree Collapse file tree 1 file changed +19
-19
lines changed Expand file tree Collapse file tree 1 file changed +19
-19
lines changed Original file line number Diff line number Diff line change 1
1
# 使用官方的 linuxserver/code-server 基础镜像
2
2
FROM linuxserver/code-server:latest
3
3
4
+ # 基于 linuxserver/code-server:latest 镜像
5
+ FROM linuxserver/code-server:latest
6
+
4
7
# 安装 nvm 所需的依赖
5
8
RUN apt-get update && apt-get install -y \
6
9
curl \
7
10
git \
8
- sudo
11
+ bash \
12
+ build-essential \
13
+ libssl-dev \
14
+ && rm -rf /var/lib/apt/lists/*
9
15
10
- # 设置环境变量
11
- ENV NVM_DIR=/usr/local/nvm
12
- ENV NODE_VERSION=20.11.1
16
+ # 安装 nvm
17
+ RUN curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/master/install.sh | bash
13
18
14
- # Use bash for the shell
15
- SHELL ["/bin/bash" , "-o" , "pipefail" , "-c" ]
19
+ # 配置 nvm 环境变量
20
+ ENV NVM_DIR=/root/.nvm
21
+ ENV PATH=${NVM_DIR}/versions/node/v20.11.1/bin:${PATH}
16
22
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
23
+ # 加载 nvm 脚本
24
+ RUN [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
21
25
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
28
-
29
- # 确保后续命令可以使用 nvm 和 node
30
- ENV PATH=$NVM_DIR/versions/node/v$NODE_VERSION/bin:$PATH
26
+ # 使用 nvm 安装 Node.js v20.11.1
27
+ RUN [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" && nvm install 20.11.1 && nvm use 20.11.1
31
28
32
29
# 可选:验证 Node.js 和 npm 版本
33
30
RUN node -v && npm -v
31
+
32
+ # 启动 code-server
33
+ CMD ["code-server" ]
You can’t perform that action at this time.
0 commit comments