From f5ee38a40af19670c4eaf54b3e859ec84e88359b Mon Sep 17 00:00:00 2001 From: xiaokai Date: Thu, 29 Aug 2024 16:12:55 +0700 Subject: [PATCH 01/10] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E8=87=AA=E5=8A=A8?= =?UTF-8?q?=E9=AA=8C=E8=AF=81api=20=E7=AC=AC=E4=B8=80=E7=89=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- drivers/pikpak/meta.go | 1 + drivers/pikpak/types.go | 6 ++++++ drivers/pikpak/util.go | 20 +++++++++++++++++++- 3 files changed, 26 insertions(+), 1 deletion(-) diff --git a/drivers/pikpak/meta.go b/drivers/pikpak/meta.go index d27cee32c74..df480fb142d 100644 --- a/drivers/pikpak/meta.go +++ b/drivers/pikpak/meta.go @@ -14,6 +14,7 @@ type Addition struct { CaptchaToken string `json:"captcha_token" default:""` DeviceID string `json:"device_id" required:"false" default:""` DisableMediaLink bool `json:"disable_media_link" default:"true"` + CaptchaApi string `json:"captcha_api" default:""` } var config = driver.Config{ diff --git a/drivers/pikpak/types.go b/drivers/pikpak/types.go index 2a959ebf05d..5b38f79df2c 100644 --- a/drivers/pikpak/types.go +++ b/drivers/pikpak/types.go @@ -195,3 +195,9 @@ type CaptchaTokenResponse struct { ExpiresIn int64 `json:"expires_in"` Url string `json:"url"` } + +type CaptchaApiResponse struct { + Token string `json:"token"` + Code int64 `json:"code"` + Url string `json:"url_received"` +} diff --git a/drivers/pikpak/util.go b/drivers/pikpak/util.go index d3371a2558a..22e3c7eddfa 100644 --- a/drivers/pikpak/util.go +++ b/drivers/pikpak/util.go @@ -397,7 +397,25 @@ func (d *PikPak) refreshCaptchaToken(action string, metas map[string]string) err } if resp.Url != "" { - return fmt.Errorf(`need verify: Click Here`, resp.Url) + // return fmt.Errorf(`need verify: Click Here`, resp.Url) + if d.Addition.CaptchaApi != "" { + var e ErrResp + var captcha_resp CaptchaApiResponse + _, e := d.request(d.Addition.CaptchaApi, http.MethodGet, func(req *resty.Request) { + req.SetQueryParams("url", resp.Url) + }, &captcha_resp) + if e.IsError() { + return errors.New(e.Error()) + } + if captcha_resp.Code == 200 { + d.Common.SetCaptchaToken(captcha_resp.Token) + return nil + } else { + return errors.New("验证失败") + } + } else { + return errors.New("没有配置自动验证Server") + } } if d.Common.RefreshCTokenCk != nil { From aa760f173f3a5fc3bb1d66cd51bb3a05ace88644 Mon Sep 17 00:00:00 2001 From: xiaokai Date: Thu, 29 Aug 2024 16:36:07 +0700 Subject: [PATCH 02/10] =?UTF-8?q?=E8=AF=AD=E6=B3=95=E6=8A=A5=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- drivers/pikpak/util.go | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/drivers/pikpak/util.go b/drivers/pikpak/util.go index 22e3c7eddfa..ddfcdaa6f42 100644 --- a/drivers/pikpak/util.go +++ b/drivers/pikpak/util.go @@ -399,13 +399,15 @@ func (d *PikPak) refreshCaptchaToken(action string, metas map[string]string) err if resp.Url != "" { // return fmt.Errorf(`need verify: Click Here`, resp.Url) if d.Addition.CaptchaApi != "" { - var e ErrResp var captcha_resp CaptchaApiResponse - _, e := d.request(d.Addition.CaptchaApi, http.MethodGet, func(req *resty.Request) { - req.SetQueryParams("url", resp.Url) + _, err := d.request(d.Addition.CaptchaApi, http.MethodGet, func(req *resty.Request) { + queryParams := map[string]string{ + "url": resp.Url, + } + req.SetQueryParams(queryParams) }, &captcha_resp) - if e.IsError() { - return errors.New(e.Error()) + if err != nil { + return err } if captcha_resp.Code == 200 { d.Common.SetCaptchaToken(captcha_resp.Token) From 188276eab54baca7c9c529cfaf5b8c8efab5d54f Mon Sep 17 00:00:00 2001 From: xiaokai Date: Fri, 30 Aug 2024 15:12:01 +0700 Subject: [PATCH 03/10] =?UTF-8?q?pikpak=20=E8=87=AA=E5=8A=A8=E7=99=BB?= =?UTF-8?q?=E9=99=86=E9=AA=8C=E8=AF=81=20=E5=8A=A0=E5=85=A5=E5=88=B0docker?= =?UTF-8?q?=E4=B8=AD=20ai=E8=AF=86=E5=88=ABpython=E7=9A=84=E6=96=87?= =?UTF-8?q?=E4=BB=B6=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 74fa2165482..6c2803daeb7 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 a0d8083509e..7b80813e40e 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 From ec6778072e10eda79b979d6dd95e9ab8f4596a78 Mon Sep 17 00:00:00 2001 From: xiaokai Date: Fri, 30 Aug 2024 17:09:11 +0700 Subject: [PATCH 04/10] =?UTF-8?q?pikpak=20=E5=9C=A8=E8=8E=B7=E5=8F=96token?= =?UTF-8?q?=E5=A4=B1=E8=B4=A5=E5=90=8E=E8=B5=B0=E7=99=BB=E9=99=86=20?= =?UTF-8?q?=E5=9B=A0=E4=B8=BA=E6=9C=89=E8=87=AA=E5=8A=A8=E9=AA=8C=E8=AF=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- drivers/pikpak/util.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/pikpak/util.go b/drivers/pikpak/util.go index ddfcdaa6f42..ffa13aece73 100644 --- a/drivers/pikpak/util.go +++ b/drivers/pikpak/util.go @@ -197,7 +197,9 @@ func (d *PikPak) request(url string, method string, callback base.ReqCallback, r return d.request(url, method, callback, resp) case 9: // 验证码token过期 if err = d.RefreshCaptchaTokenAtLogin(GetAction(method, url), d.Common.UserID); err != nil { - return nil, err + if err = d.login(); err != nil { + return nil, err + } } return d.request(url, method, callback, resp) case 10: // 操作频繁 From 6b1e91964c3a8af7cad2ff7ed14b4bae627e685d Mon Sep 17 00:00:00 2001 From: xiaokai Date: Fri, 30 Aug 2024 17:09:38 +0700 Subject: [PATCH 05/10] =?UTF-8?q?=E6=9B=B4=E6=96=B0=20pikpak=E8=87=AA?= =?UTF-8?q?=E5=8A=A8=E9=AA=8C=E8=AF=81=E7=9A=84docker=E6=9C=8D=E5=8A=A1?= =?UTF-8?q?=E5=99=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Dockerfile | 9 +++++---- entrypoint.sh | 4 ++-- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/Dockerfile b/Dockerfile index 6c2803daeb7..863b002d9f7 100644 --- a/Dockerfile +++ b/Dockerfile @@ -38,9 +38,10 @@ 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 +RUN git clone --depth=1 --recurse-submodules https://github.com/wangjunkai2022/pikpak_captcha_server.git +WORKDIR /app/pikpak_captcha_server +RUN rm -rf /app/pikpak_captcha_server/pikpak_captcha/ai/ai_train_pikpak +COPY --from=install_py /app/auto_pikpak/venv /app/pikpak_captcha_server/venv FROM ubuntu ARG INSTALL_FFMPEG=false @@ -53,7 +54,7 @@ RUN apt update && \ apt install -y bash ca-certificates tzdata ffmpeg # 复制 auto_pikpak 到第二阶段 -COPY --from=pikpak_server /app/auto_pikpak /app/auto_pikpak +COPY --from=pikpak_server /app/pikpak_captcha_server /app/pikpak_captcha_server 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 7b80813e40e..17b6656b31c 100644 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -4,11 +4,11 @@ chown -R ${PUID}:${PGID} /opt/alist/ umask ${UMASK} # 指定 Python 程序的工作目录 -PYTHON_DIR="/app/auto_pikpak" +PYTHON_DIR="/app/pikpak_captcha_server" # 启动 Python 程序 ( - cd "$PYTHON_DIR" && /app/auto_pikpak/venv/bin/python3 server.py & + cd "$PYTHON_DIR" && /app/pikpak_captcha_server/venv/bin/python3 server.py & ) if [ "$1" = "version" ]; then From a24cf1b9dca15f7014caa329365bf17d0571617d Mon Sep 17 00:00:00 2001 From: xiaokai Date: Fri, 30 Aug 2024 20:43:08 +0700 Subject: [PATCH 06/10] docker file --- Dockerfile | 37 +++++++++++++++++++------------------ 1 file changed, 19 insertions(+), 18 deletions(-) diff --git a/Dockerfile b/Dockerfile index 863b002d9f7..691fad56546 100644 --- a/Dockerfile +++ b/Dockerfile @@ -12,36 +12,37 @@ RUN go mod download COPY ./ ./ RUN bash build.sh release docker -FROM ubuntu AS install_py +FROM ubuntu AS install_yolov8 RUN apt update && \ - apt install -y curl python3 python3-pip python3.12-venv + apt install -y 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 + # pip install \ + ultralytics + +# FROM ubuntu AS install_py2 +# COPY --from=install_yolov8 /app/auto_pikpak/venv /app/pikpak_captcha_server/venv +# RUN apt update && \ +# apt install -y python3 python3-pip python3.12-venv +# WORKDIR /app/pikpak_captcha_server/ +# # 使用虚拟环境中的 Python 安装其他依赖 +# RUN /app/pikpak_captcha_server/venv/bin/python -m pip install --no-cache-dir 2captcha-python Flask FROM ubuntu as pikpak_server RUN apt update && \ - apt install -y git + apt install -y git python3 python3-pip python3.12-venv WORKDIR /app -RUN git clone --depth=1 --recurse-submodules https://github.com/wangjunkai2022/pikpak_captcha_server.git +RUN git clone --depth=1 --recurse-submodules https://github.com/wangjunkai2022/pikpak_captcha_server.git WORKDIR /app/pikpak_captcha_server RUN rm -rf /app/pikpak_captcha_server/pikpak_captcha/ai/ai_train_pikpak -COPY --from=install_py /app/auto_pikpak/venv /app/pikpak_captcha_server/venv +COPY --from=install_yolov8 /app/auto_pikpak/venv /app/pikpak_captcha_server/venv +# 使用虚拟环境中的 Python 安装其他依赖 +RUN /app/pikpak_captcha_server/venv/bin/python -m pip install -r requirements.txt +# 安装每个子模块的依赖项 +RUN find . -name 'requirements.txt' -exec /app/pikpak_captcha_server/venv/bin/python -m pip install -r {} \; FROM ubuntu ARG INSTALL_FFMPEG=false From 91efb5cc1577f1d166c882b7f0a6a85c120b3479 Mon Sep 17 00:00:00 2001 From: xiaokai Date: Mon, 2 Sep 2024 11:27:17 +0700 Subject: [PATCH 07/10] =?UTF-8?q?pikpak=20=E9=AA=8C=E8=AF=81=E7=99=BB?= =?UTF-8?q?=E9=99=86=E6=97=B6=20=E8=B6=85=E6=97=B6=E6=97=B6=E9=97=B4?= =?UTF-8?q?=E8=AE=BE=E7=BD=AE=E4=B8=BApikpak=E5=AE=98=E7=BD=91=E8=BF=94?= =?UTF-8?q?=E5=9B=9E=E7=9A=84=E8=B6=85=E6=97=B6=E6=97=B6=E9=97=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- drivers/pikpak/util.go | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/drivers/pikpak/util.go b/drivers/pikpak/util.go index ffa13aece73..bbbcd8e735e 100644 --- a/drivers/pikpak/util.go +++ b/drivers/pikpak/util.go @@ -401,16 +401,29 @@ func (d *PikPak) refreshCaptchaToken(action string, metas map[string]string) err if resp.Url != "" { // return fmt.Errorf(`need verify: Click Here`, resp.Url) if d.Addition.CaptchaApi != "" { - var captcha_resp CaptchaApiResponse - _, err := d.request(d.Addition.CaptchaApi, http.MethodGet, func(req *resty.Request) { - queryParams := map[string]string{ - "url": resp.Url, - } - req.SetQueryParams(queryParams) - }, &captcha_resp) + var captcha_resp CaptchaApiResponse // 假设 captcha_resp 是某种结构体 + client := resty.New().SetTimeout(time.Duration(resp.ExpiresIn) * time.Second) + _, err := client.R(). + SetQueryParams(map[string]string{ + "url": resp.Url, // 替换为实际的 URL + }). + SetResult(&captcha_resp). + Get(d.Addition.CaptchaApi) // 替换为实际的 API 端点 + if err != nil { return err } + + // var captcha_resp CaptchaApiResponse + // _, err := d.request(d.Addition.CaptchaApi, http.MethodGet, func(req *resty.Request) { + // queryParams := map[string]string{ + // "url": resp.Url, + // } + // req.SetQueryParams(queryParams) + // }, &captcha_resp) + // if err != nil { + // return err + // } if captcha_resp.Code == 200 { d.Common.SetCaptchaToken(captcha_resp.Token) return nil From 538d8f4e8fb3d00612257fd62058a05835f995e6 Mon Sep 17 00:00:00 2001 From: xiaokai Date: Mon, 2 Sep 2024 11:27:53 +0700 Subject: [PATCH 08/10] =?UTF-8?q?pikpak=20RefreshToken=20=E9=85=8D?= =?UTF-8?q?=E7=BD=AE=E8=BF=87=E6=9C=9F=E5=90=8E=E4=BC=9A=E5=B0=9D=E8=AF=95?= =?UTF-8?q?=E8=B5=B0=E4=B8=80=E6=AC=A1=E7=99=BB=E9=99=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- drivers/pikpak/driver.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/drivers/pikpak/driver.go b/drivers/pikpak/driver.go index e2a2b82e7a7..87f3bc7b60e 100644 --- a/drivers/pikpak/driver.go +++ b/drivers/pikpak/driver.go @@ -97,6 +97,17 @@ func (d *PikPak) Init(ctx context.Context) (err error) { RefreshToken: d.Addition.RefreshToken, }).Token() })) + _, err := d.oauth2Token.Token() + if err != nil { + if err := d.login(); err != nil { + return err + } + d.oauth2Token = oauth2.ReuseTokenSource(nil, utils.TokenSource(func() (*oauth2.Token, error) { + return oauth2Config.TokenSource(ctx, &oauth2.Token{ + RefreshToken: d.RefreshToken, + }).Token() + })) + } } else { // 如果没有填写RefreshToken,尝试登录 获取 refreshToken if err := d.login(); err != nil { From 8196b1ffef4fe7d5a8e223fdc0e409f3b69ec00e Mon Sep 17 00:00:00 2001 From: xiaokai Date: Wed, 4 Sep 2024 11:27:34 +0700 Subject: [PATCH 09/10] =?UTF-8?q?=E6=81=A2=E5=A4=8D=E9=BB=98=E8=AE=A4docke?= =?UTF-8?q?r=20=E5=A2=9E=E5=8A=A0autopikpak=20Docker=20=E6=96=87=E4=BB=B6?= =?UTF-8?q?=20=E5=8F=AF=E4=BB=A5=E8=87=AA=E5=B7=B1=E5=9C=A8=E6=9C=AC?= =?UTF-8?q?=E5=9C=B0build=E4=B8=80=E4=B8=AA=E5=B8=A6=E6=9C=89=20=E8=87=AA?= =?UTF-8?q?=E5=8A=A8=E9=AA=8C=E8=AF=81=E6=9C=8D=E5=8A=A1=E5=99=A8=E7=9A=84?= =?UTF-8?q?docker?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Dockerfile | 56 +++++++---------------------------- Dockerfile_auto_pikpak | 66 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 76 insertions(+), 46 deletions(-) create mode 100644 Dockerfile_auto_pikpak diff --git a/Dockerfile b/Dockerfile index 691fad56546..74fa2165482 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,62 +1,26 @@ -FROM ubuntu AS build_alist +FROM alpine:edge as builder +LABEL stage=go-builder WORKDIR /app/ -# 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 +RUN apk add --no-cache bash curl gcc git go musl-dev COPY go.mod go.sum ./ RUN go mod download COPY ./ ./ RUN bash build.sh release docker -FROM ubuntu AS install_yolov8 -RUN apt update && \ - apt install -y python3 python3-pip python3.12-venv -WORKDIR /app/auto_pikpak/ -# 创建虚拟环境并激活 -RUN python3 -m venv venv && \ - . venv/bin/activate && \ - pip install \ - # pip install \ - ultralytics +FROM alpine:edge -# FROM ubuntu AS install_py2 -# COPY --from=install_yolov8 /app/auto_pikpak/venv /app/pikpak_captcha_server/venv -# RUN apt update && \ -# apt install -y python3 python3-pip python3.12-venv -# WORKDIR /app/pikpak_captcha_server/ -# # 使用虚拟环境中的 Python 安装其他依赖 -# RUN /app/pikpak_captcha_server/venv/bin/python -m pip install --no-cache-dir 2captcha-python Flask - -FROM ubuntu as pikpak_server -RUN apt update && \ - apt install -y git python3 python3-pip python3.12-venv -WORKDIR /app -RUN git clone --depth=1 --recurse-submodules https://github.com/wangjunkai2022/pikpak_captcha_server.git -WORKDIR /app/pikpak_captcha_server -RUN rm -rf /app/pikpak_captcha_server/pikpak_captcha/ai/ai_train_pikpak -COPY --from=install_yolov8 /app/auto_pikpak/venv /app/pikpak_captcha_server/venv -# 使用虚拟环境中的 Python 安装其他依赖 -RUN /app/pikpak_captcha_server/venv/bin/python -m pip install -r requirements.txt -# 安装每个子模块的依赖项 -RUN find . -name 'requirements.txt' -exec /app/pikpak_captcha_server/venv/bin/python -m pip install -r {} \; - -FROM ubuntu ARG INSTALL_FFMPEG=false LABEL MAINTAINER="i@nn.ci" WORKDIR /opt/alist/ -RUN apt update && \ - apt upgrade -y && \ - apt install -y bash ca-certificates tzdata ffmpeg +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/* -# 复制 auto_pikpak 到第二阶段 -COPY --from=pikpak_server /app/pikpak_captcha_server /app/pikpak_captcha_server -COPY --from=build_alist /app/bin/alist ./ +COPY --from=builder /app/bin/alist ./ COPY entrypoint.sh /entrypoint.sh RUN chmod +x /entrypoint.sh && /entrypoint.sh version diff --git a/Dockerfile_auto_pikpak b/Dockerfile_auto_pikpak new file mode 100644 index 00000000000..691fad56546 --- /dev/null +++ b/Dockerfile_auto_pikpak @@ -0,0 +1,66 @@ +FROM ubuntu AS build_alist +WORKDIR /app/ +# 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 ubuntu AS install_yolov8 +RUN apt update && \ + apt install -y python3 python3-pip python3.12-venv +WORKDIR /app/auto_pikpak/ +# 创建虚拟环境并激活 +RUN python3 -m venv venv && \ + . venv/bin/activate && \ + pip install \ + # pip install \ + ultralytics + +# FROM ubuntu AS install_py2 +# COPY --from=install_yolov8 /app/auto_pikpak/venv /app/pikpak_captcha_server/venv +# RUN apt update && \ +# apt install -y python3 python3-pip python3.12-venv +# WORKDIR /app/pikpak_captcha_server/ +# # 使用虚拟环境中的 Python 安装其他依赖 +# RUN /app/pikpak_captcha_server/venv/bin/python -m pip install --no-cache-dir 2captcha-python Flask + +FROM ubuntu as pikpak_server +RUN apt update && \ + apt install -y git python3 python3-pip python3.12-venv +WORKDIR /app +RUN git clone --depth=1 --recurse-submodules https://github.com/wangjunkai2022/pikpak_captcha_server.git +WORKDIR /app/pikpak_captcha_server +RUN rm -rf /app/pikpak_captcha_server/pikpak_captcha/ai/ai_train_pikpak +COPY --from=install_yolov8 /app/auto_pikpak/venv /app/pikpak_captcha_server/venv +# 使用虚拟环境中的 Python 安装其他依赖 +RUN /app/pikpak_captcha_server/venv/bin/python -m pip install -r requirements.txt +# 安装每个子模块的依赖项 +RUN find . -name 'requirements.txt' -exec /app/pikpak_captcha_server/venv/bin/python -m pip install -r {} \; + +FROM ubuntu +ARG INSTALL_FFMPEG=false +LABEL MAINTAINER="i@nn.ci" + +WORKDIR /opt/alist/ + +RUN apt update && \ + apt upgrade -y && \ + apt install -y bash ca-certificates tzdata ffmpeg + +# 复制 auto_pikpak 到第二阶段 +COPY --from=pikpak_server /app/pikpak_captcha_server /app/pikpak_captcha_server +COPY --from=build_alist /app/bin/alist ./ +COPY entrypoint.sh /entrypoint.sh +RUN chmod +x /entrypoint.sh && /entrypoint.sh version + +ENV PUID=0 PGID=0 UMASK=022 +VOLUME /opt/alist/data/ +EXPOSE 5244 5245 +CMD [ "/entrypoint.sh" ] \ No newline at end of file From a18483987d81272d672e2379b2d0c0f4a6c626fb Mon Sep 17 00:00:00 2001 From: xiaokai Date: Wed, 4 Sep 2024 11:49:17 +0700 Subject: [PATCH 10/10] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=90=8D=E5=AD=97?= =?UTF-8?q?=E4=B8=BAdockerfile.pkserver?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Dockerfile_auto_pikpak => Dockerfile.pkserver | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename Dockerfile_auto_pikpak => Dockerfile.pkserver (100%) diff --git a/Dockerfile_auto_pikpak b/Dockerfile.pkserver similarity index 100% rename from Dockerfile_auto_pikpak rename to Dockerfile.pkserver