├── logs └── .gitkeep ├── mongodb └── .gitkeep ├── rabbitmq └── .gitkeep ├── storage └── .gitkeep ├── nginx ├── certificates │ └── .gitkeep └── templates │ └── default.conf.template ├── .gitignore ├── oss └── image-styles.txt ├── Makefile ├── docker-compose.gpu.yml ├── LICENSE ├── .env.sample ├── docker-compose.dev.yml ├── README.md ├── .github └── workflows │ └── update-labelplus-releases.yml ├── .env-backend.sample └── docker-compose.yml /logs/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /mongodb/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /rabbitmq/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /storage/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /nginx/certificates/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /mongodb/** 2 | /nginx/certificates/** 3 | /rabbitmq/** 4 | /logs/** 5 | /storage/** 6 | .env* 7 | !.env*.sample 8 | !.gitkeep 9 | 10 | .DS_Store 11 | -------------------------------------------------------------------------------- /oss/image-styles.txt: -------------------------------------------------------------------------------- 1 | styleName:cover,styleBody:image/auto-orient,1/interlace,1/resize,m_fill,w_180,h_140/quality,q_90/format,jpg 2 | styleName:safe-check,styleBody:image/auto-orient,1/interlace,1/resize,m_pad,w_400,h_500/quality,q_90/format,jpg -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | LOG_LEVEL := INFO 2 | # LOG_LEVEL := DEBUG 3 | 4 | 5 | BACKEND_REPO := ../moeflow-backend 6 | FRONTEND_REPO = ../moeflow-frontend 7 | 8 | dev-deps: 9 | exec docker-compose -f docker-compose.yml -f docker-compose.dev.yml up moeflow-mongodb moeflow-rabbitmq mongo-gui 10 | 11 | frontend-dev: 12 | cd $(FRONTEND_REPO) && npm run build:locale && exec npm start 13 | 14 | backend-dev: 15 | cd $(BACKEND_REPO) && make babel-update-mo && exec venv/bin/gunicorn -t 120 -w 4 --reload -b 127.0.0.1:5200 --log-level=${LOG_LEVEL} "app:create_app()" 16 | 17 | backend-worker: 18 | cd $(BACKEND_REPO) && exec venv/bin/celery --app app.celery worker --queues default,output --hostname celery.default --loglevel=${LOG_LEVEL} 19 | -------------------------------------------------------------------------------- /docker-compose.gpu.yml: -------------------------------------------------------------------------------- 1 | services: 2 | moeflow-celery-mit: 3 | image: ${GHCR_DOMAIN}/${MOEFLOW_MIT_WORKER_IMAGE:-UNSET}:${MOEFLOW_MIT_WORKER_VERSION:-UNSET} 4 | restart: unless-stopped 5 | volumes: 6 | - ./storage:/app/storage 7 | env_file: 8 | - '.env-mit-worker' 9 | entrypoint: bash 10 | command: 11 | - -uexc 12 | - | 13 | exec conda run -n mit-py311 --no-capture-output celery --app moeflow_worker worker --queues mit --loglevel=debug --concurrency=1 14 | links: [moeflow-rabbitmq, moeflow-mongodb] 15 | profiles: [mit-worker] 16 | depends_on: *backend-deps 17 | deploy: 18 | resources: 19 | reservations: 20 | devices: 21 | - driver: nvidia 22 | count: 1 23 | capabilities: 24 | - gpu 25 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2022 kozzzx 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /.env.sample: -------------------------------------------------------------------------------- 1 | # docker-compose env 2 | # 模板中值为 CHANGE_ME 的设置项涉及安全,请务必修改 3 | # ----------- 4 | # App 配置 5 | # ----------- 6 | # Docker Hub 仓库地址,国外服务器请填写 docker.io,国内服务器请填写镜像站 docker.nju.edu.cn 7 | DH_DOMAIN=docker.io 8 | # GHCR 仓库地址,国外服务器请填写 ghcr.io,国内服务器请填写镜像站 ghcr.nju.edu.cn 9 | GHCR_DOMAIN=ghcr.io 10 | # (可不修改) 在未来升级萌翻程序时修改版本号,并重新 docker-compose up 11 | # 建议非开发者只用有版本号的 `vx.y.z` image 12 | MOEFLOW_FRONTEND_IMAGE=moeflow-com/moeflow-frontend 13 | MOEFLOW_FRONTEND_VERSION=v1.1.7 14 | MOEFLOW_BACKEND_IMAGE=moeflow-com/moeflow-backend 15 | MOEFLOW_BACKEND_VERSION=v1.1.8 16 | 17 | # 【请修改】请填写您指向服务器的域名(不包含 www.)或 IP 地址。用于生成静态文件域名。 18 | DOMAIN=CHANGE_ME.moeflow.com 19 | 20 | # map nginx 80/443 to these ports 21 | HTTP_PORT=80 22 | HTTPS_PORT=443 23 | 24 | # Deps 25 | # (可不修改) MongoDB 账号,将在初次启动时设置 26 | MONGODB_USER=moeflow 27 | # 【请修改】MongoDB 密码,将在初次启动时设置 28 | MONGODB_PASS=CHANGE_ME 29 | # (可不修改) RabbitMQ 账号,将在初次启动时设置 30 | RABBITMQ_USER=moeflow 31 | # 【请修改】RabbitMQ 密码,将在初次启动时设置 32 | RABBITMQ_PASS=CHANGE_ME 33 | # (可不修改) APP 专用的 RabbitMQ Virtual Host 名称 34 | RABBITMQ_VHOST_NAME=moeflow 35 | 36 | # (可不修改) 允许上传文件的最大大小(MB),默认 1GB 37 | MAX_CONTENT_LENGTH_MB=1024 38 | 39 | # 可选的mit 翻译辅助worker 40 | # 目前不成熟,不建议开启 41 | # COMPOSE_PROFILES=mit-worker 42 | # MOEFLOW_MIT_WORKER_IMAGE=moeflow-com/manga-image-translator 43 | # MOEFLOW_MIT_WORKER_VERSION=sha-d0fed2d 44 | -------------------------------------------------------------------------------- /docker-compose.dev.yml: -------------------------------------------------------------------------------- 1 | services: 2 | moeflow-mongodb: 3 | ports: 4 | - 127.0.0.1:27017:27017 5 | 6 | moeflow-rabbitmq: 7 | ports: 8 | - 127.0.0.1:5672:5672 # AMQP 9 | - 127.0.0.1:15672:15672 # management UI 10 | 11 | mongo-gui: 12 | image: ugleiton/mongo-gui 13 | restart: unless-stopped 14 | ports: 15 | - "4321:4321" 16 | environment: 17 | MONGO_URL: mongodb://${MONGODB_USER}:${MONGODB_PASS}@moeflow-mongodb:27017/moeflow?authSource=admin 18 | logging: 19 | driver: none 20 | attach: false 21 | 22 | moeflow-backend: 23 | build: ../moeflow-backend # for local dev 24 | ports: 25 | - 127.0.0.1:5000:5000 26 | # TODO: should prepend `pip install` to gunicorn ? 27 | command: gunicorn -t 120 -w 1 --reload -b 0.0.0.0:5000 --log-level=DEBUG "app:create_app()" 28 | # environment: 29 | # LOG_LEVEL: DEBUG 30 | volumes: 31 | - ../moeflow-backend:/app # gets merged with docker-compose.yml 32 | 33 | moeflow-backend-init: 34 | command: python3 manage.py migrate 35 | 36 | moeflow-celery-default: 37 | command: celery --app app.celery worker --queues default --hostname celery.default --loglevel=debug 38 | 39 | moeflow-celery-output: 40 | command: celery --app app.celery worker --queues output --hostname celery.output --loglevel=debug 41 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # moeflow-deploy 2 | 3 | 用于自己部署萌翻服务的配置。 4 | 5 | 请参见部署视频演示 https://www.bilibili.com/video/BV1EX4y1J7MA/ 6 | 7 | ## docker compose 8 | 9 | 建议的部署方式。 10 | 11 | 0. 安装 [docker](https://docs.docker.com/engine/install/) 和 [docker-compose-plugin](https://docs.docker.com/compose/install/) 12 | - 注: 旧版本docker-compose可能无法正确设置环境变量. docker-compose-plugin v2.27.0 经测试可用. 13 | 1. 下载本repo的 [最新release](https://github.com/moeflow-com/moeflow-deploy/releases) 并解压 14 | - 非开发者不建议clone本repo: 代码最新状态可能和image不匹配 15 | 2. 将 `.env-backend.sample` 模板复制为 `.env-backend` ,并按模板内说明设置环境变量 16 | 3. 将 `.env.sample` 模板复制为 `.env` ,并按模板内说明设置环境变量 17 | 4. 运行 `docker compose up` 18 | 19 | ## FAQ 20 | 21 | ### 修改主页内容 22 | 23 | 升级前端版本至 `v1.0.3` 后端版本至 `v1.0.8` 后,即可在管理员页面-站点管理中,设置主页 HTML 和 CSS,以下为示例: 24 | 25 | 主页 HTML 26 | 27 | ```html 28 |
37 | 38 | ``` 39 | 40 | 主页 CSS 41 | 42 | ```css 43 | html { 44 | width: 100%; 45 | height: 100%; 46 | } 47 | body { 48 | width: 100%; 49 | height: 100%; 50 | margin: 0; 51 | display: flex; 52 | flex-direction: column; 53 | justify-content: center; 54 | align-items: center; 55 | } 56 | .homepage-title { 57 | flex: auto; 58 | display: flex; 59 | flex-direction: column; 60 | justify-content: center; 61 | align-items: center; 62 | } 63 | .homepage-footer { 64 | height: 50px; 65 | text-align: center; 66 | } 67 | ``` 68 | -------------------------------------------------------------------------------- /.github/workflows/update-labelplus-releases.yml: -------------------------------------------------------------------------------- 1 | # Download labelplus latest releases, convert to .zip and upload to OSS 2 | 3 | name: Update labelplus latest releases 4 | 5 | on: 6 | workflow_dispatch: 7 | 8 | jobs: 9 | update: 10 | runs-on: ubuntu-latest 11 | steps: 12 | - name: Download Labelplus Release Assets 13 | uses: houqp/download-release-assets-action@v1.0.1 14 | with: 15 | repo: LabelPlus/LabelPlus 16 | match: "LabelPlus_.+" 17 | rename: LabelPlus_latest.7z 18 | 19 | - name: Download Labelplus Photoshop Script Release Assets 20 | uses: houqp/download-release-assets-action@v1.0.1 21 | with: 22 | repo: LabelPlus/PS-Script 23 | match: "LabelPlus_PS-Script_.+" 24 | rename: LabelPlus_PS-Script_latest.7z 25 | 26 | - run: sudo apt -y install atool 27 | - run: mkdir releases 28 | 29 | - run: arepack -e -F zip LabelPlus_latest.7z 30 | - run: mv LabelPlus_latest.zip releases/LabelPlus_latest.zip 31 | - run: arepack -e -F zip LabelPlus_PS-Script_latest.7z 32 | - run: mv LabelPlus_PS-Script_latest.zip releases/LabelPlus_PS-Script_latest.zip 33 | 34 | - name: Upload to oss 35 | id: upload_to_oss 36 | uses: tvrcgo/upload-to-oss@v0.1.1 37 | with: 38 | key-id: ${{ secrets.KOZZZX_FILES_OSS_KEY_ID }} 39 | key-secret: ${{ secrets.KOZZZX_FILES_OSS_KEY_SECRET }} 40 | region: oss-cn-shanghai 41 | bucket: kozzzx-files 42 | asset-path: ./releases 43 | target-path: /labelplus/ 44 | -------------------------------------------------------------------------------- /.env-backend.sample: -------------------------------------------------------------------------------- 1 | # upstream: https://github.com/moeflow-com/moeflow-backend/blob/main/.env.sample 2 | # with values set in docker-compose.yml commented out 3 | 4 | # Template of moeflow-backend env variables / 萌翻Backend的环境变量模板 5 | # values like `change_me` SHOULD be changed. They are related to security or basic functionality. 6 | # 模板中值为 CHANGE_ME 的设置涉及安全或基础功能,请一定在部署时修改 7 | 8 | # site name 9 | SITE_NAME=Moeflow 10 | SITE_ORIGIN=https://change_me.com 11 | 12 | # encrypt key of user sessions. 13 | SECRET_KEY=CHANGE_ME 14 | 15 | # auto-created admin user and password 16 | ADMIN_EMAIL=change_me@change_me.com 17 | ADMIN_INITIAL_PASSWORD=change_me 18 | 19 | # mongodb database 20 | # MONGODB_URI='mongodb://moeflow:PLEASE_CHANGE_THIS@moeflow-mongodb:27017/moeflow?authSource=admin' 21 | 22 | # celery job queue 23 | # CELERY_BROKER_URL="amqp://moeflow:PLEASE_CHANGE_THIS@moeflow-rabbitmq:5672/moeflow" 24 | 25 | # ----------- 26 | # Storage 配置 27 | # ----------- 28 | # 目前支持 LOCAL_STORAGE 和 OSS 29 | STORAGE_TYPE=LOCAL_STORAGE 30 | # STORAGE_DOMAIN: 返回给客户端的图片URL前缀 31 | # 1. 如果STORAGE_TYPE为OSS 32 | # - 未设置自定义域名则填写阿里云提供的 OSS 域名,格式如:https://