添加 Docker 配置文件和忽略文件,设置 Alpine 软件源,安装核心开发工具,并配置 npm
This commit is contained in:
41
Dockfile
Normal file
41
Dockfile
Normal file
@@ -0,0 +1,41 @@
|
||||
FROM node:25-alpine
|
||||
|
||||
LABEL author="z-to <gaomia.site>"
|
||||
|
||||
# 设置时区 (Node.js 和 Git 都会识别此变量)
|
||||
ENV TZ=Asia/Shanghai
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
# 1. 替换 Alpine 软件源
|
||||
# 假设你的构建目录下有一个名为 repositories 的文件
|
||||
COPY ./repositories /etc/apk/repositories
|
||||
|
||||
# 2. 仅安装核心开发工具
|
||||
# git: 必须装 (终端执行 git 命令、脚本调用)
|
||||
# bash: 建议装 (比默认 sh 更好用,支持很多脚本语法)
|
||||
RUN apk update && \
|
||||
apk add --no-cache git bash
|
||||
|
||||
# 3. 下载 starship 二进制文件 (Alpine 版本)
|
||||
RUN wget https://github.com/starship/starship/releases/latest/download/starship-x86_64-unknown-linux-musl.tar.gz -O /tmp/starship.tar.gz && \
|
||||
tar -xzf /tmp/starship.tar.gz -C /tmp/ && \
|
||||
mv /tmp/starship /usr/local/bin/ && \
|
||||
rm /tmp/starship.tar.gz
|
||||
|
||||
# 4. 在 bashrc 初始化
|
||||
RUN echo 'eval "$(starship init bash)"' >> /root/.bashrc && \
|
||||
mkdir -p ~/.config/ && \
|
||||
starship preset no-empty-icons -o ~/.config/starship.toml
|
||||
|
||||
# 6. 复制 npm 配置
|
||||
COPY .npmrc ./
|
||||
|
||||
# 7. 预安装依赖到镜像中
|
||||
# RUN yarn install
|
||||
|
||||
EXPOSE 3000
|
||||
VOLUME [ "/app" ]
|
||||
|
||||
# 8. 保持容器运行
|
||||
CMD ["tail", "-f", "/dev/null"]
|
||||
Reference in New Issue
Block a user