Skip to content

Commit

Permalink
added pipeline for arm, changed to musl, fixed openssl issue
Browse files Browse the repository at this point in the history
  • Loading branch information
ValMobBIllich committed Jan 27, 2025
1 parent 8da0461 commit 6f1ecc2
Show file tree
Hide file tree
Showing 9 changed files with 182 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,8 @@ name: Containerize UStreamer and Push to Container Registry

on:
push:
branches: [main]
pull_request:
paths:
- ".github/**"
- "**/src/**"
- "**/Cargo.*"
workflow_call:
branches:
- main
workflow_dispatch:

env:
Expand Down Expand Up @@ -80,7 +75,7 @@ jobs:
uses: docker/build-push-action@v5
with:
context: .
file: "Dockerfile.zenoh_mqtt"
file: "Dockerfile.zenoh_mqtt-amd"
push: true
platforms: linux/amd64
tags: ${{ steps.meta.outputs.tags }}
Expand Down
81 changes: 81 additions & 0 deletions .github/workflows/containerize-and-push_arm.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
# ********************************************************************************
# Copyright (c) 2024 Contributors to the Eclipse Foundation
#
# See the NOTICE file(s) distributed with this work for additional
# information regarding copyright ownership.
#
# This program and the accompanying materials are made available under the
# terms of the Apache License Version 2.0 which is available at
# https://www.apache.org/licenses/LICENSE-2.0
#
# SPDX-License-Identifier: Apache-2.0
# *******************************************************************************/

name: Containerize UStreamer and Push to Container Registry

on:
push:
branches:
- main
workflow_dispatch:

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}/zenoh-mqtt-streamer

jobs:
build-binary:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write

steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker buildx
uses: docker/setup-buildx-action@v3

- name: Login to the Container registry
uses: docker/login-action@v3
with:
username: ${{ vars.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Extract metadata and create tag
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=ref,event=branch
type=ref,event=tag
type=ref,event=pr
- name: Install Rust
uses: actions-rs/toolchain@v1
with:
toolchain: stable
profile: minimal
override: true

- name: Install Cross
run: |
cargo install cross --git https://github.com/cross-rs/cross
- name: Cross Build for amd64
working-directory: example-streamer-implementations
run: |
cross build --target aarch64-unknown-linux-musl --bin zenoh_mqtt --features="zenoh-transport mqtt-transport" --release
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: .
file: "Dockerfile.zenoh_mqtt-arm-musl"
push: true
platforms: linux/arm64
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
17 changes: 13 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,12 @@ members = [
"example-streamer-uses",
"utils/hello-world-protos",
"utils/integration-test-utils",
"example-streamer-implementations", "up-linux-streamer-plugin",
"up-streamer", "subscription-cache", "utils/usubscription-static-file"]
"example-streamer-implementations",
"up-linux-streamer-plugin",
"up-streamer",
"subscription-cache",
"utils/usubscription-static-file",
]

[workspace.package]
rust-version = "1.76.0"
Expand All @@ -35,11 +39,16 @@ env_logger = { version = "0.10.1" }
futures = { version = "0.3.30" }
lazy_static = { version = "1.5.0" }
log = { version = "0.4.20" }
json5 = { version = "0.4.1" }
json5 = { version = "0.4.1" }
serde = { version = "1.0.154", features = ["derive"] }
serde_json = { version = "1.0.94" }
uuid = { version = "1.7.0" }
tokio = { version = "1.35.1", default-features = false, features = ["rt", "rt-multi-thread", "sync", "time"] }
tokio = { version = "1.35.1", default-features = false, features = [
"rt",
"rt-multi-thread",
"sync",
"time",
] }
protobuf = { version = "3.3", features = ["with-bytes"] }
up-rust = { version = "0.2.0", default-features = false }
up-transport-zenoh = { version = "0.3.0" }
Expand Down
15 changes: 9 additions & 6 deletions Cross.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,15 @@ pre-build = [
"apt-get update && apt-get install --assume-yes libssl-dev:$CROSS_DEB_ARCH",
]

[target.aarch64-unknown-linux-gnu]
[target.x86_64-unknown-linux-musl]
pre-build = [
"dpkg --add-architecture $CROSS_DEB_ARCH",
"apt-get update && apt-get install pkg-config --assume-yes libssl-dev:$CROSS_DEB_ARCH",
"export GIT_DISCOVERY_ACROSS_FILESYSTEM=1",
"apt-get update && apt-get install --assume-yes libssl-dev",
"export OPENSSL_ROOT_DIR=/usr",
"export OPENSSL_INCLUDE_DIR=/usr/include/aarch64-linux-gnu/openssl",
"export OPENSSL_LIBRARIES=/usr/lib/aarch64-linux-gnu",
]

[target.aarch64-unknown-linux-gnu]
# [build.env]
# passthrough = ["CMAKE_TOOLCHAIN_FILE_aarch64_unknown_linux_gnu"]

[build.env]
passthrough = ["CMAKE_TOOLCHAIN_FILE_aarch64_unknown_linux_musl"]
23 changes: 23 additions & 0 deletions Dockerfile.crossbuild
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
FROM ghcr.io/cross-rs/x86_64-unknown-linux-musl:latest
## Base rust 'cross' image for compiling on x86:64-unknown-linux-musl (gl-inet)
ENV OPENSSL_V="1.1.1t"
ENV OPENSSL_LIB_DIR=/tmp/openssl-${OPENSSL_V}
ENV OPENSSL_INCLUDE_DIR=/tmp/openssl-${OPENSSL_V}/include

RUN set -o errexit \
&& apt-get update \
&& apt install --yes wget clang g++-multilib \
&& cd /tmp \
&& wget https://www.openssl.org/source/openssl-${OPENSSL_V}.tar.gz \
&& tar xzf openssl-${OPENSSL_V}.tar.gz \
&& export MACHINE=x86_64 \
&& export ARCH=x86_64-linux-muslsf \
&& export CC=${ARCH}-gcc \
&& cd /tmp/openssl-${OPENSSL_V} \
&& ./config \
&& make

RUN export OPENSSL_V="1.1.1t" \
&& export OPENSSL_LIB_DIR=/tmp/openssl-${OPENSSL_V} \
&& export OPENSSL_DIR=/tmp/openssl-${OPENSSL_V} \
&& export OPENSSL_INCLUDE_DIR=/tmp/openssl-${OPENSSL_V}/include
21 changes: 21 additions & 0 deletions Dockerfile.zenoh_mqtt-amd
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
FROM --platform=linux/amd64 debian:bullseye-slim

ENV DEBIAN_FRONTEND=noninteractive
ENV RUST_LOG=trace

RUN apt-get update && apt-get install -y \
libc6 \
libgcc-s1 \
libstdc++6 \
&& rm -rf /var/lib/apt/lists/*

WORKDIR /app

COPY target/x86_64-unknown-linux-gnu/release/zenoh_mqtt /app/zenoh_mqtt

RUN chmod +x /app/zenoh_mqtt

EXPOSE 7447
EXPOSE 1883

CMD ["./zenoh_mqtt", "--config", "config/CONFIG.json5"]
21 changes: 21 additions & 0 deletions Dockerfile.zenoh_mqtt-arm
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
FROM --platform=linux/amd64 debian:bullseye-slim

ENV DEBIAN_FRONTEND=noninteractive
ENV RUST_LOG=trace

RUN apt-get update && apt-get install -y \
libc6 \
libgcc-s1 \
libstdc++6 \
&& rm -rf /var/lib/apt/lists/*

WORKDIR /app

COPY target/x86_64-unknown-linux-gnu/release/zenoh_mqtt /app/zenoh_mqtt

RUN chmod +x /app/zenoh_mqtt

EXPOSE 7447
EXPOSE 1883

CMD ["./zenoh_mqtt", "--config", "config/CONFIG.json5"]
10 changes: 10 additions & 0 deletions Dockerfile.zenoh_mqtt-arm-musl
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
FROM scratch

WORKDIR /app

COPY target/aarch64-unknown-linux-musl/release/zenoh_mqtt /app/zenoh_mqtt

EXPOSE 7447
EXPOSE 1883

CMD ["./zenoh_mqtt", "--config", "config/CONFIG.json5"]
2 changes: 1 addition & 1 deletion docker/docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
services:
ustreamer:
image: ustreamer:latest
image: benediktillich/streamertest:latest
ports:
- 3883:1883
- 7447:7447
Expand Down

0 comments on commit 6f1ecc2

Please sign in to comment.