Merge pull request #156 from gzxy0102/fix-docker

fix: Docker环境修复
This commit is contained in:
Alleria
2025-11-21 09:49:00 +08:00
committed by GitHub
3 changed files with 28 additions and 13 deletions
+13 -5
View File
@@ -1,4 +1,4 @@
FROM node:22.21.1 as builder FROM node:22.21.1 AS builder
WORKDIR /app WORKDIR /app
@@ -11,6 +11,11 @@ RUN npm install
ENV NODE_ENV=production ENV NODE_ENV=production
ENV PATH=/app/node_modules/.bin:$PATH ENV PATH=/app/node_modules/.bin:$PATH
# 替换前端中的地址
RUN sed -i 's#\${baseUrl}##g' /app/src/views/AccountManagement.vue
RUN sed -i "s#\${import\.meta\.env\.VITE_API_BASE_URL || 'http:\/\/localhost:5409'}##g" /app/src/api/material.js
RUN sed -i 's#localhost:5409##g' /app/.env.production
RUN npm run build RUN npm run build
@@ -20,10 +25,6 @@ WORKDIR /app
ENV PLAYWRIGHT_BROWSERS_PATH=/opt/playwright ENV PLAYWRIGHT_BROWSERS_PATH=/opt/playwright
COPY --from=builder /app/dist/index.html /app
COPY --from=builder /app/dist/assets /app/assets
COPY --from=builder /app/dist/vite.svg /app
RUN apt-get update && apt-get install -y --no-install-recommends libnss3 \ RUN apt-get update && apt-get install -y --no-install-recommends libnss3 \
libnspr4 \ libnspr4 \
libdbus-1-3 \ libdbus-1-3 \
@@ -48,8 +49,15 @@ RUN playwright install chromium-headless-shell
COPY . . COPY . .
COPY --from=builder /app/dist/index.html /app
COPY --from=builder /app/dist/assets /app/assets
COPY --from=builder /app/dist/vite.svg /app/assets
RUN cp conf.example.py conf.py RUN cp conf.example.py conf.py
RUN mkdir -p /app/videoFile
RUN mkdir -p /app/cookiesFile
EXPOSE 5409 EXPOSE 5409
CMD ["python", "sau_backend.py"] CMD ["python", "sau_backend.py"]
+9 -6
View File
@@ -5,15 +5,16 @@ import os
from playwright.async_api import async_playwright from playwright.async_api import async_playwright
from xhs import XhsClient from xhs import XhsClient
from conf import BASE_DIR from conf import BASE_DIR, LOCAL_CHROME_HEADLESS
from utils.base_social_media import set_init_script from utils.base_social_media import set_init_script
from utils.log import tencent_logger, kuaishou_logger, douyin_logger from utils.log import tencent_logger, kuaishou_logger, douyin_logger
from pathlib import Path from pathlib import Path
from uploader.xhs_uploader.main import sign_local from uploader.xhs_uploader.main import sign_local
async def cookie_auth_douyin(account_file): async def cookie_auth_douyin(account_file):
async with async_playwright() as playwright: async with async_playwright() as playwright:
browser = await playwright.chromium.launch(headless=True) browser = await playwright.chromium.launch(headless=LOCAL_CHROME_HEADLESS)
context = await browser.new_context(storage_state=account_file) context = await browser.new_context(storage_state=account_file)
context = await set_init_script(context) context = await set_init_script(context)
# 创建一个新的页面 # 创建一个新的页面
@@ -38,9 +39,10 @@ async def cookie_auth_douyin(account_file):
await browser.close() await browser.close()
return False return False
async def cookie_auth_tencent(account_file): async def cookie_auth_tencent(account_file):
async with async_playwright() as playwright: async with async_playwright() as playwright:
browser = await playwright.chromium.launch(headless=True) browser = await playwright.chromium.launch(headless=LOCAL_CHROME_HEADLESS)
context = await browser.new_context(storage_state=account_file) context = await browser.new_context(storage_state=account_file)
context = await set_init_script(context) context = await set_init_script(context)
# 创建一个新的页面 # 创建一个新的页面
@@ -55,9 +57,10 @@ async def cookie_auth_tencent(account_file):
tencent_logger.success("[+] cookie 有效") tencent_logger.success("[+] cookie 有效")
return True return True
async def cookie_auth_ks(account_file): async def cookie_auth_ks(account_file):
async with async_playwright() as playwright: async with async_playwright() as playwright:
browser = await playwright.chromium.launch(headless=True) browser = await playwright.chromium.launch(headless=LOCAL_CHROME_HEADLESS)
context = await browser.new_context(storage_state=account_file) context = await browser.new_context(storage_state=account_file)
context = await set_init_script(context) context = await set_init_script(context)
# 创建一个新的页面 # 创建一个新的页面
@@ -76,7 +79,7 @@ async def cookie_auth_ks(account_file):
async def cookie_auth_xhs(account_file): async def cookie_auth_xhs(account_file):
async with async_playwright() as playwright: async with async_playwright() as playwright:
browser = await playwright.chromium.launch(headless=True) browser = await playwright.chromium.launch(headless=LOCAL_CHROME_HEADLESS)
context = await browser.new_context(storage_state=account_file) context = await browser.new_context(storage_state=account_file)
context = await set_init_script(context) context = await set_init_script(context)
# 创建一个新的页面 # 创建一个新的页面
@@ -99,7 +102,7 @@ async def cookie_auth_xhs(account_file):
return True return True
async def check_cookie(type,file_path): async def check_cookie(type, file_path):
match type: match type:
# 小红书 # 小红书
case 1: case 1:
+6 -2
View File
@@ -32,8 +32,12 @@ def custom_static(filename):
# 处理 favicon.ico 静态资源(未来打包用) # 处理 favicon.ico 静态资源(未来打包用)
@app.route('/favicon.ico') @app.route('/favicon.ico')
def favicon(filename): def favicon():
return send_from_directory(os.path.join(current_dir, 'assets'), 'favicon.ico') return send_from_directory(os.path.join(current_dir, 'assets'), 'vite.svg')
@app.route('/vite.svg')
def vite_svg():
return send_from_directory(os.path.join(current_dir, 'assets'), 'vite.svg')
# (未来打包用) # (未来打包用)
@app.route('/') @app.route('/')