Skip to content

Commit 5a13ad8

Browse files
authored
Update Dockerfile
fix nvm
1 parent 7741ea7 commit 5a13ad8

File tree

1 file changed

+19
-19
lines changed

1 file changed

+19
-19
lines changed

Dockerfile

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

4+
# 基于 linuxserver/code-server:latest 镜像
5+
FROM linuxserver/code-server:latest
6+
47
# 安装 nvm 所需的依赖
58
RUN apt-get update && apt-get install -y \
69
curl \
710
git \
8-
sudo
11+
bash \
12+
build-essential \
13+
libssl-dev \
14+
&& rm -rf /var/lib/apt/lists/*
915

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
1318

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}
1622

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"
2125

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
3128

3229
# 可选:验证 Node.js 和 npm 版本
3330
RUN node -v && npm -v
31+
32+
# 启动 code-server
33+
CMD ["code-server"]

0 commit comments

Comments
 (0)