From e860a253fef46f8d820a79840295f87b4192566c Mon Sep 17 00:00:00 2001 From: "z.to" Date: Fri, 30 Jan 2026 22:49:37 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=20Docker=20=E9=85=8D?= =?UTF-8?q?=E7=BD=AE=E6=96=87=E4=BB=B6=E5=92=8C=E5=BF=BD=E7=95=A5=E6=96=87?= =?UTF-8?q?=E4=BB=B6=EF=BC=8C=E8=AE=BE=E7=BD=AE=20Alpine=20=E8=BD=AF?= =?UTF-8?q?=E4=BB=B6=E6=BA=90=EF=BC=8C=E5=AE=89=E8=A3=85=E6=A0=B8=E5=BF=83?= =?UTF-8?q?=E5=BC=80=E5=8F=91=E5=B7=A5=E5=85=B7=EF=BC=8C=E5=B9=B6=E9=85=8D?= =?UTF-8?q?=E7=BD=AE=20npm?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .dockerignore | 9 +++++++++ .gitignore | 8 ++++++++ .npmrc | 1 + Dockfile | 41 +++++++++++++++++++++++++++++++++++++++++ repositories | 2 ++ 5 files changed, 61 insertions(+) create mode 100644 .dockerignore create mode 100644 .gitignore create mode 100644 .npmrc create mode 100644 Dockfile create mode 100644 repositories diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..4ced203 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,9 @@ +.DS_Store +.ini + +node_modules/ +.vscode/ +.fleet/ +.vs/ +.webstorm/ +.phpstorm/ diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..b437e47 --- /dev/null +++ b/.gitignore @@ -0,0 +1,8 @@ +.DS_Store +.ini +.vs/ +.vs_code/ +.fleet/ +.codeartsdoer/ +.config/ +.env diff --git a/.npmrc b/.npmrc new file mode 100644 index 0000000..7f082f2 --- /dev/null +++ b/.npmrc @@ -0,0 +1 @@ +registry=https://registry.npmmirror.com \ No newline at end of file diff --git a/Dockfile b/Dockfile new file mode 100644 index 0000000..0bd0544 --- /dev/null +++ b/Dockfile @@ -0,0 +1,41 @@ +FROM node:25-alpine + +LABEL author="z-to " + +# 设置时区 (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"] \ No newline at end of file diff --git a/repositories b/repositories new file mode 100644 index 0000000..728e39b --- /dev/null +++ b/repositories @@ -0,0 +1,2 @@ +https://mirrors.aliyun.com/alpine/v3.21/main +https://mirrors.aliyun.com/alpine/v3.21/community \ No newline at end of file