From 5eba7176283655ef43eb61995e0c3dda912431d3 Mon Sep 17 00:00:00 2001 From: Devin Kelley <105753233+devkelley@users.noreply.github.com> Date: Mon, 11 Mar 2024 16:03:17 -0700 Subject: [PATCH 1/7] Add multi images and update Rust version to 1.74 --- Dockerfile.amd64 | 2 +- Dockerfile.arm64 | 2 +- Dockerfile.mosquitto.multi | 20 ++++++ Dockerfile.multi | 115 +++++++++++++++++++++++++++++++++++ Dockerfile.samples.amd64 | 2 +- Dockerfile.samples.arm64 | 2 +- Dockerfile_integrated.amd64 | 2 +- Dockerfile_integrated.arm64 | 2 +- Dockerfile_integrated.multi | 118 ++++++++++++++++++++++++++++++++++++ docs/containers.md | 21 +++++++ 10 files changed, 280 insertions(+), 6 deletions(-) create mode 100644 Dockerfile.mosquitto.multi create mode 100644 Dockerfile.multi create mode 100644 Dockerfile_integrated.multi diff --git a/Dockerfile.amd64 b/Dockerfile.amd64 index 0265284..3402b63 100644 --- a/Dockerfile.amd64 +++ b/Dockerfile.amd64 @@ -11,7 +11,7 @@ ################################################################################ # Create a stage for building the application. -ARG RUST_VERSION=1.72.1 +ARG RUST_VERSION=1.74 ARG APP_NAME=pub-sub-service ARG UID=10001 diff --git a/Dockerfile.arm64 b/Dockerfile.arm64 index 94e7e7f..8a2f4b4 100644 --- a/Dockerfile.arm64 +++ b/Dockerfile.arm64 @@ -11,7 +11,7 @@ ################################################################################ # Create a stage for building the application. -ARG RUST_VERSION=1.72.1 +ARG RUST_VERSION=1.74 ARG APP_NAME=pub-sub-service ARG UID=10001 diff --git a/Dockerfile.mosquitto.multi b/Dockerfile.mosquitto.multi new file mode 100644 index 0000000..cb0bfa9 --- /dev/null +++ b/Dockerfile.mosquitto.multi @@ -0,0 +1,20 @@ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT license. +# SPDX-License-Identifier: MIT + +# syntax=docker/dockerfile:1 + +# Comments are provided throughout this file to help you get started. +# If you need more help, visit the Dockerfile reference guide at +# https://docs.docker.com/engine/reference/builder/ + +################################################################################ +# Create a stage for building the application. + +FROM --platform=$TARGETPLATFORM docker.io/library/eclipse-mosquitto +WORKDIR /mosquitto/config + +COPY ./pub-sub-service/src/connectors/mosquitto.conf ./mosquitto.conf + +# Expose the port that the mqtt broker listens on. +EXPOSE 1883 diff --git a/Dockerfile.multi b/Dockerfile.multi new file mode 100644 index 0000000..bd2ca5f --- /dev/null +++ b/Dockerfile.multi @@ -0,0 +1,115 @@ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT license. +# SPDX-License-Identifier: MIT + +# syntax=docker/dockerfile:1 + +# Comments are provided throughout this file to help you get started. +# If you need more help, visit the Dockerfile reference guide at +# https://docs.docker.com/engine/reference/builder/ + +################################################################################ +# Create a stage for building the application. + +ARG RUST_VERSION=1.74 +ARG APP_NAME=pub-sub-service +ARG UID=10001 + +FROM --platform=$BUILDPLATFORM docker.io/library/rust:${RUST_VERSION} AS build + +# Target architecture to cross-compile +ARG TARGETARCH + +ARG APP_NAME +WORKDIR /sdv + +COPY ./ . + +# Check that APP_NAME argument is valid. +RUN /sdv/container/scripts/argument_sanitizer.sh \ + --arg-value "${APP_NAME}" \ + --regex "^[a-zA-Z_0-9-]+$" || \ + ( echo "Argument sanitizer failed for ARG 'APP_NAME'"; exit 1 ) + +# Check that TARGETARCH argument is valid. +RUN /sdv/container/scripts/argument_sanitizer.sh \ + --arg-value "${TARGETARCH}" \ + --regex "^[a-zA-Z_0-9-]+$" || \ + ( echo "Argument sanitizer failed for ARG 'TARGETARCH'"; exit 1 ) + +# Add Build dependencies. +RUN apt update && apt upgrade -y && apt install -y \ + cmake \ + libssl-dev \ + pkg-config \ + protobuf-compiler + +# Based on the target architecture, add the appropriate build target and build service. +RUN if [ "$TARGETARCH" = "amd64" ]; then \ + CARGOARCH="x86_64-unknown-linux-gnu"; \ + elif [ "$TARGETARCH" = "arm64" ]; then \ + apt install -y gcc-aarch64-linux-gnu; \ + CARGOARCH="aarch64-unknown-linux-gnu"; \ + else \ + echo "Unsupported cross-compile architecture"; \ + exit 1; \ + fi; \ + rustup target add ${CARGOARCH}; \ + cargo build --release --target=${CARGOARCH} -p "${APP_NAME}"; \ + cp /sdv/target/${CARGOARCH}/release/"${APP_NAME}" /sdv/service + +################################################################################ +# Create a new stage for running the application that contains the minimal +# runtime dependencies for the application. This often uses a different base +# image from the build stage where the necessary files are copied from the build +# stage. +# +# The example below uses the debian bullseye image as the foundation for running the app. +# By specifying the "bullseye-slim" tag, it will also use whatever happens to be the +# most recent version of that tag when you build your Dockerfile. If +# reproducability is important, consider using a digest +# (e.g., debian@sha256:ac707220fbd7b67fc19b112cee8170b41a9e97f703f588b2cdbbcdcecdd8af57). +FROM --platform=$TARGETPLATFORM docker.io/library/debian:bullseye-slim AS final +ARG UID + +# Copy container scripts. +COPY ./container/scripts/*.sh /sdv/scripts/ + +# Check that UID argument is valid. +RUN /sdv/scripts/argument_sanitizer.sh \ + --arg-value "${UID}" \ + --regex "^[0-9]+$" || \ + ( echo "Argument sanitizer failed for ARG 'UID'"; exit 1 ) + +# Create a non-privileged user that the app will run under. +# See https://docs.docker.com/develop/develop-images/dockerfile_best-practices/#user +RUN adduser \ + --disabled-password \ + --gecos "" \ + --home "/nonexistent" \ + --shell "/sbin/nologin" \ + --no-create-home \ + --uid "${UID}" \ + appuser + +# Create and add user ownership to config directory. +RUN mkdir -p /sdv/.agemo/config +RUN chown appuser /sdv/.agemo/config + +# Create mnt directory to copy override configs into. +RUN mkdir -p /mnt/config + +USER appuser + +WORKDIR /sdv + +ENV AGEMO_HOME=/sdv/.agemo + +# Copy the executable from the "build" stage. +COPY --from=build /sdv/service /sdv/ + +# Expose the port that the application listens on. +EXPOSE 50051 + +# What the container should run when it is started. +CMD ["/sdv/scripts/container_startup.sh"] diff --git a/Dockerfile.samples.amd64 b/Dockerfile.samples.amd64 index b625b54..2a4fd96 100644 --- a/Dockerfile.samples.amd64 +++ b/Dockerfile.samples.amd64 @@ -11,7 +11,7 @@ ################################################################################ # Create a stage for building the application. -ARG RUST_VERSION=1.72.1 +ARG RUST_VERSION=1.74 ARG APP_NAME=simple-publisher ARG UID=10001 diff --git a/Dockerfile.samples.arm64 b/Dockerfile.samples.arm64 index c2e7637..13320a3 100644 --- a/Dockerfile.samples.arm64 +++ b/Dockerfile.samples.arm64 @@ -11,7 +11,7 @@ ################################################################################ # Create a stage for building the application. -ARG RUST_VERSION=1.72.1 +ARG RUST_VERSION=1.74 ARG APP_NAME=simple-publisher ARG UID=10001 diff --git a/Dockerfile_integrated.amd64 b/Dockerfile_integrated.amd64 index 9b5142e..bb78f37 100644 --- a/Dockerfile_integrated.amd64 +++ b/Dockerfile_integrated.amd64 @@ -11,7 +11,7 @@ ################################################################################ # Create a stage for building the application. -ARG RUST_VERSION=1.72.1 +ARG RUST_VERSION=1.74 ARG APP_NAME=pub-sub-service ARG UID=10001 diff --git a/Dockerfile_integrated.arm64 b/Dockerfile_integrated.arm64 index f6af23c..c1aa939 100644 --- a/Dockerfile_integrated.arm64 +++ b/Dockerfile_integrated.arm64 @@ -11,7 +11,7 @@ ################################################################################ # Create a stage for building the application. -ARG RUST_VERSION=1.72.1 +ARG RUST_VERSION=1.74 ARG APP_NAME=pub-sub-service ARG UID=10001 diff --git a/Dockerfile_integrated.multi b/Dockerfile_integrated.multi new file mode 100644 index 0000000..25aa4dc --- /dev/null +++ b/Dockerfile_integrated.multi @@ -0,0 +1,118 @@ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT license. +# SPDX-License-Identifier: MIT + +# syntax=docker/dockerfile:1 + +# Comments are provided throughout this file to help you get started. +# If you need more help, visit the Dockerfile reference guide at +# https://docs.docker.com/engine/reference/builder/ + +################################################################################ +# Create a stage for building the application. + +ARG RUST_VERSION=1.74 +ARG APP_NAME=pub-sub-service +ARG UID=10001 + +FROM --platform=$BUILDPLATFORM docker.io/library/rust:${RUST_VERSION} AS build + +# Target architecture to cross-compile +ARG TARGETARCH + +ARG APP_NAME +WORKDIR /sdv + +COPY ./ . + +# Check that APP_NAME argument is valid. +RUN /sdv/container/scripts/argument_sanitizer.sh \ + --arg-value "${APP_NAME}" \ + --regex "^[a-zA-Z_0-9-]+$" || \ + ( echo "Argument sanitizer failed for ARG 'APP_NAME'"; exit 1 ) + +# Check that TARGETARCH argument is valid. +RUN /sdv/container/scripts/argument_sanitizer.sh \ + --arg-value "${TARGETARCH}" \ + --regex "^[a-zA-Z_0-9-]+$" || \ + ( echo "Argument sanitizer failed for ARG 'TARGETARCH'"; exit 1 ) + +# Add Build dependencies. +RUN apt update && apt upgrade -y && apt install -y \ + cmake \ + libssl-dev \ + pkg-config \ + protobuf-compiler + +# Based on the target architecture, add the appropriate build target and build service. +RUN if [ "$TARGETARCH" = "amd64" ]; then \ + CARGOARCH="x86_64-unknown-linux-gnu"; \ + elif [ "$TARGETARCH" = "arm64" ]; then \ + apt install -y gcc-aarch64-linux-gnu; \ + CARGOARCH="aarch64-unknown-linux-gnu"; \ + else \ + echo "Unsupported cross-compile architecture"; \ + exit 1; \ + fi; \ + rustup target add ${CARGOARCH}; \ + cargo build --release --target=${CARGOARCH} -p "${APP_NAME}"; \ + cp /sdv/target/${CARGOARCH}/release/"${APP_NAME}" /sdv/service + +################################################################################ +# Create a new stage for running the application that contains the minimal +# runtime dependencies for the application. This often uses a different base +# image from the build stage where the necessary files are copied from the build +# stage. +# +# The example below uses the debian bullseye image as the foundation for running the app. +# By specifying the "bullseye-slim" tag, it will also use whatever happens to be the +# most recent version of that tag when you build your Dockerfile. If +# reproducability is important, consider using a digest +# (e.g., debian@sha256:ac707220fbd7b67fc19b112cee8170b41a9e97f703f588b2cdbbcdcecdd8af57). +FROM --platform=$TARGETPLATFORM docker.io/library/debian:bullseye-slim AS final +ARG UID + +# Copy container scripts. +COPY ./container/scripts/*.sh /sdv/scripts/ + +# Check that UID argument is valid. +RUN /sdv/scripts/argument_sanitizer.sh \ + --arg-value "${UID}" \ + --regex "^[0-9]+$" || \ + ( echo "Argument sanitizer failed for ARG 'UID'"; exit 1 ) + +# Create a non-privileged user that the app will run under. +# See https://docs.docker.com/develop/develop-images/dockerfile_best-practices/#user +RUN adduser \ + --disabled-password \ + --gecos "" \ + --home "/nonexistent" \ + --shell "/sbin/nologin" \ + --no-create-home \ + --uid "${UID}" \ + appuser + +# Create and add user ownership to config directory. +RUN mkdir -p /sdv/.agemo/config +RUN chown appuser /sdv/.agemo/config + +# Create mnt directory to copy override configs into. +RUN mkdir -p /mnt/config + +USER appuser + +WORKDIR /sdv + +ENV AGEMO_HOME=/sdv/.agemo + +# Copy the executable from the "build" stage. +COPY --from=build /sdv/service /sdv/ + +# Copy the "integrated" config to the override config folder and rename it to what agemo expects +COPY --from=build /sdv/config/pub_sub_service_settings.integrated.yaml /sdv/.agemo/config/pub_sub_service_settings.yaml + +# Expose the port that the application listens on. +EXPOSE 50051 + +# What the container should run when it is started. +CMD ["/sdv/scripts/container_startup.sh"] diff --git a/docs/containers.md b/docs/containers.md index 2760d56..6fc8639 100644 --- a/docs/containers.md +++ b/docs/containers.md @@ -13,6 +13,8 @@ document has instructions for building and running the provided Dockerfiles in x86-64 architecture. - [Dockerfile.arm64](../Dockerfile.arm64) - Dockerfile used to build the `Pub Sub Service` for the aarch64 architecture. +- [Dockerfile.multi](../Dockerfile.arm64) - Dockerfile used to build the `Pub Sub Service` for +multiple architectures based on the TARGETARCH argument. - [Dockerfile_integrated.amd64](../Dockerfile_integrated.amd64) - Dockerfile used to build the `Pub Sub Service` using [Chariott Service Discovery](https://github.com/eclipse-chariott/chariott/blob/main/service_discovery/README.md) @@ -23,6 +25,11 @@ x86-64 architecture. [Chariott Service Discovery](https://github.com/eclipse-chariott/chariott/blob/main/service_discovery/README.md) with the [integrated configuration](../config/pub_sub_service_settings.integrated.yaml) for the aarch64 architecture. +- [Dockerfile_integrated.multi](../Dockerfile_integrated.arm64) - Dockerfile used to build the +`Pub Sub Service` using +[Chariott Service Discovery](https://github.com/eclipse-chariott/chariott/blob/main/service_discovery/README.md) +with the [integrated configuration](../config/pub_sub_service_settings.integrated.yaml) for +multiple architectures based on the TARGETARCH argument. #### Mosquitto MQTT Broker @@ -30,6 +37,9 @@ aarch64 architecture. `Mosquitto MQTT Broker` with the appropriate configuration for the x86-64 architecture. - [Dockerfile.mosquitto.arm64](../Dockerfile.mosquitto.arm64) - Dockerfile used to build the `Mosquitto MQTT Broker` with the appropriate configuration for the aarch64 architecture. +- [Dockerfile.mosquitto.multi](../Dockerfile.mosquitto.arm64) - Dockerfile used to build the +`Mosquitto MQTT Broker` with the appropriate configuration for multiple architectures based on the +TARGETARCH argument. #### Sample Applications @@ -73,6 +83,17 @@ Dockerfile: >Note: The build arg `APP_NAME` needs to be passed in for all sample applications to build the correct sample. + Or to build a multi-platform image for `pub-sub-service` project and push it to a container + registry: + You must first create a new builder using the docker-container driver, which gives you access + to more complex features like multi-platform build. See more information here: + [multi-platform builds.](https://docs.docker.com/build/building/multi-platform/#cross-compilation) + + ```shell + docker buildx create --name multibuilder --driver docker-container --use + docker buildx build --platform=linux/amd64,linux/arm64 -f Dockerfile.multi -t /pub_sub_service_multi --push . + ``` + 1. Once the container has been built, start the container in interactive mode with the following command in the project root directory: From 466aabf5f46c4f0606b6683a443ae30c090ddfd8 Mon Sep 17 00:00:00 2001 From: Devin Kelley <105753233+devkelley@users.noreply.github.com> Date: Mon, 11 Mar 2024 16:10:50 -0700 Subject: [PATCH 2/7] fixed links to files --- docs/containers.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/containers.md b/docs/containers.md index 6fc8639..3726207 100644 --- a/docs/containers.md +++ b/docs/containers.md @@ -13,7 +13,7 @@ document has instructions for building and running the provided Dockerfiles in x86-64 architecture. - [Dockerfile.arm64](../Dockerfile.arm64) - Dockerfile used to build the `Pub Sub Service` for the aarch64 architecture. -- [Dockerfile.multi](../Dockerfile.arm64) - Dockerfile used to build the `Pub Sub Service` for +- [Dockerfile.multi](../Dockerfile.multi) - Dockerfile used to build the `Pub Sub Service` for multiple architectures based on the TARGETARCH argument. - [Dockerfile_integrated.amd64](../Dockerfile_integrated.amd64) - Dockerfile used to build the `Pub Sub Service` using @@ -25,7 +25,7 @@ x86-64 architecture. [Chariott Service Discovery](https://github.com/eclipse-chariott/chariott/blob/main/service_discovery/README.md) with the [integrated configuration](../config/pub_sub_service_settings.integrated.yaml) for the aarch64 architecture. -- [Dockerfile_integrated.multi](../Dockerfile_integrated.arm64) - Dockerfile used to build the +- [Dockerfile_integrated.multi](../Dockerfile_integrated.multi) - Dockerfile used to build the `Pub Sub Service` using [Chariott Service Discovery](https://github.com/eclipse-chariott/chariott/blob/main/service_discovery/README.md) with the [integrated configuration](../config/pub_sub_service_settings.integrated.yaml) for @@ -37,7 +37,7 @@ multiple architectures based on the TARGETARCH argument. `Mosquitto MQTT Broker` with the appropriate configuration for the x86-64 architecture. - [Dockerfile.mosquitto.arm64](../Dockerfile.mosquitto.arm64) - Dockerfile used to build the `Mosquitto MQTT Broker` with the appropriate configuration for the aarch64 architecture. -- [Dockerfile.mosquitto.multi](../Dockerfile.mosquitto.arm64) - Dockerfile used to build the +- [Dockerfile.mosquitto.multi](../Dockerfile.mosquitto.multi) - Dockerfile used to build the `Mosquitto MQTT Broker` with the appropriate configuration for multiple architectures based on the TARGETARCH argument. From 53b01ac45bcb7c5736c7f797f48a6478bf446eac Mon Sep 17 00:00:00 2001 From: Devin Kelley <105753233+devkelley@users.noreply.github.com> Date: Tue, 12 Mar 2024 09:27:53 -0700 Subject: [PATCH 3/7] Downgrade markdown link check version to fix regression causing failure --- .github/workflows/markdown-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/markdown-ci.yml b/.github/workflows/markdown-ci.yml index d9e9644..28150d1 100644 --- a/.github/workflows/markdown-ci.yml +++ b/.github/workflows/markdown-ci.yml @@ -24,5 +24,5 @@ jobs: steps: - uses: actions/checkout@v2 - run: | - npm install markdown-link-check + npm install markdown-link-check@3.11.2 find . -type d \( -name node_modules -o -name .github \) -prune -o -type f -name '*.md' -print0 | xargs -0 -n1 node_modules/.bin/markdown-link-check --config ./tools/.markdownlinkcheck.jsonc --quiet From 1fb2cec2a1b5a6929bab316f86dc9681b0fea46d Mon Sep 17 00:00:00 2001 From: Devin Kelley <105753233+devkelley@users.noreply.github.com> Date: Wed, 13 Mar 2024 09:58:30 -0700 Subject: [PATCH 4/7] Add container specific config.toml to fix library error while leaving local build untouched --- Dockerfile.multi | 2 ++ Dockerfile_integrated.multi | 2 ++ container/cargo/config.toml | 15 +++++++++++++++ pub-sub-service/Cargo.toml | 2 +- 4 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 container/cargo/config.toml diff --git a/Dockerfile.multi b/Dockerfile.multi index bd2ca5f..fc9bdfe 100644 --- a/Dockerfile.multi +++ b/Dockerfile.multi @@ -25,6 +25,8 @@ WORKDIR /sdv COPY ./ . +COPY ./container/cargo/config.toml ./.cargo/config.toml + # Check that APP_NAME argument is valid. RUN /sdv/container/scripts/argument_sanitizer.sh \ --arg-value "${APP_NAME}" \ diff --git a/Dockerfile_integrated.multi b/Dockerfile_integrated.multi index 25aa4dc..58b289d 100644 --- a/Dockerfile_integrated.multi +++ b/Dockerfile_integrated.multi @@ -25,6 +25,8 @@ WORKDIR /sdv COPY ./ . +COPY ./container/cargo/config.toml ./.cargo/config.toml + # Check that APP_NAME argument is valid. RUN /sdv/container/scripts/argument_sanitizer.sh \ --arg-value "${APP_NAME}" \ diff --git a/container/cargo/config.toml b/container/cargo/config.toml new file mode 100644 index 0000000..4628343 --- /dev/null +++ b/container/cargo/config.toml @@ -0,0 +1,15 @@ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT license. +# SPDX-License-Identifier: MIT + +[env] +AGEMO_HOME = { value = ".agemo", relative = true } +AGEMO_SAMPLES_HOME = { value = ".agemo-samples", relative = true } + +[target.aarch64-unknown-linux-gnu] +linker = "aarch64-linux-gnu-gcc" +rustflags = [ "-C", "target-feature=+crt-static", "-C", "link-arg=-lgcc" ] + +[target.x86_64-unknown-linux-gnu] +linker = "x86_64-linux-gnu-gcc" +rustflags = [ "-C", "target-feature=+crt-static", "-C", "link-arg=-lgcc" ] diff --git a/pub-sub-service/Cargo.toml b/pub-sub-service/Cargo.toml index f2410fc..9484ca9 100644 --- a/pub-sub-service/Cargo.toml +++ b/pub-sub-service/Cargo.toml @@ -31,5 +31,5 @@ url = { workspace = true } uuid = { workspace = true, features = [ "v4", "fast-rng", "macro-diagnostics"] } yaml-rust = { workspace = true } -[target.'cfg(target_arch = "aarch64")'.dependencies] +[target.'cfg(any(target_arch = "aarch64", target_arch = "x86_64"))'.dependencies] paho-mqtt = { workspace = true, features = ["vendored-ssl"] } From 2bbcb6994b31548f616dbbd533def65ee21a9b44 Mon Sep 17 00:00:00 2001 From: Devin Kelley <105753233+devkelley@users.noreply.github.com> Date: Mon, 11 Mar 2024 16:03:17 -0700 Subject: [PATCH 5/7] Add multi images and update Rust version to 1.74 --- docs/containers.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/containers.md b/docs/containers.md index 3726207..6fc8639 100644 --- a/docs/containers.md +++ b/docs/containers.md @@ -13,7 +13,7 @@ document has instructions for building and running the provided Dockerfiles in x86-64 architecture. - [Dockerfile.arm64](../Dockerfile.arm64) - Dockerfile used to build the `Pub Sub Service` for the aarch64 architecture. -- [Dockerfile.multi](../Dockerfile.multi) - Dockerfile used to build the `Pub Sub Service` for +- [Dockerfile.multi](../Dockerfile.arm64) - Dockerfile used to build the `Pub Sub Service` for multiple architectures based on the TARGETARCH argument. - [Dockerfile_integrated.amd64](../Dockerfile_integrated.amd64) - Dockerfile used to build the `Pub Sub Service` using @@ -25,7 +25,7 @@ x86-64 architecture. [Chariott Service Discovery](https://github.com/eclipse-chariott/chariott/blob/main/service_discovery/README.md) with the [integrated configuration](../config/pub_sub_service_settings.integrated.yaml) for the aarch64 architecture. -- [Dockerfile_integrated.multi](../Dockerfile_integrated.multi) - Dockerfile used to build the +- [Dockerfile_integrated.multi](../Dockerfile_integrated.arm64) - Dockerfile used to build the `Pub Sub Service` using [Chariott Service Discovery](https://github.com/eclipse-chariott/chariott/blob/main/service_discovery/README.md) with the [integrated configuration](../config/pub_sub_service_settings.integrated.yaml) for @@ -37,7 +37,7 @@ multiple architectures based on the TARGETARCH argument. `Mosquitto MQTT Broker` with the appropriate configuration for the x86-64 architecture. - [Dockerfile.mosquitto.arm64](../Dockerfile.mosquitto.arm64) - Dockerfile used to build the `Mosquitto MQTT Broker` with the appropriate configuration for the aarch64 architecture. -- [Dockerfile.mosquitto.multi](../Dockerfile.mosquitto.multi) - Dockerfile used to build the +- [Dockerfile.mosquitto.multi](../Dockerfile.mosquitto.arm64) - Dockerfile used to build the `Mosquitto MQTT Broker` with the appropriate configuration for multiple architectures based on the TARGETARCH argument. From 0b8d112fce748cdb175dadf34524472a25728bbf Mon Sep 17 00:00:00 2001 From: Devin Kelley <105753233+devkelley@users.noreply.github.com> Date: Mon, 11 Mar 2024 16:10:50 -0700 Subject: [PATCH 6/7] fixed links to files --- docs/containers.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/containers.md b/docs/containers.md index 6fc8639..3726207 100644 --- a/docs/containers.md +++ b/docs/containers.md @@ -13,7 +13,7 @@ document has instructions for building and running the provided Dockerfiles in x86-64 architecture. - [Dockerfile.arm64](../Dockerfile.arm64) - Dockerfile used to build the `Pub Sub Service` for the aarch64 architecture. -- [Dockerfile.multi](../Dockerfile.arm64) - Dockerfile used to build the `Pub Sub Service` for +- [Dockerfile.multi](../Dockerfile.multi) - Dockerfile used to build the `Pub Sub Service` for multiple architectures based on the TARGETARCH argument. - [Dockerfile_integrated.amd64](../Dockerfile_integrated.amd64) - Dockerfile used to build the `Pub Sub Service` using @@ -25,7 +25,7 @@ x86-64 architecture. [Chariott Service Discovery](https://github.com/eclipse-chariott/chariott/blob/main/service_discovery/README.md) with the [integrated configuration](../config/pub_sub_service_settings.integrated.yaml) for the aarch64 architecture. -- [Dockerfile_integrated.multi](../Dockerfile_integrated.arm64) - Dockerfile used to build the +- [Dockerfile_integrated.multi](../Dockerfile_integrated.multi) - Dockerfile used to build the `Pub Sub Service` using [Chariott Service Discovery](https://github.com/eclipse-chariott/chariott/blob/main/service_discovery/README.md) with the [integrated configuration](../config/pub_sub_service_settings.integrated.yaml) for @@ -37,7 +37,7 @@ multiple architectures based on the TARGETARCH argument. `Mosquitto MQTT Broker` with the appropriate configuration for the x86-64 architecture. - [Dockerfile.mosquitto.arm64](../Dockerfile.mosquitto.arm64) - Dockerfile used to build the `Mosquitto MQTT Broker` with the appropriate configuration for the aarch64 architecture. -- [Dockerfile.mosquitto.multi](../Dockerfile.mosquitto.arm64) - Dockerfile used to build the +- [Dockerfile.mosquitto.multi](../Dockerfile.mosquitto.multi) - Dockerfile used to build the `Mosquitto MQTT Broker` with the appropriate configuration for multiple architectures based on the TARGETARCH argument. From 02e1705e40ebcd471933da400a8421dba2ae68ca Mon Sep 17 00:00:00 2001 From: Devin Kelley <105753233+devkelley@users.noreply.github.com> Date: Wed, 13 Mar 2024 09:58:30 -0700 Subject: [PATCH 7/7] Add container specific config.toml to fix library error while leaving local build untouched --- Dockerfile.multi | 2 ++ Dockerfile_integrated.multi | 2 ++ container/cargo/config.toml | 15 +++++++++++++++ pub-sub-service/Cargo.toml | 2 +- 4 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 container/cargo/config.toml diff --git a/Dockerfile.multi b/Dockerfile.multi index bd2ca5f..fc9bdfe 100644 --- a/Dockerfile.multi +++ b/Dockerfile.multi @@ -25,6 +25,8 @@ WORKDIR /sdv COPY ./ . +COPY ./container/cargo/config.toml ./.cargo/config.toml + # Check that APP_NAME argument is valid. RUN /sdv/container/scripts/argument_sanitizer.sh \ --arg-value "${APP_NAME}" \ diff --git a/Dockerfile_integrated.multi b/Dockerfile_integrated.multi index 25aa4dc..58b289d 100644 --- a/Dockerfile_integrated.multi +++ b/Dockerfile_integrated.multi @@ -25,6 +25,8 @@ WORKDIR /sdv COPY ./ . +COPY ./container/cargo/config.toml ./.cargo/config.toml + # Check that APP_NAME argument is valid. RUN /sdv/container/scripts/argument_sanitizer.sh \ --arg-value "${APP_NAME}" \ diff --git a/container/cargo/config.toml b/container/cargo/config.toml new file mode 100644 index 0000000..4628343 --- /dev/null +++ b/container/cargo/config.toml @@ -0,0 +1,15 @@ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT license. +# SPDX-License-Identifier: MIT + +[env] +AGEMO_HOME = { value = ".agemo", relative = true } +AGEMO_SAMPLES_HOME = { value = ".agemo-samples", relative = true } + +[target.aarch64-unknown-linux-gnu] +linker = "aarch64-linux-gnu-gcc" +rustflags = [ "-C", "target-feature=+crt-static", "-C", "link-arg=-lgcc" ] + +[target.x86_64-unknown-linux-gnu] +linker = "x86_64-linux-gnu-gcc" +rustflags = [ "-C", "target-feature=+crt-static", "-C", "link-arg=-lgcc" ] diff --git a/pub-sub-service/Cargo.toml b/pub-sub-service/Cargo.toml index f2410fc..9484ca9 100644 --- a/pub-sub-service/Cargo.toml +++ b/pub-sub-service/Cargo.toml @@ -31,5 +31,5 @@ url = { workspace = true } uuid = { workspace = true, features = [ "v4", "fast-rng", "macro-diagnostics"] } yaml-rust = { workspace = true } -[target.'cfg(target_arch = "aarch64")'.dependencies] +[target.'cfg(any(target_arch = "aarch64", target_arch = "x86_64"))'.dependencies] paho-mqtt = { workspace = true, features = ["vendored-ssl"] }