Add binaries for our Rust demos in a Torizon container

This commit is contained in:
Simon Hausmann 2023-01-04 16:59:30 +01:00
parent 830c5eb1fd
commit d13712c121
3 changed files with 102 additions and 0 deletions

2
.dockerignore Normal file
View file

@ -0,0 +1,2 @@
target
.git

51
.github/workflows/torizon_demos.yaml vendored Normal file
View file

@ -0,0 +1,51 @@
# Copyright © SixtyFPS GmbH <info@slint-ui.com>
# SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-commercial
name: Rust Demos built for Torizon
on:
workflow_dispatch:
inputs:
push:
type: boolean
description: "Push the built images"
workflow_call:
inputs:
push:
type: boolean
description: "Push the built images"
jobs:
build_containers:
runs-on: ubuntu-20.04
strategy:
matrix:
include:
- target: armhf
image_arch: linux/arm/v7
rust_toolchain_arch: armv7-unknown-linux-gnueabihf
- target: arm64
image_arch: linux/arm64
rust_toolchain_arch: aarch64-unknown-linux-gnu
steps:
- uses: actions/checkout@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Login to GitHub Container Registry
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.CR_PAT }}
- name: Build and push
uses: docker/build-push-action@v3
with:
context: .
file: ./docker/Dockerfile.torizon-demos
push: ${{ github.event.inputs.push || inputs.push }}
tags: ghcr.io/slint-ui/slint/slint-torizon-demos-${{matrix.target}}:latest
build-args: |
TOOLCHAIN_ARCH=${{matrix.target}}
IMAGE_ARCH=${{matrix.image_arch}}
RUST_TOOLCHAIN_ARCH=${{matrix.rust_toolchain_arch}}

View file

@ -0,0 +1,49 @@
# This docker file builds the Rust binaries of our demos and packages them into a Torizon container
ARG TOOLCHAIN_ARCH=arm64
ARG IMAGE_ARCH=linux/arm64
ARG BASE_NAME=wayland-base
FROM torizon/debian-cross-toolchain-$TOOLCHAIN_ARCH:2-bullseye AS build
ARG TOOLCHAIN_ARCH
ARG RUST_TOOLCHAIN_ARCH=aarch64-unknown-linux-gnu
# Install Rust
ENV RUSTUP_HOME=/rust
ENV CARGO_HOME=/cargo
ENV PATH=/cargo/bin:/rust/bin:$PATH
RUN curl https://sh.rustup.rs -sSf | sh -s -- -y
RUN rustup target add $RUST_TOOLCHAIN_ARCH
ENV CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=aarch64-linux-gnu-gcc
ENV CARGO_TARGET_ARMV7_UNKNOWN_LINUX_GNUEABIHF_LINKER=arm-linux-gnueabihf-gcc
# Install Slint build dependencies (libxcb, etc.)
RUN apt-get update && \
apt-get install --assume-yes libfontconfig1-dev:$TOOLCHAIN_ARCH libxcb1-dev:$TOOLCHAIN_ARCH libxcb-render0-dev:$TOOLCHAIN_ARCH libxcb-shape0-dev:$TOOLCHAIN_ARCH libxcb-xfixes0-dev:$TOOLCHAIN_ARCH libxkbcommon-dev:$TOOLCHAIN_ARCH python3 clang libstdc++-10-dev:$TOOLCHAIN_ARCH && \
rm -rf /var/lib/apt/lists/*
# Don't require font-config when the compiler runs
ENV RUST_FONTCONFIG_DLOPEN=on
# Build Demos
COPY . /slint
WORKDIR /slint
RUN mkdir demos \
&& for demo in printerdemo slide_puzzle gallery opengl_underlay carousel todo; do \
cargo build --release --target $RUST_TOOLCHAIN_ARCH --features slint/renderer-winit-skia -p $demo; \
cp target/$RUST_TOOLCHAIN_ARCH/release/$demo ./demos/; \
done
# Create container for target
FROM --platform=$IMAGE_ARCH torizon/$BASE_NAME:2
RUN apt-get update \
&& apt-get install libfontconfig1 \
&& rm -rf /var/lib/apt/lists/*
COPY --from=build /slint/demos/* /usr/bin/
ENV SLINT_FULLSCREEN=1
ENV SLINT_BACKEND=winit-skia
CMD /usr/bin/printerdemo