Compare commits
8 Commits
main
...
docker-com
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c8a4a40ae9 | ||
|
|
3272d09900 | ||
|
|
5a8da02f24 | ||
|
|
039c8d937a | ||
|
|
73845efee3 | ||
|
|
578744eddd | ||
|
|
24cf1f788b | ||
|
|
5052727dc5 |
22
.github/workflows/docker-build.yml
vendored
22
.github/workflows/docker-build.yml
vendored
@ -17,9 +17,18 @@ jobs:
|
|||||||
uses: docker/build-push-action@v5
|
uses: docker/build-push-action@v5
|
||||||
with:
|
with:
|
||||||
context: .
|
context: .
|
||||||
file: ./Dockerfile # 指定 Dockerfile 路径
|
file: ./Dockerfile
|
||||||
tags: registry.fandouke.com/test-image:latest # 镜像标签(包含 Registry 地址)
|
tags: registry.fandouke.com/test-image:latest
|
||||||
push: true
|
push: true
|
||||||
|
|
||||||
|
- name: 拷贝docker-compose文件到远程服务器📄
|
||||||
|
uses: appleboy/scp-action@v0.1.4
|
||||||
|
with:
|
||||||
|
host: ${{ secrets.REMOTE_HOST }}
|
||||||
|
username: ${{ secrets.REMOTE_USER }}
|
||||||
|
password: ${{ secrets.REMOTE_PASSWORD }}
|
||||||
|
source: "docker-compose.yml"
|
||||||
|
target: "/home/${{ secrets.REMOTE_USER }}/app"
|
||||||
|
|
||||||
- name: 部署到远程服务器🚀
|
- name: 部署到远程服务器🚀
|
||||||
uses: appleboy/ssh-action@v1.0.3
|
uses: appleboy/ssh-action@v1.0.3
|
||||||
@ -28,11 +37,8 @@ jobs:
|
|||||||
username: ${{ secrets.REMOTE_USER }}
|
username: ${{ secrets.REMOTE_USER }}
|
||||||
password: ${{ secrets.REMOTE_PASSWORD }}
|
password: ${{ secrets.REMOTE_PASSWORD }}
|
||||||
script: |
|
script: |
|
||||||
docker pull registry.fandouke.com/test-image:latest
|
cd /home/${{ secrets.REMOTE_USER }}/app
|
||||||
docker stop test-container || true
|
docker-compose down || true
|
||||||
docker rm test-container || true
|
docker-compose up -d
|
||||||
docker run -d --name test-container \
|
|
||||||
-p 5321:5000 \
|
|
||||||
registry.fandouke.com/test-image:latest
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
46
.github/workflows/docker-compose-build.yml
vendored
Normal file
46
.github/workflows/docker-compose-build.yml
vendored
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
name: 打包发布docker镜像
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches: [ docker-compose ]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build-push:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: 拉取代码🔄
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Set up Docker Buildx🔧
|
||||||
|
uses: docker/setup-buildx-action@v3
|
||||||
|
|
||||||
|
- name: 打包并发布镜像📦
|
||||||
|
uses: docker/build-push-action@v5
|
||||||
|
with:
|
||||||
|
context: .
|
||||||
|
file: ./Dockerfile
|
||||||
|
tags: registry.fandouke.com/test-image:latest
|
||||||
|
push: true
|
||||||
|
|
||||||
|
- name: 拷贝docker-compose文件到远程服务器📄
|
||||||
|
uses: appleboy/scp-action@v0.1.4
|
||||||
|
with:
|
||||||
|
host: 8.138.188.137
|
||||||
|
port: 13502
|
||||||
|
username: ${{ secrets.REMOTE_USER }}
|
||||||
|
password: ${{ secrets.REMOTE_PASSWORD }}
|
||||||
|
source: "docker-compose.yml"
|
||||||
|
target: "/home/${{ secrets.REMOTE_USER }}/app"
|
||||||
|
|
||||||
|
- name: 部署到远程服务器🚀
|
||||||
|
uses: appleboy/ssh-action@v1.0.3
|
||||||
|
with:
|
||||||
|
host: 8.138.188.137
|
||||||
|
port: 13502
|
||||||
|
username: ${{ secrets.REMOTE_USER }}
|
||||||
|
password: ${{ secrets.REMOTE_PASSWORD }}
|
||||||
|
script: |
|
||||||
|
cd /home/${{ secrets.REMOTE_USER }}/app
|
||||||
|
docker-compose down || true
|
||||||
|
docker-compose up -d
|
||||||
|
|
||||||
|
|
||||||
@ -1,4 +1,4 @@
|
|||||||
FROM python:3.10-alpine
|
FROM dockerproxy.fandouke.com/python:3.10-alpine
|
||||||
|
|
||||||
COPY . .
|
COPY . .
|
||||||
|
|
||||||
|
|||||||
8
docker-compose.yml
Normal file
8
docker-compose.yml
Normal 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
|
||||||
Loading…
x
Reference in New Issue
Block a user