# 使用基础镜像 FROM golang:alpine AS builder # 安装必要的工具 RUN apk update && apk add --no-cache \ curl \ tar \ jq \ git \ python3 \ py3-pip # 安装 Python 和 pip RUN apk add --update --no-cache python3 py3-pip RUN python3 -m ensurepip # 为应用程序创建一个虚拟环境 RUN python3 -m venv /app/venv # 激活虚拟环境并安装依赖项 COPY requirements.txt /app/ RUN . /app/venv/bin/activate && pip install --no-cache-dir -r /app/requirements.txt # 创建新的工作目录 WORKDIR /app # 下载并解压文件,并给予所有用户读写和执行权限 RUN version=$(basename $(curl -sL -o /dev/null -w %{url_effective} https://github.com/pandora-next/deploy/releases/latest)) \ && base_url="https://github.com/pandora-next/deploy/releases/expanded_assets/$version" \ && latest_url="https://github.com/$(curl -sL $base_url | grep "href.*amd64.*\.tar.gz" | sed 's/.*href="//' | sed 's/".*//')" \ && curl -Lo PandoraNext.tar.gz $latest_url \ && tar -xzf PandoraNext.tar.gz --strip-components=1 \ && rm PandoraNext.tar.gz \ && chmod 777 -R . # 获取tokens.json RUN --mount=type=secret,id=TOKENS_JSON,dst=/etc/secrets/TOKENS_JSON \ if [ -f /etc/secrets/TOKENS_JSON ]; then \ cat /etc/secrets/TOKENS_JSON > tokens.json \ && chmod 777 tokens.json; \ else \ echo "TOKENS_JSON not found, skipping"; \ fi # 获取config.json RUN --mount=type=secret,id=CONFIG_JSON,dst=/etc/secrets/CONFIG_JSON \ cat /etc/secrets/CONFIG_JSON > config.json && chmod 777 config.json # 修改PandoraNext的执行权限 RUN chmod 777 ./PandoraNext # 创建全局缓存目录并提供最宽松的权限 RUN mkdir /.cache && chmod 777 /.cache # 克隆PandoraNext-Helper仓库 RUN git clone https://github.com/nianhua99/PandoraNext-Helper.git # 安装PandoraNext-Helper的Python依赖 RUN pip3 install --no-cache-dir -r PandoraNext-Helper/requirements.txt # 设置环境变量 ENV PANDORA_NEXT_DOMAIN=0.0.0.0:7860 ENV PANDORA_NEXT_PATH=/app # 开放端口 EXPOSE 7860 8181 # 运行应用程序时,确保激活虚拟环境 CMD ["/app/venv/bin/python3", "/app/PandoraNext-Helper/waitress_run.py"]