Skip to content

build_rust_mos_docker_image #31

build_rust_mos_docker_image

build_rust_mos_docker_image #31

name: build_rust_mos_docker_image
on:
workflow_dispatch:
inputs:
llvm_mos_repo:
description: 'llvm-mos repo'
default: 'llvm-mos/llvm-mos'
type: string
llvm_mos_sdk_repo:
description: 'llvm-mos-sdk repo'
default: 'llvm-mos/llvm-mos-sdk'
type: string
llvm_mos_ref:
description: 'llvm-mos ref'
default: '7c0751c5b1e2fd62e1e0e358e9e853903f876920'
type: string
llvm_mos_sdk_ref:
description: 'llvm-mos-sdk ref'
default: '334fc9823745284938bfba543112f95bfb489b50'
type: string
rust_mos_sha:
description: 'rust_mos_sha (last part of image name)'
# default: '21ee0734'
type: string
jobs:
amd64_image:
if: ${{ true }}
uses: ./.github/workflows/cross-build-llvm-mos.yml
with:
arch: amd64
llvm_mos_repo: ${{ inputs.llvm_mos_repo }}
llvm_mos_sdk_repo: ${{ inputs.llvm_mos_sdk_repo }}
llvm_mos_ref: ${{ inputs.llvm_mos_ref }}
llvm_mos_sdk_ref: ${{ inputs.llvm_mos_sdk_ref }}
secrets: inherit
arm64_image_tmp:
if: ${{ true }}
uses: ./.github/workflows/cross-build-llvm-mos.yml
with:
arch: arm64
arch_suffix: -tmp
llvm_mos_repo: ${{ inputs.llvm_mos_repo }}
llvm_mos_sdk_repo: ${{ inputs.llvm_mos_sdk_repo }}
llvm_mos_ref: ${{ inputs.llvm_mos_ref }}
llvm_mos_sdk_ref: ${{ inputs.llvm_mos_sdk_ref }}
secrets: inherit
arm64_image:
if: ${{ true }}
runs-on: ubuntu-latest
needs:
- amd64_image
- arm64_image_tmp
steps:
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Checkout
uses: actions/checkout@v4
- name: Set short sha
id: short_sha
run: |
echo "llvm_mos=$(echo ${{ inputs.llvm_mos_ref }} | cut -b 1-9)" >> $GITHUB_OUTPUT
echo "llvm_mos_sdk=$(echo ${{ inputs.llvm_mos_sdk_ref }} | cut -b 1-7)" >> $GITHUB_OUTPUT
- name: Build and push fixed arm image
id: build_fixed_arm_image
uses: docker/build-push-action@v2
with:
push: true
tags: mrkits/llvm-mos:${{ steps.short_sha.outputs.llvm_mos }}-${{ steps.short_sha.outputs.llvm_mos_sdk }}-arm64
file: docker/llvm-mos/Dockerfile.fix.arm64
context: .
platforms: arm64
build-args: |
LLVM_MOS_IMAGE=mrkits/llvm-mos:${{ steps.short_sha.outputs.llvm_mos }}-${{ steps.short_sha.outputs.llvm_mos_sdk }}
TARGETARCH=arm64
build_image:
if: ${{ true }}
runs-on: ubuntu-latest
needs:
- amd64_image
- arm64_image
steps:
- name: Set short sha
id: short_sha
run: |
echo "rust_mos=$(echo ${{ inputs.rust_mos_sha || github.sha }} | cut -b 1-8)" >> $GITHUB_OUTPUT
echo "llvm_mos=$(echo ${{ inputs.llvm_mos_ref }} | cut -b 1-9)" >> $GITHUB_OUTPUT
echo "llvm_mos_sdk=$(echo ${{ inputs.llvm_mos_sdk_ref }} | cut -b 1-7)" >> $GITHUB_OUTPUT
- name: show revisions
run: "echo llvm-mos: ${{ steps.short_sha.outputs.llvm_mos}} llvm-mos-sdk: ${{ steps.short_sha.outputs.llvm_mos_sdk}} rust_mos: ${{ steps.short_sha.outputs.rust_mos}}"
- name: cleanup
run: |
echo "=============================================================================="
echo "Freeing up disk space on CI system"
echo "=============================================================================="
echo "Listing 100 largest packages"
dpkg-query -Wf '${Installed-Size}\t${Package}\n' | sort -n | tail -n 100
df -h
echo "Removing large packages"
echo sudo apt-get update
echo sudo apt-get remove -y '^dotnet-.*' '^llvm-.*' 'aspnetcore.*' 'temurin.*' azure-cli google-cloud-cli \
microsoft-edge-stable google-chrome-stable firefox powershell mono-devel \
'^gfortran.*' 'mono-devel' 'libllvm.*' 'mysql-server-core-.*' 'libclang-common.*' \
'^gcc-10.*' '^gcc-11.*' '^gcc-12.*' '^postgresql.*' 'libclang-cpp.*' '^.*-dev$'
echo sudo apt-get autoremove -y
echo sudo apt-get clean
df -h
echo "Removing large directories"
sudo rm -rf /usr/share/dotnet/ /usr/share/swift /usr/share/miniconda /usr/local/lib/android
df -h
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Checkout
uses: actions/checkout@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push rust-mos
id: build_rust_dist_image
uses: docker/build-push-action@v2
with:
push: true
tags: mrkits/rust-mos:${{ steps.short_sha.outputs.llvm_mos }}-${{ steps.short_sha.outputs.llvm_mos_sdk }}-${{ steps.short_sha.outputs.rust_mos}}-dist
file: docker/rust-mos/Dockerfile
context: .
build-args: |
LLVM_MOS_IMAGE=mrkits/llvm-mos:${{ steps.short_sha.outputs.llvm_mos }}-${{ steps.short_sha.outputs.llvm_mos_sdk }}
- name: Build and push multi-platform rust-mos image
id: build_rust_multiarch_image
uses: docker/build-push-action@v2
with:
push: true
tags: mrkits/rust-mos:${{ steps.short_sha.outputs.llvm_mos }}-${{ steps.short_sha.outputs.llvm_mos_sdk }}-${{ steps.short_sha.outputs.rust_mos }}
file: docker/rust-mos/Dockerfile.multiarch
platforms: linux/amd64,linux/arm64
context: docker/rust-mos/
build-args: |
LLVM_MOS_IMAGE=mrkits/llvm-mos:${{ steps.short_sha.outputs.llvm_mos }}-${{ steps.short_sha.outputs.llvm_mos_sdk }}
RUST_MOS_DIST_IMAGE=mrkits/rust-mos:${{ steps.short_sha.outputs.llvm_mos }}-${{ steps.short_sha.outputs.llvm_mos_sdk }}-${{ steps.short_sha.outputs.rust_mos }}-dist
test_image:
needs:
- build_image
uses: ./.github/workflows/aoc_tests.yml
with:
llvm_mos_ref: ${{inputs.llvm_mos_ref}}
llvm_mos_sdk_ref: ${{inputs.llvm_mos_sdk_ref}}
rust_mos_sha: ${{inputs.rust_mos_sha}}
secrets: inherit