Privacy-first password manager with built-in email aliasing. Fully encrypted and self-hostable.
Update release Docker build efficiency
Leendert de Borstcb04b897d46c
diff --git a/.github/actions/build-docker-image/action.yml b/.github/actions/build-docker-image/action.ymlnew file mode 100644index 000000000..279dc8c19--- /dev/null+++ b/.github/actions/build-docker-image/action.yml@@ -0,0 +1,94 @@+name: "Build and Push Docker Image"+description: "Builds a multi-arch AliasVault image and pushes it to GHCR, reusing the persistent buildx builder on self-hosted runners"+inputs:+ image:+ description: "Image name under ghcr.io/aliasvault/ (e.g. client)"+ required: true+ dockerfile:+ description: "Path to the Dockerfile, relative to the repository root"+ required: true+ title:+ description: "Value for the org.opencontainers.image.title label"+ required: true+ description:+ description: "Value for the org.opencontainers.image.description label and annotation"+ required: true+ version:+ description: "Version tag to publish. Empty falls back to branch-based tags."+ required: false+ default: ""+ tag_latest:+ description: "Whether to also tag the image as :latest"+ required: false+ default: "false"+ github_token:+ description: "Token used to log in to the GitHub Container Registry"+ required: true+ runner_environment:+ description: "Pass runner.environment from the calling job. Anything other than 'self-hosted' uses the GitHub-hosted (throwaway builder) path."+ required: true++runs:+ using: "composite"+ steps:+ - name: Set up QEMU+ uses: docker/setup-qemu-action@v4++ # Deliberately the fallback branch: a multi-platform build needs a docker-container builder, so an+ # unexpected runner_environment must still end up with a working one rather than no builder at all.+ - name: Set up Docker Buildx (GitHub-hosted)+ if: inputs.runner_environment != 'self-hosted'+ uses: docker/setup-buildx-action@v4++ # On self-hosted we reuse a named builder across runs so its build cache survives, which is+ # what makes building the images back-to-back on a single machine fast. setup-buildx-action+ # deletes its builder in a post-step, throwing away exactly that cache.+ - name: Set up Docker Buildx (self-hosted)+ if: inputs.runner_environment == 'self-hosted'+ shell: bash+ run: |+ docker buildx inspect aliasvault >/dev/null 2>&1 \+ || docker buildx create --name aliasvault --driver docker-container --bootstrap+ docker buildx use aliasvault++ - name: Log in to GitHub Container Registry+ uses: docker/login-action@v4+ with:+ registry: ghcr.io+ username: ${{ github.actor }}+ password: ${{ inputs.github_token }}++ - name: Extract metadata+ id: meta+ uses: docker/metadata-action@v6+ env:+ DOCKER_METADATA_ANNOTATIONS_LEVELS: manifest,index+ with:+ images: ghcr.io/aliasvault/${{ inputs.image }}+ tags: |+ type=raw,value=${{ inputs.version }},enable=${{ inputs.version != '' }}+ type=raw,value=latest,enable=${{ inputs.tag_latest == 'true' }}+ type=ref,event=branch,enable=${{ inputs.version == '' }}+ type=raw,value={{branch}}-{{sha}},enable=${{ inputs.version == '' }}+ labels: |+ org.opencontainers.image.title=${{ inputs.title }}+ org.opencontainers.image.description=${{ inputs.description }}+ annotations: |+ org.opencontainers.image.description=${{ inputs.description }}++ - name: Build and push image+ uses: docker/build-push-action@v7+ with:+ context: .+ file: ${{ inputs.dockerfile }}+ platforms: linux/amd64,linux/arm64/v8+ push: true+ tags: ${{ steps.meta.outputs.tags }}+ labels: ${{ steps.meta.outputs.labels }}+ annotations: ${{ steps.meta.outputs.annotations }}++ # Keep the persistent builder cache from growing without bound on our own hardware.+ - name: Prune stale build cache+ if: always() && inputs.runner_environment == 'self-hosted'+ shell: bash+ run: docker buildx prune --force --keep-storage=50GBdiff --git a/.github/workflows/release-docker.yml b/.github/workflows/release-docker.ymlindex 0dfdf7442..373eb454f 100644--- a/.github/workflows/release-docker.yml+++ b/.github/workflows/release-docker.yml@@ -127,8 +127,50 @@ jobs:doneecho "multi_container_exists=${MULTI_EXISTS}" >> $GITHUB_OUTPUT- build-and-push-docker-multi-container:+ # The Client image takes the longest time to build, so we build it in its own job instead of a matrix slot,+ # as jobs in a matrix are queued at once and picked up in an order we don't control, making the full build run+ # longer than it needs to be.+ build-and-push-docker-client:+ needs: [valid-release, detect-version]+ # Skip if images already exist during release (just tag them as latest instead), but allow manual rebuild via workflow_dispatch+ if: always() && (github.event_name != 'release' || needs.valid-release.result == 'success') && (github.event_name == 'release' || inputs.build_multi_container) && (github.event_name != 'release' || needs.detect-version.outputs.multi_container_exists != 'true')+ runs-on: ${{ inputs.runner == 'self-hosted' && 'docker-build' || 'ubuntu-latest' }}+ permissions:+ contents: read+ packages: write++ steps:+ - name: Checkout repository+ uses: actions/checkout@v6++ - name: Build and push Client image+ uses: ./.github/actions/build-docker-image+ with:+ image: client+ dockerfile: apps/server/AliasVault.Client/Dockerfile+ title: AliasVault Client+ description: Blazor WebAssembly client UI for AliasVault. Part of multi-container setup and can be deployed via install.sh (see docs.aliasvault.com)+ version: ${{ needs.detect-version.outputs.version }}+ tag_latest: ${{ needs.detect-version.outputs.tag_latest }}+ github_token: ${{ secrets.GITHUB_TOKEN }}+ runner_environment: ${{ runner.environment }}++ # Head start for the two heavy builds (Client and all-in-one) so they, and not the cheap images,+ # claim the runners first.+ stagger-light-images:needs: [valid-release, detect-version]+ if: always() && inputs.runner == 'self-hosted' && (github.event_name != 'release' || needs.valid-release.result == 'success') && (github.event_name == 'release' || inputs.build_multi_container) && (github.event_name != 'release' || needs.detect-version.outputs.multi_container_exists != 'true')+ runs-on: ubuntu-latest+ timeout-minutes: 5+ steps:+ - name: Let the heavy builds claim a runner first+ run: sleep 60++ build-and-push-docker-multi-container:+ # stagger-light-images is only in "needs" for its ordering effect: this job waits for it to finish+ # regardless of its outcome (the "always()" below), it does not gate whether these images build.+ # It is skipped entirely on GitHub-hosted runs, which is also fine -- always() ignores that too.+ needs: [valid-release, detect-version, stagger-light-images]# Skip if images already exist during release (just tag them as latest instead), but allow manual rebuild via workflow_dispatchif: always() && (github.event_name != 'release' || needs.valid-release.result == 'success') && (github.event_name == 'release' || inputs.build_multi_container) && (github.event_name != 'release' || needs.detect-version.outputs.multi_container_exists != 'true')runs-on: ${{ inputs.runner == 'self-hosted' && 'docker-build' || 'ubuntu-latest' }}@@ -138,23 +180,18 @@ jobs:strategy:# Don't cancel the other images if one fails.fail-fast: false- # On GitHub-hosted runners: cap at 2 concurrent runner slots. The heavy Client build- # (~55 min: Rust→WASM + wasm-tools + WASM publish) holds one slot while the remaining- # light images cycle through the second slot (~35-45 min total). This frees up the rest+ # On GitHub-hosted runners: cap at 1 concurrent runner slot, which together with the separate+ # Client and all-in-one jobs keeps this workflow to 3 concurrent runners. This frees up the rest# of the CI worker pool for other workflows.# On self-hosted: no meaningful cap, the size of our own "docker-build" runner pool is the# real limit, so let every image queue and fill whatever runners are free. This is what lets- # the pool pick these up the moment the all-in-one job finishes, instead of leaving a runner- # idle. Each runner keeps its own persistent buildx cache, which carries the shared .NET- # layers from one image to the next.- max-parallel: ${{ inputs.runner == 'self-hosted' && 8 || 2 }}+ # the pool pick these up the moment the Client or all-in-one job finishes, instead of leaving a+ # runner idle. Each runner keeps its own persistent buildx cache, which carries the shared .NET+ # layers from one image to the next. The value is deliberately well above the number of matrix+ # entries so that adding an image never silently turns this into a real cap.+ max-parallel: ${{ inputs.runner == 'self-hosted' && 32 || 1 }}matrix:- # Client is listed first so it claims a slot immediately and runs alongside the rest of the images.include:- - image: client- dockerfile: apps/server/AliasVault.Client/Dockerfile- title: AliasVault Client- description: Blazor WebAssembly client UI for AliasVault. Part of multi-container setup and can be deployed via install.sh (see docs.aliasvault.com)- image: postgresdockerfile: apps/server/Databases/AliasServerDb/Dockerfiletitle: AliasVault PostgreSQL@@ -188,63 +225,17 @@ jobs:- name: Checkout repositoryuses: actions/checkout@v6- - name: Set up QEMU- uses: docker/setup-qemu-action@v4-- - name: Set up Docker Buildx (GitHub-hosted)- if: runner.environment == 'github-hosted'- uses: docker/setup-buildx-action@v4-- # On self-hosted we reuse a named builder across runs so its build cache survives, which is- # what makes building the images back-to-back on a single machine fast. setup-buildx-action- # deletes its builder in a post-step, throwing away exactly that cache.- - name: Set up Docker Buildx (self-hosted)- if: runner.environment == 'self-hosted'- run: |- docker buildx inspect aliasvault >/dev/null 2>&1 \- || docker buildx create --name aliasvault --driver docker-container --bootstrap- docker buildx use aliasvault-- - name: Log in to GitHub Container Registry- uses: docker/login-action@v4- with:- registry: ghcr.io- username: ${{ github.actor }}- password: ${{ secrets.GITHUB_TOKEN }}-- - name: Extract metadata- id: meta- uses: docker/metadata-action@v6- env:- DOCKER_METADATA_ANNOTATIONS_LEVELS: manifest,index- with:- images: ghcr.io/aliasvault/${{ matrix.image }}- tags: |- type=raw,value=${{ needs.detect-version.outputs.version }},enable=${{ needs.detect-version.outputs.version != '' }}- type=raw,value=latest,enable=${{ needs.detect-version.outputs.tag_latest == 'true' }}- type=ref,event=branch,enable=${{ needs.detect-version.outputs.version == '' }}- type=raw,value={{branch}}-{{sha}},enable=${{ needs.detect-version.outputs.version == '' }}- labels: |- org.opencontainers.image.title=${{ matrix.title }}- org.opencontainers.image.description=${{ matrix.description }}- annotations: |- org.opencontainers.image.description=${{ matrix.description }}-- name: Build and push image- uses: docker/build-push-action@v7+ uses: ./.github/actions/build-docker-imagewith:- context: .- file: ${{ matrix.dockerfile }}- platforms: linux/amd64,linux/arm64/v8- push: true- tags: ${{ steps.meta.outputs.tags }}- labels: ${{ steps.meta.outputs.labels }}- annotations: ${{ steps.meta.outputs.annotations }}-- # Keep the persistent builder cache from growing without bound on our own hardware.- - name: Prune stale build cache- if: always() && runner.environment == 'self-hosted'- run: docker buildx prune --force --keep-storage=50GB+ image: ${{ matrix.image }}+ dockerfile: ${{ matrix.dockerfile }}+ title: ${{ matrix.title }}+ description: ${{ matrix.description }}+ version: ${{ needs.detect-version.outputs.version }}+ tag_latest: ${{ needs.detect-version.outputs.tag_latest }}+ github_token: ${{ secrets.GITHUB_TOKEN }}+ runner_environment: ${{ runner.environment }}build-and-push-docker-all-in-one:needs: [valid-release, detect-version]