From 188276eab54baca7c9c529cfaf5b8c8efab5d54f Mon Sep 17 00:00:00 2001 From: xiaokai Date: Fri, 30 Aug 2024 15:12:01 +0700 Subject: [PATCH] =?UTF-8?q?pikpak=20=E8=87=AA=E5=8A=A8=E7=99=BB=E9=99=86?= =?UTF-8?q?=E9=AA=8C=E8=AF=81=20=E5=8A=A0=E5=85=A5=E5=88=B0docker=E4=B8=AD?= =?UTF-8?q?=20ai=E8=AF=86=E5=88=ABpython=E7=9A=84=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E8=BE=83=E5=A4=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Dockerfile | 54 +++++++++++++++++++++++++++++++++++++++++---------- entrypoint.sh | 9 ++++++++- 2 files changed, 52 insertions(+), 11 deletions(-) diff --git a/Dockerfile b/Dockerfile index 74fa2165..6c2803da 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,26 +1,60 @@ -FROM alpine:edge as builder -LABEL stage=go-builder +FROM ubuntu AS build_alist WORKDIR /app/ -RUN apk add --no-cache bash curl gcc git go musl-dev +# RUN apt update && apt install bash curl gcc git go musl-dev +# 安装基本工具 +RUN apt update && \ + apt install -y software-properties-common && \ + add-apt-repository ppa:longsleep/golang-backports && \ + apt update && \ + apt install -y bash curl gcc git golang-go musl-dev COPY go.mod go.sum ./ RUN go mod download COPY ./ ./ RUN bash build.sh release docker -FROM alpine:edge +FROM ubuntu AS install_py +RUN apt update && \ + apt install -y curl python3 python3-pip python3.12-venv +WORKDIR /app/auto_pikpak/ +# RUN curl -O -L https://raw.githubusercontent.com/wangjunkai2022/auto_pikpak/main/requirements.txt requirements.txt +# RUN curl -O -L https://raw.githubusercontent.com/wangjunkai2022/auto_pikpak/main/requirements.txt requirements.txt +# 创建虚拟环境并激活 +RUN python3 -m venv venv && \ + . venv/bin/activate && \ + pip install \ + PyYAML \ + selenium \ + pyTelegramBotAPI \ + pyrclone \ + httpx \ + numpy \ + opencv_python \ + opencv_python_headless \ + ultralytics \ + 2captcha-python \ + Flask +FROM ubuntu as pikpak_server +RUN apt update && \ + apt install -y git +WORKDIR /app +RUN git clone https://github.com/wangjunkai2022/auto_pikpak.git --depth 1 +WORKDIR /app/auto_pikpak +COPY --from=install_py /app/auto_pikpak/venv /app/auto_pikpak/venv + +FROM ubuntu ARG INSTALL_FFMPEG=false LABEL MAINTAINER="i@nn.ci" WORKDIR /opt/alist/ -RUN apk update && \ - apk upgrade --no-cache && \ - apk add --no-cache bash ca-certificates su-exec tzdata; \ - [ "$INSTALL_FFMPEG" = "true" ] && apk add --no-cache ffmpeg; \ - rm -rf /var/cache/apk/* +RUN apt update && \ + apt upgrade -y && \ + apt install -y bash ca-certificates tzdata ffmpeg -COPY --from=builder /app/bin/alist ./ +# 复制 auto_pikpak 到第二阶段 +COPY --from=pikpak_server /app/auto_pikpak /app/auto_pikpak +COPY --from=build_alist /app/bin/alist ./ COPY entrypoint.sh /entrypoint.sh RUN chmod +x /entrypoint.sh && /entrypoint.sh version diff --git a/entrypoint.sh b/entrypoint.sh index a0d80835..7b80813e 100644 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -3,9 +3,16 @@ chown -R ${PUID}:${PGID} /opt/alist/ umask ${UMASK} +# 指定 Python 程序的工作目录 +PYTHON_DIR="/app/auto_pikpak" + +# 启动 Python 程序 +( + cd "$PYTHON_DIR" && /app/auto_pikpak/venv/bin/python3 server.py & +) if [ "$1" = "version" ]; then ./alist version else - exec su-exec ${PUID}:${PGID} ./alist server --no-prefix + exec ./alist server --no-prefix fi \ No newline at end of file