Skip to content

Commit d13712c

Browse files
committedJan 4, 2023
Add binaries for our Rust demos in a Torizon container
1 parent 830c5eb commit d13712c

File tree

3 files changed

+102
-0
lines changed

3 files changed

+102
-0
lines changed
 

‎.dockerignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
target
2+
.git

‎.github/workflows/torizon_demos.yaml

+51
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# Copyright © SixtyFPS GmbH <info@slint-ui.com>
2+
# SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-commercial
3+
4+
name: Rust Demos built for Torizon
5+
6+
on:
7+
workflow_dispatch:
8+
inputs:
9+
push:
10+
type: boolean
11+
description: "Push the built images"
12+
workflow_call:
13+
inputs:
14+
push:
15+
type: boolean
16+
description: "Push the built images"
17+
18+
jobs:
19+
build_containers:
20+
runs-on: ubuntu-20.04
21+
strategy:
22+
matrix:
23+
include:
24+
- target: armhf
25+
image_arch: linux/arm/v7
26+
rust_toolchain_arch: armv7-unknown-linux-gnueabihf
27+
- target: arm64
28+
image_arch: linux/arm64
29+
rust_toolchain_arch: aarch64-unknown-linux-gnu
30+
31+
steps:
32+
- uses: actions/checkout@v3
33+
- name: Set up Docker Buildx
34+
uses: docker/setup-buildx-action@v1
35+
- name: Login to GitHub Container Registry
36+
uses: docker/login-action@v1
37+
with:
38+
registry: ghcr.io
39+
username: ${{ github.actor }}
40+
password: ${{ secrets.CR_PAT }}
41+
- name: Build and push
42+
uses: docker/build-push-action@v3
43+
with:
44+
context: .
45+
file: ./docker/Dockerfile.torizon-demos
46+
push: ${{ github.event.inputs.push || inputs.push }}
47+
tags: ghcr.io/slint-ui/slint/slint-torizon-demos-${{matrix.target}}:latest
48+
build-args: |
49+
TOOLCHAIN_ARCH=${{matrix.target}}
50+
IMAGE_ARCH=${{matrix.image_arch}}
51+
RUST_TOOLCHAIN_ARCH=${{matrix.rust_toolchain_arch}}

‎docker/Dockerfile.torizon-demos

+49
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# This docker file builds the Rust binaries of our demos and packages them into a Torizon container
2+
3+
ARG TOOLCHAIN_ARCH=arm64
4+
ARG IMAGE_ARCH=linux/arm64
5+
ARG BASE_NAME=wayland-base
6+
FROM torizon/debian-cross-toolchain-$TOOLCHAIN_ARCH:2-bullseye AS build
7+
ARG TOOLCHAIN_ARCH
8+
ARG RUST_TOOLCHAIN_ARCH=aarch64-unknown-linux-gnu
9+
10+
# Install Rust
11+
ENV RUSTUP_HOME=/rust
12+
ENV CARGO_HOME=/cargo
13+
ENV PATH=/cargo/bin:/rust/bin:$PATH
14+
15+
RUN curl https://sh.rustup.rs -sSf | sh -s -- -y
16+
RUN rustup target add $RUST_TOOLCHAIN_ARCH
17+
18+
ENV CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=aarch64-linux-gnu-gcc
19+
ENV CARGO_TARGET_ARMV7_UNKNOWN_LINUX_GNUEABIHF_LINKER=arm-linux-gnueabihf-gcc
20+
21+
# Install Slint build dependencies (libxcb, etc.)
22+
RUN apt-get update && \
23+
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 && \
24+
rm -rf /var/lib/apt/lists/*
25+
26+
# Don't require font-config when the compiler runs
27+
ENV RUST_FONTCONFIG_DLOPEN=on
28+
29+
# Build Demos
30+
COPY . /slint
31+
WORKDIR /slint
32+
RUN mkdir demos \
33+
&& for demo in printerdemo slide_puzzle gallery opengl_underlay carousel todo; do \
34+
cargo build --release --target $RUST_TOOLCHAIN_ARCH --features slint/renderer-winit-skia -p $demo; \
35+
cp target/$RUST_TOOLCHAIN_ARCH/release/$demo ./demos/; \
36+
done
37+
38+
# Create container for target
39+
FROM --platform=$IMAGE_ARCH torizon/$BASE_NAME:2
40+
41+
RUN apt-get update \
42+
&& apt-get install libfontconfig1 \
43+
&& rm -rf /var/lib/apt/lists/*
44+
45+
COPY --from=build /slint/demos/* /usr/bin/
46+
47+
ENV SLINT_FULLSCREEN=1
48+
ENV SLINT_BACKEND=winit-skia
49+
CMD /usr/bin/printerdemo

0 commit comments

Comments
 (0)
Please sign in to comment.