Compare commits
9
Commits
f364821128
...
aabbf2abac
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
aabbf2abac | ||
|
|
886b551d10 | ||
|
|
ca2ba8b08d | ||
|
|
e2f1d0ba23 | ||
|
|
2897b8c547 | ||
|
|
8a498987b2 | ||
|
|
88b4f97a26 | ||
|
|
081ae5a903 | ||
|
|
1291fd1381 |
No files matched your search
@@ -1,57 +0,0 @@
|
||||
name: Build and Push Docker Image
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
- main
|
||||
tags:
|
||||
- 'v*'
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: read
|
||||
packages: write
|
||||
steps:
|
||||
- name: Checkout code
|
||||
run: |
|
||||
git clone --depth=1 "https://${{ gitea.actor }}:${{ secrets.GITHUB_TOKEN }}@git.openlocalpdf.com/${{ gitea.repository }}.git" .
|
||||
git checkout "${{ github.sha }}" || true
|
||||
|
||||
- name: Check Runner Environment
|
||||
run: |
|
||||
echo "=== System Info ==="
|
||||
uname -a || true
|
||||
which docker || echo "docker CLI not found!"
|
||||
docker version || echo "docker daemon not accessible!"
|
||||
|
||||
- name: Set up QEMU
|
||||
uses: docker/setup-qemu-action@v3
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v3
|
||||
|
||||
- name: Log in to Gitea Container Registry
|
||||
run: |
|
||||
echo "${{ secrets.REGISTRY_TOKEN }}" | docker login git.openlocalpdf.com -u "${{ gitea.actor }}" --password-stdin
|
||||
|
||||
- name: Build and Push Docker image (Multi-Arch)
|
||||
run: |
|
||||
IMAGE_NAME="git.openlocalpdf.com/${{ gitea.repository }}"
|
||||
TAGS="-t ${IMAGE_NAME}:latest"
|
||||
|
||||
# 如果是 tag 触发,则同时打上具体版本 tag
|
||||
if [ "${{ github.ref_type }}" = "tag" ]; then
|
||||
TAG_NAME="${{ github.ref_name }}"
|
||||
echo "Tag detected: ${TAG_NAME}"
|
||||
TAGS="${TAGS} -t ${IMAGE_NAME}:${TAG_NAME}"
|
||||
fi
|
||||
|
||||
echo "Building and pushing multi-arch image: ${TAGS}"
|
||||
docker buildx build \
|
||||
--platform linux/amd64,linux/arm64 \
|
||||
${TAGS} \
|
||||
--push \
|
||||
-f Dockerfile .
|
||||
@@ -0,0 +1,99 @@
|
||||
name: Build and Push Multi-Arch Docker Image
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
- main
|
||||
tags:
|
||||
- 'v*'
|
||||
workflow_dispatch:
|
||||
|
||||
env:
|
||||
REGISTRY: git.openlocalpdf.com
|
||||
IMAGE_NAME: ${{ gitea.repository }}
|
||||
|
||||
jobs:
|
||||
build-arch:
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- platform: linux/amd64
|
||||
runner: amd64 # 香港 runner,原生编译
|
||||
arch: amd64
|
||||
- platform: linux/arm64
|
||||
runner: arm64 # 本机 runner,原生编译
|
||||
arch: arm64
|
||||
|
||||
runs-on: ${{ matrix.runner }}
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v3
|
||||
|
||||
- name: Log in to Gitea Container Registry
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
registry: ${{ env.REGISTRY }}
|
||||
username: ${{ gitea.actor }}
|
||||
password: ${{ secrets.REGISTRY_TOKEN }}
|
||||
|
||||
- name: Extract Docker metadata for platform
|
||||
id: meta
|
||||
uses: docker/metadata-action@v5
|
||||
with:
|
||||
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
|
||||
flavor: |
|
||||
suffix=-${{ matrix.arch }},onlatest=true
|
||||
tags: |
|
||||
type=ref,event=branch
|
||||
type=semver,pattern={{version}}
|
||||
type=semver,pattern={{major}}.{{minor}}
|
||||
type=raw,value=latest,enable=${{ gitea.ref == 'refs/heads/master' || gitea.ref == 'refs/heads/main' || startsWith(gitea.ref, 'refs/tags/v') }}
|
||||
|
||||
- name: Build and push by architecture
|
||||
uses: docker/build-push-action@v5
|
||||
with:
|
||||
context: .
|
||||
file: ./Dockerfile
|
||||
platforms: ${{ matrix.platform }}
|
||||
push: true
|
||||
tags: ${{ steps.meta.outputs.tags }}
|
||||
labels: ${{ steps.meta.outputs.labels }}
|
||||
|
||||
merge-manifests:
|
||||
needs: build-arch
|
||||
runs-on: amd64
|
||||
steps:
|
||||
- name: Log in to Gitea Container Registry
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
registry: ${{ env.REGISTRY }}
|
||||
username: ${{ gitea.actor }}
|
||||
password: ${{ secrets.REGISTRY_TOKEN }}
|
||||
|
||||
- name: Extract Docker metadata for manifest list
|
||||
id: meta
|
||||
uses: docker/metadata-action@v5
|
||||
with:
|
||||
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
|
||||
tags: |
|
||||
type=ref,event=branch
|
||||
type=semver,pattern={{version}}
|
||||
type=semver,pattern={{major}}.{{minor}}
|
||||
type=raw,value=latest,enable=${{ gitea.ref == 'refs/heads/master' || gitea.ref == 'refs/heads/main' || startsWith(gitea.ref, 'refs/tags/v') }}
|
||||
|
||||
- name: Create and push multi-arch manifest
|
||||
env:
|
||||
TAGS: ${{ steps.meta.outputs.tags }}
|
||||
run: |
|
||||
for tag in ${TAGS}; do
|
||||
echo "Creating manifest for $tag..."
|
||||
docker buildx imagetools create -t "$tag" \
|
||||
"${tag}-amd64" \
|
||||
"${tag}-arm64"
|
||||
docker buildx imagetools inspect "$tag"
|
||||
done
|
||||
@@ -3,3 +3,4 @@ Thumbs.db
|
||||
*.log
|
||||
.codegraph/
|
||||
.omo/
|
||||
.idea/
|
||||
@@ -27,6 +27,7 @@ RUN install-php-extensions \
|
||||
pdo_mysql \
|
||||
redis \
|
||||
gd \
|
||||
imagick \
|
||||
zip \
|
||||
bcmath \
|
||||
opcache \
|
||||
|
||||
@@ -17,9 +17,15 @@
|
||||
docker build -t webman:8.2 .
|
||||
```
|
||||
|
||||
### Gitea CI/CD 自动构建
|
||||
### Gitea Actions 自动构建与发布
|
||||
|
||||
已配置 `.gitea/workflows/build.yaml`。每次推送到 `master` / `main` 或推送 tag(如 `v1.0.0`)时,Gitea Actions 会自动构建并推送到 Gitea 镜像仓库:
|
||||
已配置 `.gitea/workflows/build.yml`。采用**混合原生双架构矩阵构建**:
|
||||
- **`linux/amd64`**:由 Gitea Actions 的 `ubuntu-latest` Runner 原生构建
|
||||
- **`linux/arm64`**:由组织 Self-Hosted ARM Runner 原生硬件全速构建
|
||||
- 自动合并生成多架构 Manifest 并发布到 Gitea Container Registry:
|
||||
|
||||
- **Registry**: `git.openlocalpdf.com:222/gitea/webman-docker:latest`
|
||||
- 确保 Gitea 仓库已启用 Actions 且部署有对应 Runner(如 act_runner)。
|
||||
- **Registry**: `git.openlocalpdf.com/gitea/webman-docker:latest`
|
||||
(或对应 tag 如 `:v1.0.0`)
|
||||
- 请在 Gitea 仓库的 Actions Secrets 中配置 `REGISTRY_TOKEN`,其需要具备
|
||||
写入包(Package)的权限。
|
||||
- 无论是在 x86_64 服务器、云主机还是本地 Apple Silicon / ARM 设备上,Docker 都会自动拉取匹配本机架构的镜像运行。
|
||||
Reference in new issue
Block a user