| 1 | FROM node:22.21.1 AS builder |
| 2 | |
| 3 | WORKDIR /app |
| 4 | |
| 5 | RUN npm config set registry https://registry.npmmirror.com |
| 6 | |
| 7 | COPY sau_frontend . |
| 8 | |
| 9 | RUN npm install |
| 10 | |
| 11 | ENV NODE_ENV=production |
| 12 | ENV PATH=/app/node_modules/.bin:$PATH |
| 13 | |
| 14 | # 替换前端中的地址 |
| 15 | RUN sed -i 's#\${baseUrl}##g' /app/src/views/AccountManagement.vue |
| 16 | RUN sed -i "s#\${import\.meta\.env\.VITE_API_BASE_URL || 'http:\/\/localhost:5409'}##g" /app/src/api/material.js |
| 17 | RUN sed -i 's#localhost:5409##g' /app/.env.production |
| 18 | |
| 19 | RUN npm run build |
| 20 | |
| 21 | |
| 22 | FROM python:3.10.19 |
| 23 | |
| 24 | WORKDIR /app |
| 25 | |
| 26 | ENV PLAYWRIGHT_BROWSERS_PATH=/opt/playwright |
| 27 | |
| 28 | RUN apt-get update && apt-get install -y --no-install-recommends libnss3 \ |
| 29 | libnspr4 \ |
| 30 | libdbus-1-3 \ |
| 31 | libatk1.0-0 \ |
| 32 | libatk-bridge2.0-0 \ |
| 33 | libatspi2.0-0 \ |
| 34 | libxcomposite1 \ |
| 35 | libxdamage1 \ |
| 36 | libxfixes3 \ |
| 37 | libxrandr2 \ |
| 38 | libgbm1 \ |
| 39 | libxkbcommon0 \ |
| 40 | libasound2 && rm -rf /var/lib/apt/lists/* |
| 41 | |
| 42 | RUN pip config set global.index-url https://mirrors.tuna.tsinghua.edu.cn/pypi/web/simple |
| 43 | |
| 44 | COPY requirements.txt requirements.txt |
| 45 | |
| 46 | RUN pip install -r requirements.txt |
| 47 | |
| 48 | RUN playwright install chromium-headless-shell |
| 49 | |
| 50 | COPY . . |
| 51 | |
| 52 | COPY --from=builder /app/dist/index.html /app |
| 53 | COPY --from=builder /app/dist/assets /app/assets |
| 54 | COPY --from=builder /app/dist/vite.svg /app/assets |
| 55 | |
| 56 | RUN cp conf.example.py conf.py |
| 57 | |
| 58 | RUN mkdir -p /app/videoFile |
| 59 | RUN mkdir -p /app/cookiesFile |
| 60 | |
| 61 | EXPOSE 5409 |
| 62 | |
| 63 | CMD ["python", "sau_backend.py"] |
| 64 |