Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Discuss] docker-compose 方式启动案例 #601

Closed
sgpublic opened this issue Mar 14, 2024 · 0 comments
Closed

[Discuss] docker-compose 方式启动案例 #601

sgpublic opened this issue Mar 14, 2024 · 0 comments

Comments

@sgpublic
Copy link
Contributor

sgpublic commented Mar 14, 2024

注:此方法在 #600 合并后可用

linux 下 docker-compose 样例:

version: '3'
services:
  app:
    image: mhmzx/poetry-runner:bullseye-20240311
    container_name: princess-connection-farm
    volumes:
      - /mnt/core/app/princess-connection-farm/app:/app
      - /mnt/core/app/princess-connection-farm/.venv:/app/.venv # 如果删掉了 poetry.toml 就可以把这行删掉了
      - /mnt/core/app/princess-connection-farm/.data/batches:/app/batches
      - /mnt/core/app/princess-connection-farm/.data/bind_schedule.txt:/app/bind_schedule.txt
      - /mnt/core/app/princess-connection-farm/.data/config.ini:/app/config.ini
      - /mnt/core/app/princess-connection-farm/.data/data:/app/data
      - /mnt/core/app/princess-connection-farm/.data/error_screenshot:/app/error_screenshot
      - /mnt/core/app/princess-connection-farm/.data/groups:/app/groups
      - /mnt/core/app/princess-connection-farm/.data/log:/app/log
      - /mnt/core/app/princess-connection-farm/.data/pcrdata:/app/pcrdata
      - /mnt/core/app/princess-connection-farm/.data/rec:/app/rec
      - /mnt/core/app/princess-connection-farm/.data/schedules:/app/schedules
      - /mnt/core/app/princess-connection-farm/.data/switches:/app/switches
      - /mnt/core/app/princess-connection-farm/.data/tasks:/app/tasks
      - /mnt/core/app/princess-connection-farm/.data/users:/app/users
      - /mnt/core/app/princess-connection-farm/start:/start
      - /mnt/core/app/princess-connection-farm/.data/.android:/home/poetry-runner/.android
      - /mnt/core/home/.ssh/docker:/home/poetry-runner/.ssh
      - /mnt/core/var/tmp/princess-connection-farm:/home/poetry-runner/.cache
    restart: unless-stopped

目录结构:

madray@NAS:/mnt/core/app/princess-connection-farm$ tree -L 2 -aF
.
├── app/
│   └──  # 项目克隆下来
├── .data/
│   ├── .android/
│   ├── atches/
│   ├── batches/
│   ├── bind_schedule.txt
│   ├── config.ini
│   ├── error_screenshot/
│   ├── groups/
│   ├── log/
│   ├── pcrdata/data.db
│   ├── rec/
│   ├── schedules/
│   ├── switches/
│   ├── tasks/
│   └── users/
├── start # 启动脚本
└── .venv/
    └── # 虚拟环境目录

start(启动脚本):

#!/bin/bash

mkdir -p ~/.cache/pcr
if [ ! -e "~/.cache/pcr/git.date" ]; then
        echo 0 > ~/.cache/pcr/git.date
fi

now=$(date +%Y%m%d)

pip config set global.index-url https://mirrors.aliyun.com/pypi/simple/

if [ ! "$(cat ~/.cache/pcr/git.date)" == "$now" ]; then
        timeout 1m git pull
        poetry install
        echo "$now" > ~/.cache/pcr/git.date
fi

poetry run python3 main_new.py first daily # 请提前创建相关 schedule
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant