添加 docker-compose.yml 文件以支持容器编排,并更新 GitHub Actions 工作流以使用 docker-compose 管理容器生命周期。

This commit is contained in:
MR-ZC 2025-03-25 19:00:47 +08:00
parent 554708b062
commit 5052727dc5
2 changed files with 12 additions and 7 deletions

View File

@ -17,8 +17,8 @@ jobs:
uses: docker/build-push-action@v5
with:
context: .
file: ./Dockerfile # 指定 Dockerfile 路径
tags: registry.fandouke.com/test-image:latest # 镜像标签(包含 Registry 地址)
file: ./Dockerfile
tags: registry.fandouke.com/test-image:latest
push: true
- name: 部署到远程服务器🚀
@ -29,10 +29,7 @@ jobs:
password: ${{ secrets.REMOTE_PASSWORD }}
script: |
docker pull registry.fandouke.com/test-image:latest
docker stop test-container || true
docker rm test-container || true
docker run -d --name test-container \
-p 5321:5000 \
registry.fandouke.com/test-image:latest
docker-compose down || true
docker-compose up -d

8
docker-compose.yml Normal file
View File

@ -0,0 +1,8 @@
version: '3'
services:
test-app:
image: registry.fandouke.com/test-image:latest
container_name: test-container
ports:
- "5321:5000"
restart: unless-stopped