尝试gitea action
This commit is contained in:
@@ -1,29 +1,73 @@
|
|||||||
name: Build and Push Docker Image
|
name: Build and Push Docker Images
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches:
|
branches: [ main ]
|
||||||
- main
|
tags: [ 'v*' ]
|
||||||
|
pull_request:
|
||||||
|
branches: [ main ]
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build-and-push:
|
build-and-push:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
service: [frontend, backend]
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout code
|
- name: Checkout code
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Set up Docker Buildx
|
- name: Set up Docker Buildx
|
||||||
uses: docker/setup-buildx-action@v2
|
uses: docker/setup-buildx-action@v3
|
||||||
|
|
||||||
- name: Login to Docker Hub
|
- name: Login to Registry
|
||||||
uses: docker/login-action@v2
|
uses: docker/login-action@v3
|
||||||
with:
|
with:
|
||||||
username: ${{ secrets.DOCKER_USERNAME }}
|
registry: gitea.zfxt.top
|
||||||
password: ${{ secrets.DOCKER_PASSWORD }}
|
username: ${{ secrets.REGISTRY_USERNAME }}
|
||||||
|
password: ${{ secrets.AUTH_TOKEN }}
|
||||||
|
|
||||||
- name: Build and push
|
- name: Extract metadata for backend
|
||||||
uses: docker/build-push-action@v4
|
if: matrix.service == 'backend'
|
||||||
with:
|
id: meta-backend
|
||||||
context: .
|
uses: docker/metadata-action@v5
|
||||||
push: true
|
with:
|
||||||
tags: your-dockerhub-username/your-repo-name:latest
|
images: gitea.zfxt.top/zfxt/backend
|
||||||
|
tags: |
|
||||||
|
type=ref,event=branch
|
||||||
|
type=ref,event=pr
|
||||||
|
type=semver,pattern={{version}}
|
||||||
|
type=semver,pattern={{major}}.{{minor}}
|
||||||
|
|
||||||
|
- name: Extract metadata for frontend
|
||||||
|
if: matrix.service == 'frontend'
|
||||||
|
id: meta-frontend
|
||||||
|
uses: docker/metadata-action@v5
|
||||||
|
with:
|
||||||
|
images: gitea.zfxt.top/zfxt/frontend
|
||||||
|
tags: |
|
||||||
|
type=ref,event=branch
|
||||||
|
type=ref,event=pr
|
||||||
|
type=semver,pattern={{version}}
|
||||||
|
type=semver,pattern={{major}}.{{minor}}
|
||||||
|
|
||||||
|
- name: Build and push backend image
|
||||||
|
if: matrix.service == 'backend'
|
||||||
|
uses: docker/build-push-action@v5
|
||||||
|
with:
|
||||||
|
context: ./backend
|
||||||
|
file: ./backend/dockerfile
|
||||||
|
push: true
|
||||||
|
tags: ${{ steps.meta-backend.outputs.tags }}
|
||||||
|
labels: ${{ steps.meta-backend.outputs.labels }}
|
||||||
|
|
||||||
|
- name: Build and push frontend image
|
||||||
|
if: matrix.service == 'frontend'
|
||||||
|
uses: docker/build-push-action@v5
|
||||||
|
with:
|
||||||
|
context: ./front
|
||||||
|
file: ./front/dockerfile
|
||||||
|
push: true
|
||||||
|
tags: ${{ steps.meta-frontend.outputs.tags }}
|
||||||
|
labels: ${{ steps.meta-frontend.outputs.labels }}
|
||||||
@@ -2,26 +2,22 @@ version: '3.8'
|
|||||||
|
|
||||||
services:
|
services:
|
||||||
frontend:
|
frontend:
|
||||||
build:
|
|
||||||
context: ./front
|
|
||||||
dockerfile: dockerfile
|
|
||||||
container_name: my-frontend-web
|
|
||||||
image: gitea.zfxt.top/zfxt/frontend:latest
|
image: gitea.zfxt.top/zfxt/frontend:latest
|
||||||
|
container_name: my-frontend-web
|
||||||
ports:
|
ports:
|
||||||
- "5555:5555" # 修改为5555端口映射
|
- "5555:5555"
|
||||||
depends_on:
|
depends_on:
|
||||||
- backend
|
- backend
|
||||||
networks:
|
networks:
|
||||||
- app-network
|
- app-network
|
||||||
|
# 移除了build配置,因为我们现在使用预构建的镜像
|
||||||
|
|
||||||
backend:
|
backend:
|
||||||
build:
|
|
||||||
context: ./backend
|
|
||||||
dockerfile: dockerfile
|
|
||||||
image: gitea.zfxt.top/zfxt/backend:latest
|
image: gitea.zfxt.top/zfxt/backend:latest
|
||||||
container_name: my-backend-api # 设置后端容器名
|
container_name: my-backend-api
|
||||||
networks:
|
networks:
|
||||||
- app-network
|
- app-network
|
||||||
|
# 移除了build配置,因为我们现在使用预构建的镜像
|
||||||
|
|
||||||
networks:
|
networks:
|
||||||
app-network:
|
app-network:
|
||||||
|
|||||||
Reference in New Issue
Block a user