From 89ed57007f4c9f2b7ca77fca9f51678eeace1a00 Mon Sep 17 00:00:00 2001 From: yleaf <11785335+leavesster@users.noreply.github.com> Date: Tue, 22 Oct 2024 11:31:14 +0800 Subject: [PATCH] chore: add base rootfs to release --- .github/workflows/base.yaml | 62 ++++++++++++++++++++++++++++++++++++ .github/workflows/build.yaml | 2 +- base.dockerfile | 7 ++++ 3 files changed, 70 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/base.yaml create mode 100644 base.dockerfile diff --git a/.github/workflows/base.yaml b/.github/workflows/base.yaml new file mode 100644 index 0000000..f78a29d --- /dev/null +++ b/.github/workflows/base.yaml @@ -0,0 +1,62 @@ +name: build image +on: + pull_request: + paths: + - "base.dockerfile" + - ".github/workflows/base.yaml" + push: + paths: + - "base.dockerfile" + - ".github/workflows/base.yaml" + workflow_dispatch: + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Login to GitHub Container Registry + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + - uses: docker/setup-qemu-action@v3 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + - name: Docker meta + id: meta + uses: docker/metadata-action@v5 + with: + images: ghcr.io/oomol/base-rootfs + tags: | + type=sha + type=raw,value=latest,enable={{is_default_branch}} + type=semver,pattern={{version}} + flavor: | + latest=auto + - name: Build and push + uses: docker/build-push-action@v6 + with: + context: . + push: ${{ (github.event_name == 'push' && github.ref == 'refs/heads/main') || github.ref_type == 'tag' }} + platforms: linux/amd64,linux/arm64 + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + file: base.dockerfile + cache-from: type=gha + cache-to: type=gha,mode=max + - name: export rootfs + run: | + docker run -d --name rootfs-export ${{ steps.meta.outputs.images }} + docker export rootfs-export > base-rootfs-amd64.tar + - name: Release + uses: softprops/action-gh-release@v2 + with: + files: base-rootfs-amd64.tar + token: ${{ secrets.GITHUB_TOKEN }} + tag_name: ${{ github.sha }} + body: ${{ github.sha }} + draft: false + prerelease: false + make_latest: true \ No newline at end of file diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index a10296c..1dedc02 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -52,4 +52,4 @@ jobs: npmrc=.npmrc file: .Dockerfile cache-from: type=gha - cache-to: type=gha,mode=max + cache-to: type=gha,mode=max \ No newline at end of file diff --git a/base.dockerfile b/base.dockerfile new file mode 100644 index 0000000..f204d3f --- /dev/null +++ b/base.dockerfile @@ -0,0 +1,7 @@ +FROM ubuntu:latest + +RUN --mount=target=/var/lib/apt/lists,type=cache,sharing=locked \ + --mount=target=/var/cache/apt,type=cache,sharing=locked \ + rm -f /etc/apt/apt.conf.d/docker-clean \ + && apt update \ + && apt install -y --no-install-recommends locales-all tar xz-utils uuid-runtime \ No newline at end of file