Skip to content

Commit

Permalink
dotnetAvalonia: Add GPU build arg support
Browse files Browse the repository at this point in the history
This fixes the build for machines that use a different docker image
with special libs for the specific vendor GPU.

NOTE: The Avalonia GTK uses XWayland, anyway, this should not
work with the Vivante GPU.

Related-to: toradex#51
Signed-off-by: Matheus Castello <matheus.castello@toradex.com>
  • Loading branch information
microhobby committed May 20, 2023
1 parent 9dd34c4 commit 6aab1ee
Show file tree
Hide file tree
Showing 3 changed files with 92 additions and 6 deletions.
48 changes: 45 additions & 3 deletions dotnetAvalonia/Dockerfile
Expand Up @@ -7,15 +7,20 @@ ARG IMAGE_ARCH=
##
# Base container version
##
ARG BASE_VERSION=3-6.0
ARG BASE_VERSION=3
ARG DOTNET_BASE_VERSION=3-6.0

##
# Application Name
##
ARG APP_EXECUTABLE=__change__
# ARGUMENTS --------------------------------------------------------------------

##
# Board GPU vendor prefix
##
ARG GPU=

# ARGUMENTS --------------------------------------------------------------------

# BUILD ------------------------------------------------------------------------
FROM mcr.microsoft.com/dotnet/sdk:6.0 AS Build
Expand All @@ -31,16 +36,38 @@ RUN dotnet restore && \
dotnet publish -c Release -r linux-${IMAGE_ARCH} --no-self-contained
# BUILD ------------------------------------------------------------------------

# DOTNET -----------------------------------------------------------------------
FROM --platform=linux/${IMAGE_ARCH} \
torizon/dotnet:${DOTNET_BASE_VERSION} AS Dotnet


# DEPLOY -----------------------------------------------------------------------
FROM --platform=linux/${IMAGE_ARCH} \
torizon/dotnet-uno:${BASE_VERSION} AS Deploy
torizon/wayland-base${GPU}:${BASE_VERSION} AS Deploy

ARG IMAGE_ARCH
ARG GPU
ARG APP_EXECUTABLE
ENV APP_EXECUTABLE ${APP_EXECUTABLE}

ENV DOTNET_ROOT=/dotnet
ENV PATH=$PATH:/dotnet

COPY --from=Dotnet /dotnet /dotnet

# for vivante GPU we need some "special" sauce
RUN apt-get -q -y update && \
if [ "${GPU}" = "-vivante" ]; then \
apt-get -q -y install \
imx-gpu-viv-wayland-dev \
; else \
apt-get -q -y install \
libgl1 \
; fi \
&& \
apt-get clean && apt-get autoremove && \
rm -rf /var/lib/apt/lists/*

RUN apt-get -y update && apt-get install -y --no-install-recommends \
# ADD YOUR PACKAGES HERE
# DOES NOT REMOVE THIS LABEL: this is used for VS Code automation
Expand All @@ -49,8 +76,23 @@ RUN apt-get -y update && apt-get install -y --no-install-recommends \
# DOES NOT REMOVE THIS LABEL: this is used for VS Code automation
libice6 \
libsm6 \
libicu67 \
curl \
gettext \
apt-transport-https \
libx11-6 \
libunwind8 icu-devtools \
libfontconfig1 \
libgtk-3-0 libgtk-3-bin libgtk-3-common \
libdrm2 \
libinput10 \
libssl1.1 \
&& apt-get clean && apt-get autoremove && rm -rf /var/lib/apt/lists/*

RUN printf "{\n \"device\": \"/dev/dri/card1\",\n \"outputs\": [ { \"name\": \"HDMI1\" } ],\n \"hwcursor\": false\n}" > /etc/kms-imx6.conf \
&& printf "{\n \"hwcursor\": false\n}" > /etc/kms-imx8.conf \
&& ln -s /etc/kms-imx8.conf /etc/kms-imx7.conf

# copy the build
COPY --from=Build /build/bin/Release/net6.0/linux-${IMAGE_ARCH}/publish /app

Expand Down
49 changes: 46 additions & 3 deletions dotnetAvalonia/Dockerfile.debug
Expand Up @@ -9,7 +9,8 @@ ARG IMAGE_ARCH=
##
# Base container version
##
ARG BASE_VERSION=3-6.0
ARG BASE_VERSION=3
ARG DOTNET_BASE_VERSION=3-6.0

##
# Application Name
Expand All @@ -26,25 +27,55 @@ ARG SSH_DEBUG_PORT=
##
ARG SSHUSERNAME=

##
# Board GPU vendor prefix
##
ARG GPU=

# DOTNET -----------------------------------------------------------------------
FROM --platform=linux/${IMAGE_ARCH} \
torizon/dotnet:${DOTNET_BASE_VERSION} AS Dotnet


# BUILD ------------------------------------------------------------------------
##
# Deploy Step .NET Uno
##
FROM --platform=linux/${IMAGE_ARCH} \
torizon/dotnet-uno-debug:${BASE_VERSION} AS Debug
torizon/wayland-base${GPU}:${BASE_VERSION} AS Debug

ARG IMAGE_ARCH
ARG GPU
ARG SSH_DEBUG_PORT
ARG APP_EXECUTABLE
ARG SSHUSERNAME
ENV APP_EXECUTABLE ${APP_EXECUTABLE}

ENV DOTNET_ROOT=/dotnet
ENV PATH=$PATH:/dotnet

COPY --from=dotnet /vsdbg /vsdbg
COPY --from=dotnet /dotnet /dotnet

# SSH for remote debug
EXPOSE ${SSH_DEBUG_PORT}

# Make sure we don't get notifications we can't answer during building.
ENV DEBIAN_FRONTEND="noninteractive"

# for vivante GPU we need some "special" sauce
RUN apt-get -q -y update && \
if [ "${GPU}" = "-vivante" ]; then \
apt-get -q -y install \
imx-gpu-viv-wayland-dev \
; else \
apt-get -q -y install \
libgl1 \
; fi \
&& \
apt-get clean && apt-get autoremove && \
rm -rf /var/lib/apt/lists/*

# your regular RUN statements here
# Install required packages
RUN apt-get -q -y update && \
Expand All @@ -54,7 +85,19 @@ RUN apt-get -q -y update && \
rsync \
file \
libice6 \
libsm6 && \
libsm6 \
libicu67 \
curl \
gettext \
apt-utils \
apt-transport-https \
libx11-6 \
libunwind8 icu-devtools \
libfontconfig1 \
libgtk-3-0 libgtk-3-bin libgtk-3-common \
libdrm2 \
libinput10 \
libssl1.1 && \
apt-get clean && apt-get autoremove && \
rm -rf /var/lib/apt/lists/*

Expand Down
1 change: 1 addition & 0 deletions dotnetAvalonia/docker-compose.yml
Expand Up @@ -54,6 +54,7 @@ services:
weston
]

# TODO: we are using bullseye here because an issue with xwayland on bookworm
weston:
image: torizon/weston${GPU}:2
environment:
Expand Down

0 comments on commit 6aab1ee

Please sign in to comment.