--- name: 'build container images (reusable)' on: workflow_call: inputs: base-image: description: 'Base image' required: true type: string build-type: description: 'Build type' default: '' type: string cuda-major-version: description: 'CUDA major version' default: "12" type: string cuda-minor-version: description: 'CUDA minor version' default: "9" type: string platforms: description: 'Platforms' default: '' type: string tag-latest: description: 'Tag latest' default: '' type: string tag-suffix: description: 'Tag suffix' default: '' type: string skip-drivers: description: 'Skip drivers by default' default: 'false' type: string runs-on: description: 'Runs on' required: true default: '' type: string makeflags: description: 'Make Flags' required: false default: '--jobs=4 --output-sync=target' type: string ubuntu-version: description: 'Ubuntu version' required: false default: '2204' type: string ubuntu-codename: description: 'Ubuntu codename' required: false default: 'noble' type: string secrets: dockerUsername: required: true dockerPassword: required: true quayUsername: required: true quayPassword: required: true jobs: reusable_image-build: runs-on: ${{ inputs.runs-on }} steps: - name: Checkout uses: actions/checkout@v6 - name: Configure apt mirror on runner id: apt_mirror uses: ./.github/actions/configure-apt-mirror - name: Free disk space uses: ./.github/actions/free-disk-space with: mode: ${{ inputs.runs-on == 'ubuntu-latest' && 'hosted' || 'skip' }} - name: Set up build disk uses: ./.github/actions/setup-build-disk - name: Docker meta id: meta if: github.event_name != 'pull_request' uses: docker/metadata-action@v6 with: images: | quay.io/go-skynet/local-ai localai/localai tags: | type=ref,event=branch type=semver,pattern={{raw}} type=sha flavor: | latest=${{ inputs.tag-latest }} suffix=${{ inputs.tag-suffix }},onlatest=true - name: Docker meta for PR id: meta_pull_request if: github.event_name == 'pull_request' uses: docker/metadata-action@v6 with: images: | quay.io/go-skynet/ci-tests tags: | type=ref,event=branch,suffix=localai${{ github.event.number }}-${{ inputs.build-type }}-${{ inputs.cuda-major-version }}-${{ inputs.cuda-minor-version }} type=semver,pattern={{raw}},suffix=localai${{ github.event.number }}-${{ inputs.build-type }}-${{ inputs.cuda-major-version }}-${{ inputs.cuda-minor-version }} type=sha,suffix=localai${{ github.event.number }}-${{ inputs.build-type }}-${{ inputs.cuda-major-version }}-${{ inputs.cuda-minor-version }} flavor: | latest=${{ inputs.tag-latest }} suffix=${{ inputs.tag-suffix }} - name: Set up QEMU uses: docker/setup-qemu-action@master with: platforms: all - name: Set up Docker Buildx id: buildx uses: docker/setup-buildx-action@master - name: Login to DockerHub if: github.event_name != 'pull_request' uses: docker/login-action@v4 with: username: ${{ secrets.dockerUsername }} password: ${{ secrets.dockerPassword }} - name: Login to DockerHub if: github.event_name != 'pull_request' uses: docker/login-action@v4 with: registry: quay.io username: ${{ secrets.quayUsername }} password: ${{ secrets.quayPassword }} - name: Build and push uses: docker/build-push-action@v7 if: github.event_name != 'pull_request' with: builder: ${{ steps.buildx.outputs.name }} build-args: | BUILD_TYPE=${{ inputs.build-type }} CUDA_MAJOR_VERSION=${{ inputs.cuda-major-version }} CUDA_MINOR_VERSION=${{ inputs.cuda-minor-version }} BASE_IMAGE=${{ inputs.base-image }} MAKEFLAGS=${{ inputs.makeflags }} SKIP_DRIVERS=${{ inputs.skip-drivers }} UBUNTU_VERSION=${{ inputs.ubuntu-version }} UBUNTU_CODENAME=${{ inputs.ubuntu-codename }} APT_MIRROR=${{ steps.apt_mirror.outputs.effective-mirror }} APT_PORTS_MIRROR=${{ steps.apt_mirror.outputs.effective-ports-mirror }} context: . file: ./Dockerfile cache-from: type=registry,ref=quay.io/go-skynet/ci-cache:cache-localai${{ inputs.tag-suffix }} cache-to: type=registry,ref=quay.io/go-skynet/ci-cache:cache-localai${{ inputs.tag-suffix }},mode=max,ignore-error=true platforms: ${{ inputs.platforms }} push: ${{ github.event_name != 'pull_request' }} tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} ### Start testing image - name: Build and push uses: docker/build-push-action@v7 if: github.event_name == 'pull_request' with: builder: ${{ steps.buildx.outputs.name }} build-args: | BUILD_TYPE=${{ inputs.build-type }} CUDA_MAJOR_VERSION=${{ inputs.cuda-major-version }} CUDA_MINOR_VERSION=${{ inputs.cuda-minor-version }} BASE_IMAGE=${{ inputs.base-image }} MAKEFLAGS=${{ inputs.makeflags }} SKIP_DRIVERS=${{ inputs.skip-drivers }} UBUNTU_VERSION=${{ inputs.ubuntu-version }} UBUNTU_CODENAME=${{ inputs.ubuntu-codename }} APT_MIRROR=${{ steps.apt_mirror.outputs.effective-mirror }} APT_PORTS_MIRROR=${{ steps.apt_mirror.outputs.effective-ports-mirror }} context: . file: ./Dockerfile cache-from: type=registry,ref=quay.io/go-skynet/ci-cache:cache-localai${{ inputs.tag-suffix }} platforms: ${{ inputs.platforms }} #push: true tags: ${{ steps.meta_pull_request.outputs.tags }} labels: ${{ steps.meta_pull_request.outputs.labels }} ## End testing image - name: job summary run: | echo "Built image: ${{ steps.meta.outputs.labels }}" >> $GITHUB_STEP_SUMMARY