Skip to content

Commit

Permalink
Add containerization for samples w/ container documentation (#64)
Browse files Browse the repository at this point in the history
* Add containerization for samples w/ container documentation

* Fix fmt warnings

* fix linking issues

* Remove unecessary .to_string

* updated comment and readme wording

* Update rust ci

* Added -y
  • Loading branch information
devkelley authored Nov 6, 2023
1 parent 44e6bbd commit 0e5e1ba
Show file tree
Hide file tree
Showing 26 changed files with 768 additions and 115 deletions.
2 changes: 2 additions & 0 deletions .accepted_words.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ chariott
com
config
containerized
Containerization
Ctrl
dev
digitaltwins
Expand Down Expand Up @@ -48,6 +49,7 @@ libfontconfig
libsdl
localhost
loopback
md
microsoft
minimalistic
mosquitto
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/check-spelling.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,10 @@ jobs:
- name: Check spelling
run: |
./tools/check_spelling.sh ./README.md
./tools/check_spelling.sh ./container/README.md
./tools/check_spelling.sh ./core/common/README.md
./tools/check_spelling.sh ./dtdl-parser/README.md
./tools/check_spelling.sh ./docs/design/README.md
./tools/check_spelling.sh ./samples/container/README.md
./tools/check_spelling.sh ./samples/managed_subscribe/README.md
shell: bash
4 changes: 2 additions & 2 deletions .github/workflows/rust-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
with:
submodules: recursive
- name: Install packages
run: sudo apt-get install -y protobuf-compiler libsdl2-dev
run: sudo apt-get update -y && sudo apt-get install -y protobuf-compiler libsdl2-dev
- name: Install .NET 7.0
uses: actions/setup-dotnet@v3
with:
Expand Down Expand Up @@ -54,7 +54,7 @@ jobs:
with:
submodules: recursive
- name: Install packages
run: sudo apt-get install -y protobuf-compiler libsdl2-dev
run: sudo apt-get update -y && sudo apt-get install -y protobuf-compiler libsdl2-dev
- name: Install .NET 7.0
uses: actions/setup-dotnet@v3
with:
Expand Down
6 changes: 2 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
# 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/
Expand Down Expand Up @@ -63,13 +61,13 @@ USER appuser
WORKDIR /sdv

# Set home environment variable.
ENV IBEJI_HOME=/sdv
ENV IBEJI_HOME=/sdv/config

# Copy the executable from the "build" stage.
COPY --from=build /sdv/service /sdv/

# Copy configuration for service.
COPY --from=build /sdv/container/config/standalone/ /sdv/
COPY --from=build /sdv/container/config/standalone/ /sdv/config

# Expose the port that the application listens on.
EXPOSE 5010
Expand Down
6 changes: 2 additions & 4 deletions Dockerfile.integrated
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
# 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/
Expand Down Expand Up @@ -63,13 +61,13 @@ USER appuser
WORKDIR /sdv

# Set home environment variable.
ENV IBEJI_HOME=/sdv
ENV IBEJI_HOME=/sdv/config

# Copy the executable from the "build" stage.
COPY --from=build /sdv/service /sdv/

# Copy configuration for service.
COPY --from=build /sdv/container/config/integrated/ /sdv/
COPY --from=build /sdv/container/config/integrated/ /sdv/config

# Expose the port that the application listens on.
EXPOSE 5010
Expand Down
83 changes: 4 additions & 79 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,6 @@
- [Streaming Sample](#streaming-sample)
- [Using Chariott](#using-chariott)
- [Running in a Container](#running-in-a-container)
- [Dockerfile](#dockerfile)
- [Docker](#docker)
- [Podman](#podman)
- [Trademarks](#trademarks)

## <a name="introduction">Introduction</a>
Expand Down Expand Up @@ -75,7 +72,8 @@ sudo apt install -y protobuf-compiler

### <a name="install-sdl2-library">Install SDL2 library</a>

You will need to install the libsdl2-dev library. This can be done by executing:
You will need to install the libsdl2-dev library. This is used by the streaming sample to view
images. Install the libsdl2-dev library by executing:

```shell
sudo apt install -y libsdl2-dev
Expand Down Expand Up @@ -299,82 +297,9 @@ rather than having it statically provided in their respective config file, then

## <a name="running-in-a-container">Running in a Container</a>

Below are the steps for running the service in a container. Note that the configuration files used
by the containerized service are cloned from [container/config](./container/config/) defined in the
project's root.
To run the In-Vehicle Digital Twin Service in a container, please refer to [Ibeji Containerization](./container/README.md).

### <a name="dockerfile">Dockerfile</a>

There are currently two dockerfiles provided in the root directory of the project that can be built:

- Dockerfile - A standalone version of the In-Vehicle Digital Twin Service
- Dockerfile.integrated - A version of the In-Vehicle Digital Twin Service that communicates with
the [Chariott Service](https://github.com/eclipse-chariott/chariott) and the
[Agemo Service](https://github.com/eclipse-chariott/Agemo).

### <a name="docker">Docker</a>

<b>Prerequisites</b>

[Install Docker](https://docs.docker.com/engine/install/)

<b>Running in Docker</b>

To run the service in a Docker container:

1. Run the following command in the project's root directory to build the docker container from the
Dockerfile:

```shell
docker build -t invehicle_digital_twin -f Dockerfile .
```

1. Once the container has been built, start the container in interactive mode with the following
command in the project's root directory:

```shell
docker run --name invehicle_digital_twin -p 5010:5010 --env-file=./container/config/docker.env --add-host=host.docker.internal:host-gateway -it --rm invehicle_digital_twin
```

1. To detach from the container, enter:

<kbd>Ctrl</kbd> + <kbd>p</kbd>, <kbd>Ctrl</kbd> + <kbd>q</kbd>

1. To stop the container, enter:

```shell
docker stop invehicle_digital_twin
```

### <a name="podman">Podman</a>

<b>Prerequisites</b>

[Install Podman](https://podman.io/docs/installation)

<b>Running in Podman</b>

To run the service in a Podman container:

1. Run the following command in the project's root directory to build the podman container from the
Dockerfile:
```shell
podman build -t invehicle_digital_twin:latest -f Dockerfile .
```
1. Once the container has been built, start the container with the following command in the
project's root directory:

```shell
podman run -p 5010:5010 --env-file=./container/config/podman.env --network=slirp4netns:allow_host_loopback=true localhost/invehicle_digital_twin
```

1. To stop the container, run:

```shell
podman ps -f ancestor=localhost/invehicle_digital_twin:latest --format="{{.Names}}" | xargs podman stop
```
To run the samples in a container, please refer to [Samples Containerization](./samples/container/README.md).

## <a name="trademarks">Trademarks</a>

Expand Down
91 changes: 91 additions & 0 deletions container/.accepted_words.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
Agemo
agemo
br
build
cargo
cd
CHARIOTT
Chariott
Chariott's
chariott
com
config
containerize
containerized
Containerization
Ctrl
dev
digitaltwins
dir
Dockerfile
dockerfile
dockerfiles
dotnet
dst
dt
dtdl
DTDL
en
env
fontconfig
gcc
gcc's
github
hardcheese
haudebourg
https
ibeji
Ibeji
Ibeji's
intellectualproperty
invehicle
io
iot
js
json
JSON
kbd
ld
LD
libfontconfig
libsdl
localhost
loopback
md
microsoft
minimalistic
mosquitto
Mosquitto
mqtt
MQTT
netns
opendigitaltwins
plugandplay
Podman
podman
protobuf
Protobuf
ps
repo
Repo
rm
ro
rustup
sdk
sdl
SDL
sdv
slirp
snapd
src
standalone
sudo
timothee
toml
Tonic
toolchain
uri
URI
www
xargs
yaml
Loading

0 comments on commit 0e5e1ba

Please sign in to comment.