From 3d13f5856a9345bc725ad62af30f8db5eadb6ec1 Mon Sep 17 00:00:00 2001 From: zhangwenjian Date: Thu, 27 Aug 2026 12:48:32 +0800 Subject: [PATCH] =?UTF-8?q?ci=F0=9F=94=A7:=20point=20the=20demo=20at=20the?= =?UTF-8?q?=20managed=20database?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The demo ran on the sqlite file baked into the image, so every deploy reset it and nothing there resembled how anyone actually runs this. The config is mounted from the host rather than taken from the image. config/settings.demo.yml ships in a public repository and is copied into a public image, so the connection string cannot live there; that copy stays on sqlite, which is what a fresh clone should get. The deploy refuses to start if the host config is missing, rather than falling back to the image's sqlite and looking like it worked. --- .github/workflows/build.yml | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index e6a69879..82d82f09 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -65,7 +65,14 @@ jobs: username: ${{ secrets.SSH_USERNAME }} key: ${{ secrets.DEPLOY_KEY }} # 重启的脚本,根据自身情况做相应改动,一般要做的是migrate数据库以及重启服务器 + # + # 配置从宿主机挂载,不使用镜像里的那份:演示站连的是托管 MySQL, + # 而 config/settings.demo.yml 会随仓库公开、也会打进镜像,凭据不能写在那里。 + # 镜像里那份保持 sqlite,供 clone 仓库的人开箱即用。 script: | + test -f /www/vue-demo/config/settings.yml || { echo "缺少 /www/vue-demo/config/settings.yml,中止部署"; exit 1; } sudo docker rm -f go-admin-api sudo docker login --username=${{ secrets.DOCKER_USERNAME }} registry.ap-northeast-1.aliyuncs.com --password=${{ secrets.DOCKER_PASSWORD }} - sudo docker run -d -p 8000:8000 --name go-admin-api ${{ env.IMAGE_NAME_TAG }} + sudo docker run -d -p 8000:8000 \ + -v /www/vue-demo/config/settings.yml:/config/settings.yml:ro \ + --name go-admin-api ${{ env.IMAGE_NAME_TAG }}