Skip to content

Build Jetson Code in Docker #6

Build Jetson Code in Docker

Build Jetson Code in Docker #6

name: Build Jetson Code in Docker
on:
push:
tags:
- 'v[0-9]+.[0-9]+.[0-9]+-jetson'
paths-ignore:
- 'doc/**'
- 'example/**'
- '.github/**'
- '.vscode/**'
- '*.md'
workflow_dispatch:
inputs:
build_type:
description: 'Build type (Debug/Release)'
required: true
default: 'Release'
docker_image:
description: 'NVIDIA L4T JetPack image tag'
required: true
default: 'nvcr.io/nvidia/l4t-base:r36.2.0'
jobs:
build:
runs-on: ubuntu-24.04-arm
strategy:
matrix:
build_type: [Debug]
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
submodules: recursive
- name: Create Dockerfile
run: |
cat <<'EOF' > Dockerfile
FROM ${{ github.event.inputs.docker_image || 'nvcr.io/nvidia/l4t-base:r36.2.0' }}
RUN apt-get update --fix-missing && \
apt-get install -y \
wget \
curl \
cmake \
clang \
build-essential \
mosquitto-dev \
libboost-program-options-dev \
libavformat-dev \
libavcodec-dev \
libavutil-dev \
libswscale-dev \
libpulse-dev \
libasound2-dev \
libjpeg-dev \
libcamera-dev \
libmosquitto-dev \
protobuf-compiler \
libprotobuf-dev && \
rm -rf /var/lib/apt/lists/*
RUN mkdir -p /tmp/webrtc && cd /tmp/webrtc && \
wget -q https://github.com/TzuHuanTai/Native-WebRTC-Build/releases/download/5790/libwebrtc-arm64.tar.gz && \
tar -xzf libwebrtc-arm64.tar.gz && \
mkdir -p /usr/local/include/webrtc && \
mv include/* /usr/local/include/webrtc && \
mv lib/* /usr/local/lib && \
mkdir -p /usr/local/include/nlohmann && \
curl -L https://raw.githubusercontent.com/nlohmann/json/v3.11.3/single_include/nlohmann/json.hpp -o /usr/local/include/nlohmann/json.hpp && \
rm -rf /tmp/webrtc
EOF
- name: Cache Docker layers
uses: actions/cache@v4
with:
path: /tmp/.buildx-cache
key: docker-${{ github.event.inputs.docker_image }}-${{ hashFiles('Dockerfile') }}
restore-keys: |
docker-${{ github.event.inputs.docker_image }}-
- name: Build Docker Image
run: |
docker build -t jetson-build-env .
- name: Build inside Docker
run: |
docker run --rm \
-v ${{ github.workspace }}:/app \
jetson-build-env \
/bin/bash -c "
cd /app &&
mkdir -p build &&
cd build &&
cmake .. -DCMAKE_CXX_COMPILER=clang++ -DPLATFORM=jetson -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} &&
make -j\$(nproc)
"
- name: Zip binary
id: zip-binary
run: |
cd build
if [ "${{ matrix.build_type }}" == "Release" ]; then
FILENAME="pi-webrtc-${{ github.ref_name }}.tar.gz"
else
FILENAME="pi-webrtc-${{ github.ref_name }}_debug.tar.gz"
fi
tar -czvf $FILENAME pi-webrtc
echo "filename=$FILENAME" >> $GITHUB_OUTPUT
- name: Upload to GitHub Release
if: startsWith(github.ref, 'refs/tags/')
uses: softprops/action-gh-release@v2
with:
files: build/${{ steps.zip-binary.outputs.filename }}