🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
102 lines
3.0 KiB
Docker
102 lines
3.0 KiB
Docker
# 基于 Node.js Alpine 的 CI/CD 基础镜像
|
|
# 预配置所有网络和包管理器优化
|
|
FROM node:20-alpine
|
|
|
|
# 设置环境变量
|
|
ENV HTTP_PROXY=http://127.0.0.1:7890
|
|
ENV HTTPS_PROXY=http://127.0.0.1:7890
|
|
ENV NO_PROXY=localhost,127.0.0.1,192.168.1.83,192.168.1.83:33000,192.168.1.83:8443
|
|
ENV TZ=Asia/Shanghai
|
|
|
|
# 配置 Alpine 国内源(清华大学)
|
|
RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.tuna.tsinghua.edu.cn/g' /etc/apk/repositories
|
|
|
|
# 安装基础工具
|
|
RUN apk update && apk add --no-cache \
|
|
git \
|
|
curl \
|
|
wget \
|
|
unzip \
|
|
zip \
|
|
jq \
|
|
ca-certificates \
|
|
tzdata \
|
|
python3 \
|
|
py3-pip \
|
|
maven \
|
|
openjdk21 \
|
|
bash \
|
|
&& rm -rf /var/cache/apk/*
|
|
|
|
# 设置时区
|
|
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
|
|
|
|
# 安装 kubectl 和 helm
|
|
RUN curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/arm64/kubectl" \
|
|
&& chmod +x kubectl \
|
|
&& mv kubectl /usr/local/bin/ \
|
|
&& curl https://get.helm.sh/helm-v3.15.3-linux-arm64.tar.gz | tar xz \
|
|
&& mv linux-arm64/helm /usr/local/bin/ \
|
|
&& rm -rf linux-arm64
|
|
|
|
# 配置 NPM - 使用国内镜像源和代理
|
|
RUN npm config set registry https://registry.npmmirror.com \
|
|
&& npm config set proxy http://127.0.0.1:7890 \
|
|
&& npm config set https-proxy http://127.0.0.1:7890
|
|
|
|
# 配置 Maven settings.xml - 使用阿里云镜像源
|
|
RUN mkdir -p ~/.m2 \
|
|
&& cat > ~/.m2/settings.xml << 'EOF'
|
|
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
|
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
|
|
http://maven.apache.org/xsd/settings-1.0.0.xsd">
|
|
<mirrors>
|
|
<mirror>
|
|
<id>alimaven</id>
|
|
<name>aliyun maven</name>
|
|
<url>http://maven.aliyun.com/nexus/content/groups/public/</url>
|
|
<mirrorOf>central</mirrorOf>
|
|
</mirror>
|
|
<mirror>
|
|
<id>nexus-tencentyun</id>
|
|
<mirrorOf>*</mirrorOf>
|
|
<name>Nexus tencentyun</name>
|
|
<url>http://mirrors.cloud.tencent.com/nexus/repository/maven-public/</url>
|
|
</mirror>
|
|
</mirrors>
|
|
</settings>
|
|
EOF
|
|
|
|
# 配置 PIP - 使用国内镜像源
|
|
RUN mkdir -p ~/.pip \
|
|
&& cat > ~/.pip/pip.conf << 'EOF'
|
|
[global]
|
|
trusted-host = mirrors.aliyun.com
|
|
pypi.org
|
|
pypi.python.org
|
|
files.pythonhosted.org
|
|
index-url = https://mirrors.aliyun.com/pypi/simple/
|
|
timeout = 60
|
|
EOF
|
|
|
|
# 配置 Git 优化
|
|
RUN git config --global core.preloadindex true \
|
|
&& git config --global core.fscache true \
|
|
&& git config --global gc.auto 256 \
|
|
&& git config --global submodule.fetchJobs 4
|
|
|
|
# 创建工作目录
|
|
WORKDIR /workspace
|
|
|
|
# 设置环境变量
|
|
ENV JAVA_HOME=/usr/lib/jvm/java-21-openjdk
|
|
ENV PATH=$JAVA_HOME/bin:$PATH
|
|
|
|
# 添加标签
|
|
LABEL maintainer="bookstore-team"
|
|
LABEL description="Optimized Node.js Alpine CI/CD base image with Chinese mirrors and proxy support"
|
|
LABEL version="1.0.0"
|
|
|
|
# 设置默认命令
|
|
CMD ["/bin/bash"] |