Skip to content

Commit dc402c4

Browse files
Add first Version of Docker Image as take-over from openbsw
1 parent 741f870 commit dc402c4

7 files changed

Lines changed: 197 additions & 2 deletions

File tree

.github/workflows/check.yaml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
name: check
2+
on:
3+
pull_request:
4+
types:
5+
- opened
6+
- synchronize
7+
jobs:
8+
docker-build-check-development:
9+
name: docker-build-check-development
10+
runs-on: ubuntu-24.04
11+
permissions:
12+
contents: read
13+
steps:
14+
- name: build and push image
15+
uses: docker/build-push-action@v6
16+
with:
17+
push: false
18+
tags: ghcr.io/${{ github.repository }}/development:${{ github.ref_name }}

.github/workflows/release.yaml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: release
2+
on:
3+
push:
4+
branches:
5+
- "main"
6+
tags:
7+
- "v[0-9]+.[0-9]+.[0-9]+"
8+
jobs:
9+
docker-build-release-development:
10+
name: docker-build-release-development
11+
runs-on: ubuntu-24.04
12+
permissions:
13+
contents: read
14+
id-token: write
15+
steps:
16+
- name: login to container registry
17+
uses: docker/login-action@v3
18+
with:
19+
registry: ghcr.io
20+
username: ${{ github.actor }}
21+
password: ${{ secrets.GITHUB_TOKEN }}
22+
- name: build and push image
23+
uses: docker/build-push-action@v6
24+
with:
25+
push: true
26+
tags: ghcr.io/${{ github.repository }}/development:${{ github.ref_name }}

Dockerfile

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
FROM ubuntu:22.04
2+
3+
RUN for i in 1 2 3; do \
4+
apt-get update && apt-get install -y \
5+
bzip2 \
6+
clang-tidy \
7+
curl \
8+
g++-11 \
9+
gcc-11 \
10+
git \
11+
iputils-ping \
12+
lcov \
13+
ninja-build \
14+
python3-pip \
15+
python3.10 \
16+
ruby-rubygems \
17+
tar \
18+
tmux \
19+
wget \
20+
zip \
21+
&& rm -rf /var/lib/apt/lists/* \
22+
&& break || { echo "Apt install failed, retrying ($i/3)..."; sleep 10; }; \
23+
done
24+
25+
RUN wget https://github.com/Kitware/CMake/releases/download/v3.28.3/cmake-3.28.3-linux-x86_64.sh \
26+
&& chmod +x cmake-3.28.3-linux-x86_64.sh \
27+
&& ./cmake-3.28.3-linux-x86_64.sh --skip-license --prefix=/usr/local \
28+
&& rm cmake-3.28.3-linux-x86_64.sh
29+
30+
RUN wget https://developer.arm.com/-/media/Files/downloads/gnu/14.3.rel1/binrel/arm-gnu-toolchain-14.3.rel1-x86_64-arm-none-eabi.tar.xz \
31+
&& tar xf arm-gnu-toolchain-14.3.rel1-x86_64-arm-none-eabi.tar.xz \
32+
&& mv arm-gnu-toolchain-14.3.rel1-x86_64-arm-none-eabi /usr/bin/gcc-arm-none-eabi \
33+
&& rm arm-gnu-toolchain-14.3.rel1-x86_64-arm-none-eabi.tar.xz
34+
ENV PATH="/usr/bin/gcc-arm-none-eabi/bin:${PATH}"
35+
36+
RUN wget https://github.com/llvm/llvm-project/releases/download/llvmorg-17.0.2/clang+llvm-17.0.2-x86_64-linux-gnu-ubuntu-22.04.tar.xz \
37+
&& tar -xf clang+llvm-17.0.2-x86_64-linux-gnu-ubuntu-22.04.tar.xz \
38+
&& mv clang+llvm-17.0.2-x86_64-linux-gnu-ubuntu-22.04 /usr/bin/llvm \
39+
&& rm clang+llvm-17.0.2-x86_64-linux-gnu-ubuntu-22.04.tar.xz
40+
ENV PATH="/usr/bin/llvm/bin:${PATH}"
41+
42+
RUN wget https://github.com/ARM-software/LLVM-embedded-toolchain-for-Arm/releases/download/release-19.1.1/LLVM-ET-Arm-19.1.1-Linux-x86_64.tar.xz \
43+
&& tar -xf LLVM-ET-Arm-19.1.1-Linux-x86_64.tar.xz \
44+
&& mv LLVM-ET-Arm-19.1.1-Linux-x86_64 /usr/bin/llvm-arm \
45+
&& rm LLVM-ET-Arm-19.1.1-Linux-x86_64.tar.xz
46+
ENV PATH="/usr/bin/llvm-arm/bin:${PATH}"
47+
48+
RUN curl -L https://github.com/numtide/treefmt/releases/download/v2.1.0/treefmt_2.1.0_linux_amd64.tar.gz -o treefmt.tar.gz \
49+
&& tar -xvzf treefmt.tar.gz \
50+
&& install -m 755 treefmt /usr/bin/treefmt \
51+
&& rm LICENSE README.md treefmt treefmt.tar.gz
52+
53+
RUN curl -L https://github.com/muttleyxd/clang-tools-static-binaries/releases/download/master-32d3ac78/clang-format-17_linux-amd64 -o /usr/bin/clang-format-17 \
54+
&& chmod +x /usr/bin/clang-format-17
55+
56+
RUN wget https://github.com/mozilla/sccache/releases/download/v0.10.0/sccache-v0.10.0-x86_64-unknown-linux-musl.tar.gz \
57+
&& tar -xzf sccache-v0.10.0-x86_64-unknown-linux-musl.tar.gz \
58+
&& mv sccache-v0.10.0-x86_64-unknown-linux-musl/sccache /usr/local/bin/sccache \
59+
&& chmod a+x /usr/local/bin/sccache \
60+
&& rm sccache-v0.10.0-x86_64-unknown-linux-musl.tar.gz \
61+
&& rm -rf sccache-v0.10.0-x86_64-unknown-linux-musl
62+
63+
RUN gem install esr-rim
64+
65+
RUN pip3 install cmakelang pytest rich pyelftools
66+
67+
RUN useradd build
68+
RUN install -d /home/build --mode 0777 --owner build --group build
69+
COPY --chown=build:build --chmod=0666 files/.bashrc /home/build/.bashrc
70+
COPY --chown=build:build --chmod=0666 files/.bash_profile /home/build/.bash_profile
71+
72+
USER build

README.md

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,35 @@
1-
# docker
2-
Official Docker Image to develop for OpenBSW
1+
# Eclipse OpenBSW - Docker
2+
3+
This repository contains the official docker images used in the Eclipse OpenBSW project. The images
4+
are build automatically and pushed to the GitHub Container Registry for each release. Both the
5+
developer as well as the CI in the OpenBSW project then utilize the pre-build docker images to
6+
ensure a defined environment and reproducibility of CI builds.
7+
8+
## Building the Image locally
9+
10+
In case you want to build the docker image locally e.g. when modifying the `Dockerfile` you can use
11+
the provided docker-compose file and call `docker compose build <service>`. This will build the
12+
image locally and tag it as `<service>:test`.
13+
14+
## Remarks
15+
16+
### User ID handling
17+
18+
A typical issue we encountered in the past when using pre-build docker images is that the `UID` of
19+
the user inside of the image does not match to the user on the host machine. To avoid the need to
20+
re-build the image locally with a matching `UID` we utilize a different approach. When the user
21+
wants to start a container we overwrite the `UID` of the user in the container by mounting a custom
22+
`/etc/passwd` file. To make this easy to use, we typically provide a docker-compose file with this
23+
as shown below.
24+
25+
```yaml
26+
configs:
27+
passwd:
28+
content: |
29+
build::${DOCKER_UID:-1000}:${DOCKER_GID:-1000}::/home/build:/usr/bin/bash
30+
group:
31+
content: |
32+
build::${DOCKER_GID:-1000}:
33+
shadow:
34+
content: "#empty"
35+
```

docker-compose.yaml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
services:
2+
development:
3+
image: development:test
4+
build:
5+
context: .
6+
network: host
7+
args:
8+
http_proxy: ${http_proxy}
9+
https_proxy: ${https_proxy}
10+
no_proxy: ${no_proxy}
11+
user: build
12+
stdin_open: true
13+
tty: true
14+
network_mode: host
15+
working_dir: ${PWD}
16+
configs:
17+
- source: passwd
18+
target: /etc/passwd
19+
- source: group
20+
target: /etc/group
21+
- source: shadow
22+
target: /etc/shadow
23+
volumes:
24+
- type: bind
25+
source: ${PWD}
26+
target: ${PWD}
27+
bind:
28+
create_host_path: false
29+
- type: bind
30+
source: ${DOCKER_HISTORY:-${HOME}/.docker_history}
31+
target: /home/build/.bash_history
32+
bind:
33+
create_host_path: false
34+
35+
configs:
36+
passwd:
37+
content: |
38+
build::${DOCKER_UID:-1000}:${DOCKER_GID:-1000}::/home/build:/usr/bin/bash
39+
group:
40+
content: |
41+
build::${DOCKER_GID:-1000}:
42+
shadow:
43+
content: "#empty"

files/.bash_profile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
[[ -f ~/.bashrc ]] && . ~/.bashrc

files/.bashrc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[[ $- != *i* ]] && return
2+
export PS1="openbsw> $PS1"

0 commit comments

Comments
 (0)