# 使用JDK 21作为基础镜像 FROM openjdk:21-slim # 安装必要工具 RUN apt-get update && apt-get install -y \ git \ wget \ unzip \ && rm -rf /var/lib/apt/lists/* # 设置Gradle ENV GRADLE_VERSION=8.14 ENV GRADLE_HOME=/opt/gradle ENV PATH=${GRADLE_HOME}/bin:${PATH} # 安装Gradle RUN wget -q https://services.gradle.org/distributions/gradle-${GRADLE_VERSION}-bin.zip \ && unzip gradle-${GRADLE_VERSION}-bin.zip -d /opt \ && mv /opt/gradle-${GRADLE_VERSION} ${GRADLE_HOME} \ && rm gradle-${GRADLE_VERSION}-bin.zip # 创建工作目录 WORKDIR /app # 创建构建脚本 RUN echo '#!/bin/bash\n\ set -e\n\ \n\ if [ -z "$GIT_REPO_URL" ]; then\n\ echo "ERROR: GIT_REPO_URL environment variable is not set"\n\ exit 1\n\ fi\n\ \n\ # 如果代码还没克隆,就克隆\n\ if [ ! -d "/app/source" ]; then\n\ echo "Cloning repository..."\n\ git clone $GIT_REPO_URL /app/source\n\ \n\ echo "Building project..."\n\ cd /app/source\n\ ./gradlew clean installDist\n\ \n\ # 复制编译产物到运行目录\n\ cp -r /app/source/build/install/unidbg-fetch-qsign/* /app/\n\ fi\n\ \n\ # 启动服务\n\ cd /app\n\ echo "Starting service..."\n\ exec ./bin/unidbg-fetch-qsign --basePath="txlib/9.1.70"\n\ ' > /app/entrypoint.sh && chmod +x /app/entrypoint.sh # 暴露端口 EXPOSE 8080 # 设置入口点 ENTRYPOINT ["/app/entrypoint.sh"]