From b589f82b6ce4e57a02e4a146dd6ceab427e3a55e Mon Sep 17 00:00:00 2001 From: jbwfu <75001777+jbwfu@users.noreply.github.com> Date: Wed, 31 Aug 2022 12:08:13 +0800 Subject: [PATCH] feat: add tutorial to deploy on Replit (#1731) --- README.md | 18 ++++++++++++++++++ install-replit.sh | 28 ++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+) create mode 100644 install-replit.sh diff --git a/README.md b/README.md index 222d640..34efc41 100644 --- a/README.md +++ b/README.md @@ -142,6 +142,24 @@ docker-compose up -d YesPlayMusic 地址为 `http://localhost` +## ⚙️ 部署至 Replit + +1. 新建 Repl,选择 Bash 模板 + +2. 在 Replit shell 中运行以下命令 + +```sh +bash <(curl -s -L https://raw.githubusercontent.com/qier222/YesPlayMusic/main/install-replit.sh) +``` + +3. 首次运行成功后,只需点击绿色按钮 `Run` 即可再次运行 + +4. 由于 replit 个人版限制内存为 1G(教育版为 3G),构建过程中可能会失败,请再次运行上述命令或运行以下命令: + +```sh +cd /home/runner/${REPL_SLUG}/music && yarn installl && yarn run build +``` + ## 👷‍♂️ 打包客户端 如果在 Release 页面没有找到适合你的设备的安装包的话,你可以根据下面的步骤来打包自己的客户端。 diff --git a/install-replit.sh b/install-replit.sh new file mode 100644 index 0000000..c17e438 --- /dev/null +++ b/install-replit.sh @@ -0,0 +1,28 @@ + #!/usr/bin/bash + +# 初始化 .replit 和 replit.nix +if [[ $1 == i ]];then + echo -e 'run = ["bash", "main.sh"]\n\nentrypoint = "main.sh"' >.replit + echo -e "{ pkgs }: {\n\t\tdeps = [\n\t\t\tpkgs.nodejs-16_x\n\t\t\tpkgs.yarn\n\t\t\tpkgs.bashInteractive\n\t\t];\n}" > replit.nix + exit +fi + +# 安装 +if [[ ! -d api ]];then + mkdir api + git clone https://github.com/Binaryify/NeteaseCloudMusicApi ./api && \ + cd api && npm install && cd .. +fi + +if [[ ! -d music ]];then + mkdir music + git clone https://github.com/qier222/YesPlayMusic ./music && \ + cd music && cp .env.example .env && npm install --force && npm run build && cd .. +fi + +# 启动 +PID=`ps -ef | grep npm | awk '{print $2}' | sed '$d'` + +if [[ ! -z ${PID} ]];then echo $PID | xargs kill;fi +nohup bash -c 'cd api && PORT=35216 node app.js' > api.log 2>&1 +nohup bash -c 'npx serve music/dist/' > music.log 2>&1