Skip to content

Commit

Permalink
updates
Browse files Browse the repository at this point in the history
  • Loading branch information
ladatz committed Apr 1, 2024
1 parent 2f5cfad commit 6388fd9
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 16 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/containerize-sample-workloads.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Licensed under the MIT license.
# SPDX-License-Identifier: MIT

name: Containerize In-Vehicle Stack - Chariott
name: Containerize Sample Workloads - Smart Trailer

on:
workflow_dispatch:
Expand Down Expand Up @@ -38,7 +38,7 @@ jobs:
file: Dockerfile.sample_workloads
platforms: linux/amd64,linux/arm64
push: true
tags: ghcr.io/ladatz/software-orchestration/invehicle-stack/trailer-properties-provider:0.1.0
tags: ghcr.io/eclipse-sdv-blueprints/software-orchestration/invehicle-stack/trailer-properties-provider:0.1.0

- name: Build and push multi-platform Docker image for the Trailer Connected Provider
uses: docker/build-push-action@v5
Expand All @@ -47,7 +47,7 @@ jobs:
file: Dockerfile.sample_workloads
platforms: linux/amd64,linux/arm64
push: true
tags: ghcr.io/ladatz/software-orchestration/invehicle-stack/trailer-connected-provider:0.1.0
tags: ghcr.io/eclipse-sdv-blueprints/software-orchestration/invehicle-stack/trailer-connected-provider:0.1.0
build-args: |
APP_NAME=trailer_connected_provider
Expand All @@ -58,7 +58,7 @@ jobs:
file: Dockerfile.sample_workloads
platforms: linux/amd64,linux/arm64
push: true
tags: ghcr.io/ladatz/software-orchestration/invehicle-stack/smart-trailer-application:0.1.0
tags: ghcr.io/eclipse-sdv-blueprints/software-orchestration/invehicle-stack/smart-trailer-application:0.1.0
build-args: |
APP_NAME=smart_trailer_application
36 changes: 27 additions & 9 deletions scenarios/smart_trailer/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,41 +27,59 @@ the language of your choice to generate clients for interacting with the service
To containerize the sample workloads, follow the steps below for your container engine:

- Run the following command in this directory to build the docker container. If you run it from another
directory, adjust this command accordingly because the docker build context is the directory where this
README.md and the Dockerfile.sample_workloads files are located.

>Note: The dockerfile defaults to build the
[Trailer Properties Provider](./digital_twin_providers/trailer_properties_provider/) if a build
argument is not provided.

#### Building with Docker

- Run the following command in this directory to build the docker container.

```shell
docker build -t <image_name> -f Dockerfile.sample_workloads [--build-arg=APP_NAME=<workload_name>] .
```
For example, to build an image for the `smart_trailer_application` workload:

```shell
docker build -t ghcr.io/ladatz/sdvblueprint/smart_trailer_application:0.1.0 -f Dockerfile.sample_workloads --build-arg APP_NAME=smart_trailer_application .
docker build -t ghcr.io/sdvblueprint/smart_trailer_application:0.1.0 -f Dockerfile.sample_workloads --build-arg APP_NAME=smart_trailer_application .
```

- You can also use docker buildx build for cross-compilation, for example to build and push to a container registry:
- If you build the container from another directory, change the -f argument and the build context.
The docker build context is the directory where this README.md and the Dockerfile.sample_workloads
files are located. For example, if you run build from the root of this repository, the command
would be:

```shell
docker build -t <image_name> -f <path_to>/Dockerfile.sample_workloads [--build-arg=APP_NAME=<workload_name>] <path_to_dockerfile_directory>
```
For example, to build an image for the `smart_trailer_application` workload:

```shell
docker build -t ghcr.io/sdvblueprint/smart_trailer_application:0.1.0 -f ./scenarios/smart_trailer/Dockerfile.sample_workloads --build-arg APP_NAME=smart_trailer_application ./scenarios/smart_trailer
```

#### Building with Docker Buildx build for cross-compilation

- To use docker buildx build for cross-compilation, for example to build and push to a container registry:

```shell
docker buildx build [--platform=<platform_name(s)>] -t <image_name> -f Dockerfile.sample_workloads [--build-arg=APP_NAME=<workload_name>] . --push
```
For example, to build an image for the `smart_trailer_application` workload for linux/amd64 and linux/arm64:

```shell
docker buildx build --platform=linux/amd64,linux/arm64 -t ghcr.io/ladatz/sdvblueprint/smart_trailer_application:0.1.0 -f Dockerfile.sample_workloads --build-arg APP_NAME=smart_trailer_application . --push
docker buildx build --platform=linux/amd64,linux/arm64 -t ghcr.io/sdvblueprint/smart_trailer_application:0.1.0 -f Dockerfile.sample_workloads --build-arg APP_NAME=smart_trailer_application . --push
```

- You can also use podman:
#### Building with Podman

- Run the following command in this directory to build the podman container.

```shell
podman build -t <image_name> -f Dockerfile.sample_workloads [--build-arg=APP_NAME=<workload_name>] .
```
For example, to build an image for the `smart_trailer_application` workload:

```shell
podman build -t ghcr.io/ladatz/sdvblueprint/smart_trailer_application:0.1.0 -f Dockerfile.sample_workloads --build-arg APP_NAME=smart_trailer_application .
podman build -t ghcr.io/sdvblueprint/smart_trailer_application:0.1.0 -f Dockerfile.sample_workloads --build-arg APP_NAME=smart_trailer_application .
```
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ use parking_lot::RwLock;
use serde_derive::{Deserialize, Serialize};
use strum_macros::{Display, EnumString};
use tokio::sync::{mpsc, watch};
use tokio::task::JoinHandle;
use tokio::time::{sleep, Duration};
use tonic::{Request, Response, Status};

Expand Down Expand Up @@ -165,7 +166,7 @@ impl TrailerPropertiesProviderImpl {
let data_stream = self.data_stream.clone();

// Start thread for new topic.
tokio::spawn(async move {
let _handle: JoinHandle<Result<(), String>> = tokio::spawn(async move {
// Get constraints information.
let mut frequency_ms = min_interval_ms;

Expand All @@ -181,7 +182,7 @@ impl TrailerPropertiesProviderImpl {
// See if we need to shutdown.
if reciever.try_recv() == Err(mpsc::error::TryRecvError::Disconnected) {
info!("Shutdown thread for {topic}.");
return Result::<(), String>::Ok(());
return Ok(());
}

// Get data from stream at the current instant.
Expand All @@ -205,7 +206,7 @@ impl TrailerPropertiesProviderImpl {
// Sleep for requested amount of time.
sleep(Duration::from_millis(frequency_ms)).await;
}
Result::<(), String>::Ok(())
Ok(())
});
Ok(())
}
Expand Down

0 comments on commit 6388fd9

Please sign in to comment.