docker: build dep images

This commit is contained in:
boypt
2026-07-07 15:12:44 +08:00
parent 71d9a204b7
commit a8f7831f67
3 changed files with 99 additions and 1 deletions

62
.github/workflows/build-deps-images.yml vendored Executable file
View File

@@ -0,0 +1,62 @@
name: Build and Push Dependency Images
on:
workflow_dispatch:
push:
branches: [ main ]
paths:
- 'install_deps.sh'
- 'docker/Dockerfile.deps'
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
jobs:
# amd64 和 arm64 都用各自架构的原生 runner 构建(和 create-release.yml 的策略保持一致),
# 不使用 QEMU 模拟,避免影响构建速度。
build:
runs-on: ${{ matrix.os }}
permissions:
contents: read
packages: write
strategy:
matrix:
os: [ubuntu-latest, ubuntu-24.04-arm]
version: ["ubuntu:noble", "ubuntu:jammy", "ubuntu:focal", "debian:trixie", "debian:bookworm", "debian:bullseye"]
fail-fast: false
steps:
- name: Checkout repository
uses: actions/checkout@v5
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to Container Registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Compute image tag
id: vars
run: |
CODENAME=$(echo "${{ matrix.version }}" | cut -d':' -f2)
ARCH="amd64"
[[ "${{ matrix.os }}" == *arm* ]] && ARCH="arm64"
echo "codename=${CODENAME}" >> $GITHUB_OUTPUT
echo "arch=${ARCH}" >> $GITHUB_OUTPUT
- name: Build and push
uses: docker/build-push-action@v5
with:
context: .
file: ./docker/Dockerfile.deps
build-args: |
BASE_IMAGE=${{ matrix.version }}
push: true
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:deps-${{ steps.vars.outputs.codename }}-${{ steps.vars.outputs.arch }}
cache-from: type=gha,scope=deps-${{ steps.vars.outputs.codename }}-${{ steps.vars.outputs.arch }}
cache-to: type=gha,mode=max,scope=deps-${{ steps.vars.outputs.codename }}-${{ steps.vars.outputs.arch }}

27
.github/workflows/create-release.yml vendored Normal file → Executable file
View File

@@ -7,6 +7,11 @@ on:
permissions:
contents: write
packages: read
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
jobs:
build:
@@ -24,10 +29,30 @@ jobs:
fetch-depth: 0
persist-credentials: false
- name: Set image tag
id: vars
run: |
CODENAME=$(echo "${{ matrix.version }}" | cut -d':' -f2)
ARCH="amd64"
[[ "${{ matrix.os }}" == *arm* ]] && ARCH="arm64"
echo "arch=${ARCH}" >> $GITHUB_OUTPUT
echo "codename=${CODENAME}" >> $GITHUB_OUTPUT
echo "image=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:deps-${CODENAME}-${ARCH}" >> $GITHUB_OUTPUT
- name: Log in to Container Registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Pull prebuilt dependency image
run: docker pull ${{ steps.vars.outputs.image }}
- name: Compile ${{ matrix.version }} on ${{ matrix.os }}
run: |
./pullsrc.sh
docker run --rm -v ${{ github.workspace }}:/work -w /work library/${{ matrix.version }} bash -c "./install_deps.sh && ./compile.sh"
docker run --rm -v ${{ github.workspace }}:/work -w /work ${{ steps.vars.outputs.image }} bash -c "./compile.sh"
- name: Install test with ${{ matrix.version }}
run: |