Skip to content

Commit

Permalink
Improve builds part 2
Browse files Browse the repository at this point in the history
  • Loading branch information
erikbosch committed Mar 7, 2024
1 parent d869593 commit 24cdb1a
Show file tree
Hide file tree
Showing 7 changed files with 51 additions and 37 deletions.
2 changes: 0 additions & 2 deletions .github/workflows/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
* for sub components like hvac_service and seat_service use pattern:
**\<subcomponent>_\<action> eg: hvac_service**

* for overall tasks use pattern:
**\<action> eg: release**

## Naming of Tags

Expand Down
6 changes: 0 additions & 6 deletions .github/workflows/hvac_integration_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,7 @@ concurrency:

jobs:
integration-test:
# reduce runtime requirements from libc/libc++
runs-on: ubuntu-20.04
# container:
# image: ghcr.io/${{ github.repository }}/oci_kuksa-val-services-ci:v0.1.0
# credentials:
# username: ${{ github.repository_owner }}
# password: ${{ secrets.GITHUB_TOKEN }}

steps:
- name: Adding github workspace as safe directory
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/seat_service.yml
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ jobs:
linux/amd64
linux/arm64
file: ./seat_service/Dockerfile
context: .
context: ./seat_service
push: true
tags: |
${{ steps.meta.outputs.tags }}
Expand All @@ -134,7 +134,7 @@ jobs:
linux/amd64
linux/arm64
file: ./seat_service/Dockerfile
context: .
context: ./seat_service
push: true
tags: "ttl.sh/eclipse-kuksa/kuksa-incubation/seat_service-${{github.sha}}"
labels: ${{ steps.meta.outputs.labels }}
Expand Down
2 changes: 1 addition & 1 deletion hvac_service/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,4 @@ INFO:hvac_service:datapoints are registered.

### Devcontainer

A dev-container exist, you still need to do `pip install`.
A dev-container exist, you still need to do `pip install` before starting hvac_service.
4 changes: 0 additions & 4 deletions seat_service/.devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,5 @@
"twxs.cmake"
]
}
},
"features": {
"ghcr.io/devcontainers/features/docker-in-docker:2": {
}
}
}
2 changes: 1 addition & 1 deletion seat_service/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ ARG TARGETPLATFORM

WORKDIR /workspace

COPY seat_service/bin_vservice-seat_*_release.* /workspace
COPY bin_vservice-seat_*_release.* /workspace

# FIXME! Binaries are built from another base image, potentially incompatible with ubuntu:latest image
# RUN tar -xf bin_vservice-seat_x86_64_release.tar.gz && tar -xf bin_vservice-seat_aarch64_release.tar.gz
Expand Down
68 changes: 47 additions & 21 deletions seat_service/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,24 +53,21 @@ For `aarch64` hosts or for quickly testing a pull request it is easier to use [G

#### Prerequisites

Most existing build scripts rely on that you have Docker installed.
Some scripts also assumes that you use Ubuntu 20.04 as development environment,
by for example building binaries locally and then copying to a docker environment based on Ubuntu 20.04.

1. Install and configure (if needed) local authentication proxy e.g. CNTLM or Px
1. Install and configure docker: [Get Docker](https://docs.docker.com/get-docker/)
1. Build base development docker. Go to the top-level of the repo

``` bash
cd ..
docker build -t oci_kuksa-val-services-ci:latest -f tools/Dockerfile .
# NOTE: If you need to cross compile for different arch:
DOCKER_BUILDKIT=1 docker buildx build --platform linux/arm64 -t oci_kuksa-val-services-ci:arm64 -f tools/Dockerfile --load .
```

#### Usage on CLI

**NOTE:** Building Seat Service on `aarch64` host is not supported at the moment.

##### Building on Ubuntu 20.04

You can use dedicated build docker script [docker-build.sh](./docker-build.sh) if host environment matches target (Ubuntu 20.04):
You can use dedicated build docker script [docker-build.sh](./docker-build.sh) if host environment matches target (Ubuntu 20.04).
Note that you may need to install dependencies - use [.devcontainer/Dockerfile](.devcontainer/Dockerfile) as reference.

``` bash
# Linux: [Ubuntu 20.04]
Expand All @@ -88,39 +85,58 @@ TARGETS:
x86_64|amd64, aarch64|amd64 Target arch to build for, if not set - defaults to multiarch
```
#### Building in DevContainer
##### Creating Docker container for build
If you are using different distro / version, you may use the devcontainer to compile seat service binaries.
First build the Docker container
From the checked-out git folder, to enter a shell execute:
``` bash
$ cd seat_service/.devcontainer
$ docker build -f Dockerfile -t seat_service_env:latest .
```
From the seat_service folder, use Docker like below where `<build-command>`is the command you intend to run
``` bash
cd seat_service

# Linux: [x86_64, any version]
docker run --rm -it -v $(pwd):/workspace oci_kuksa-val-services-ci:latest <build-command>
docker run --rm -it -v $(pwd):/workspace seat_service_env:latest <build-command>

# Windows (cmd)
docker run --rm -it -v %cd%:/workspace oci_kuksa-val-services-ci:latest <build-command>
docker run --rm -it -v %cd%:/workspace seat_service_env:latest <build-command>

# Windows (Powershell)
docker run --rm -it -v ${PWD}:/workspace oci_kuksa-val-services-ci:latest <build-command>
docker run --rm -it -v ${PWD}:/workspace seat_service_env:latest <build-command>
```
##### Build Seat Service binaries
Building the seat service via dev container must be triggered from the project root folder (seat service is referencing kuksa_data_broker/proto), e.g.:
Building the seat service via dev container must be triggered from the seat_service root folder, e.g.:
``` bash
# Linux

cd seat_service

# Cleanup any build artifacts
rm -rf seat_service/bin_vservice-seat_*.tar.gz seat_service/target/
rm -rf bin_vservice-seat_*.tar.gz target/

# Generate seat_service/bin_vservice-seat_*.tar.gz files for packing seat service container
# Generate bin_vservice-seat_*.tar.gz files for packing seat service container
docker run --rm -it -v $(pwd):/workspace oci_kuksa-val-services-ci:latest /bin/bash -c \
"cd seat_service/; ./build-release.sh --pack"
"./build-release.sh --pack"

# Check if release package is build
ls -la seat_service/bin_vservice-seat_*.tar.gz
ls -la bin_vservice-seat_*.tar.gz
```
It shall now be possible to start the service
``` bash
$ docker run --rm -it -v $(pwd):/workspace xxx:latest target/x86_64/release/install/bin/seat_service
Usage: target/x86_64/release/install/bin/seat_service CAN_IF_NAME [LISTEN_ADDRESS [PORT]]

Environment: SEAT_DEBUG=1 to enable SeatDataFeeder dumps
```
##### Build Seat Service container
Expand All @@ -129,17 +145,27 @@ Build the container using pre-built binaries: `seat_service/bin_vservice-seat_*.
``` bash
# Linux
docker build -t seat_service -f seat_service/Dockerfile .
ce seat_service
docker build -t seat_service -f Dockerfile .
```
### Usage in Visual Studio Code
It is also possible to open the repo as a remote container in VScode using the approach [Developing inside a Container](https://code.visualstudio.com/docs/remote/containers).
It is also possible to open the seat_service directory as a remote container in VScode using the approach
[Developing inside a Container](https://code.visualstudio.com/docs/remote/containers).
All needed tools for VScode are automatically installed in this case
1. Install VScode extension with ID ```ms-vscode-remote.remote-containers```
1. Hit `F1` and type `Remote-Containers: Reopen in Container`
``` bash
root@aeefe5ca40f5:/workspaces/incubation3/seat_service# ./build-release.sh
root@aeefe5ca40f5:/workspaces/incubation3/seat_service# target/x86_64/release/install/bin/seat_service
Usage: target/x86_64/release/install/bin/seat_service CAN_IF_NAME [LISTEN_ADDRESS [PORT]]
Environment: SEAT_DEBUG=1 to enable SeatDataFeeder dumps
```
## Configuration
### Command line arguments
Expand Down

0 comments on commit 24cdb1a

Please sign in to comment.