Skip to content

Commit 264beb3

Browse files
authored
Merge pull request #1 from doosuu/improve-base-container
Improve base container
2 parents 8ef265d + 5d0ade4 commit 264beb3

File tree

7 files changed

+148
-26
lines changed

7 files changed

+148
-26
lines changed

.dockerignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
.conan_home
22
.devcontainer
3-
.git
43
.github
54
.vscode
65
**/build

.github/workflows/release.yml

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
# Copyright (c) 2023 Robert Bosch GmbH
2+
#
3+
# This program and the accompanying materials are made available under the
4+
# terms of the Apache License, Version 2.0 which is available at
5+
# https://www.apache.org/licenses/LICENSE-2.0.
6+
#
7+
# Unless required by applicable law or agreed to in writing, software
8+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
9+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
10+
# License for the specific language governing permissions and limitations
11+
# under the License.
12+
#
13+
# SPDX-License-Identifier: Apache-2.0
14+
15+
name: Release
16+
17+
on:
18+
push:
19+
tags:
20+
- 'v[0-9]+\.[0-9]+\.[0-9]+'
21+
22+
workflow_dispatch:
23+
24+
jobs:
25+
wait-for-images:
26+
runs-on: ubuntu-latest
27+
name: Wait for container images
28+
29+
steps:
30+
- name: Wait for build-base-images workflow to succeed
31+
uses: fountainhead/[email protected]
32+
with:
33+
checkName: Building image
34+
token: ${{ secrets.GITHUB_TOKEN }}
35+
timeoutSeconds: 5400
36+
intervalSeconds: 120
37+
38+
initialize-matrix:
39+
runs-on: ubuntu-latest
40+
name: Setting up build matrix
41+
needs: [wait-for-images]
42+
43+
steps:
44+
- name: Login to GitHub Container Registry
45+
uses: docker/login-action@v2
46+
with:
47+
registry: ghcr.io
48+
username: ${{ github.repository_owner }}
49+
password: ${{ secrets.GITHUB_TOKEN }}
50+
51+
- id: github-repository-name-case-adjusted
52+
name: Prepare repository name in lower case for docker upload.
53+
uses: ASzc/change-string-case-action@v5
54+
with:
55+
string: ${{ github.repository }}
56+
57+
- uses: docker/setup-buildx-action@v2
58+
id: buildx
59+
with:
60+
install: true
61+
62+
- name: Get version from tag
63+
id: getVersions
64+
run: |
65+
semantic_version=$(sed -e "s/^v//" <<< ${{ github.ref_name }})
66+
major_version=$(cut -d '.' -f 1 <<< "$semantic_version")
67+
major_minor_version=$(cut -d '.' -f 1,2 <<< "$semantic_version")
68+
echo "semantic_version=v$semantic_version" >> $GITHUB_OUTPUT
69+
echo "major_version=v$major_version" >> $GITHUB_OUTPUT
70+
echo "major_minor_version=v$major_minor_version" >> $GITHUB_OUTPUT
71+
72+
- name: Tag docker images
73+
run: |
74+
FQ_IMAGE_NAME=ghcr.io/${{ steps.github-repository-name-case-adjusted.outputs.lowercase }}/app-builder
75+
OLD_TAG=${{ github.sha }}
76+
V_XXX=${{ steps.getVersions.outputs.semantic_version }}
77+
V_X=${{ steps.getVersions.outputs.major_version }}
78+
V_XX=${{ steps.getVersions.outputs.major_minor_version }}
79+
80+
if [[ $V_XX != "v0.0" ]] ; then
81+
docker buildx imagetools create -t $FQ_IMAGE_NAME:$V_XX $FQ_IMAGE_NAME:$OLD_TAG
82+
if [[ $V_X != "v0" ]] ; then
83+
docker buildx imagetools create -t $FQ_IMAGE_NAME:$V_X $FQ_IMAGE_NAME:$OLD_TAG
84+
fi
85+
fi
86+
87+
docker buildx imagetools create -t $FQ_IMAGE_NAME:$V_XXX $FQ_IMAGE_NAME:$OLD_TAG

.github/workflows/sdk-build-container.yml

Lines changed: 37 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (c) 2022 Robert Bosch GmbH
1+
# Copyright (c) 2022-2023 Robert Bosch GmbH
22
#
33
# This program and the accompanying materials are made available under the
44
# terms of the Apache License, Version 2.0 which is available at
@@ -12,25 +12,24 @@
1212
#
1313
# SPDX-License-Identifier: Apache-2.0
1414

15-
name: SDK - Build Base Container
15+
name: SDK - App Builder
1616
concurrency:
17-
group: sdk-build-container-${{ github.ref }}
17+
group: sdk-app-builder-${{ github.ref }}
1818
cancel-in-progress: true
1919

2020
on:
2121
workflow_dispatch:
2222
push:
2323
branches:
24-
- "main"
25-
release:
26-
types: [published, edited]
24+
- main
25+
pull_request:
26+
branches:
27+
- main
2728

2829
jobs:
2930
build-container:
31+
name: Building image
3032
runs-on: ubuntu-latest
31-
#strategy:
32-
# matrix:
33-
# platform: [amd64, aarch64]
3433

3534
steps:
3635
- name: Checkout repository
@@ -49,26 +48,48 @@ jobs:
4948
username: ${{ github.repository_owner }}
5049
password: ${{ secrets.GITHUB_TOKEN }}
5150

51+
- id: github-repository-name-case-adjusted
52+
name: Prepare repository name in lower case for docker upload.
53+
uses: ASzc/change-string-case-action@v5
54+
with:
55+
string: ${{ github.repository }}
56+
5257
- name: Extract metadata (tags, labels) for Docker
5358
id: meta
5459
uses: docker/metadata-action@v4
5560
with:
5661
images: |
5762
ghcr.io/${{ github.repository }}
5863
59-
- name: Generate version.txt
64+
- name: Get image tag
65+
id: get-tag
66+
shell: bash
67+
run: |
68+
BASE=${{ steps.github-repository-name-case-adjusted.outputs.lowercase }}/app-builder
69+
TAGS=$BASE:${{ github.sha }}
70+
if [[ "${{ github.ref }}" == "refs/heads/main" ]]; then
71+
TAGS="${TAGS},$BASE:latest"
72+
fi
73+
echo "tags=${TAGS}" >> $GITHUB_OUTPUT
74+
75+
- name: Set container output type
76+
id: container_output
77+
shell: bash
6078
run: |
61-
pip install conan==1.60.2
62-
conan export .
63-
cat ./version.txt
79+
if [ ${{ github.event }} = "push" ]; then
80+
echo "type=registry" >> $GITHUB_OUTPUT
81+
else
82+
echo "type=oci,dest=./container.tar" >> $GITHUB_OUTPUT
83+
fi
6484
65-
- name: "Build image"
85+
- name: Build image
6686
id: image_build
6787
uses: docker/[email protected]
6888
with:
69-
push: true
89+
tags: ${{ steps.get-tag.outputs.tags }}
7090
file: sdk/Dockerfile
7191
platforms: linux/amd64
72-
tags: ${{ steps.meta.outputs.tags }}
7392
labels: ${{ steps.meta.outputs.labels }}
93+
outputs: |
94+
type=${{ steps.container_output.outputs.type }}
7495
context: .

NOTICE-3RD-PARTY-CONTENT.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@
1212
|cpplint|1.6.1|New BSD|
1313
|distlib|0.3.7|Python Software Foundation License|
1414
|distro|1.8.0|Apache 2.0|
15-
|fasteners|0.18|Apache 2.0|
15+
|fasteners|0.19|Apache 2.0|
1616
|filelock|3.12.4|The Unlicense (Unlicense)|
1717
|gcovr|5.2|BSD|
18-
|identify|2.5.28|MIT|
18+
|identify|2.5.29|MIT|
1919
|idna|3.4|BSD|
2020
|Jinja2|3.1.2|New BSD|
2121
|lxml|4.9.3|New BSD|

build.sh

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ Arguments:
2828
-d, --debug Builds the target(s) in debug mode.
2929
-r, --release Builds the target(s) in release mode.
3030
-t <name>, --target <name> Builds only the target <name> instead of all targets.
31-
-no-examples Disables the build of the SDK examples.
31+
-no-examples Disables the build of the SDK examples.
32+
-no-tests Disables the build of the SDK tests.
3233
-s, --static Links all dependencies statically.
3334
-x, --cross <arch> Cross compiles for the specified architecture.
3435
-h, --help Shows this help.
@@ -41,6 +42,7 @@ HOST_ARCH=${BUILD_ARCH}
4142
BUILD_TARGET=all
4243
STATIC_BUILD=OFF
4344
SDK_BUILD_EXAMPLES=ON
45+
SDK_BUILD_TESTS=ON
4446

4547
POSITIONAL_ARGS=()
4648

@@ -67,6 +69,10 @@ while [[ $# -gt 0 ]]; do
6769
SDK_BUILD_EXAMPLES=OFF
6870
shift
6971
;;
72+
--no-tests)
73+
SDK_BUILD_TESTS=OFF
74+
shift
75+
;;
7076
-x|--cross)
7177
HOST_ARCH="$2"
7278
shift

conanfile.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@ class VehicleAppCppSdkConan(ConanFile):
3838
("openssl/1.1.1u@#de76bbea24d8b46f8def8daa18b31fd9"),
3939
("paho-mqtt-c/1.3.9@#0421671a9f4e8ccfa5fc678cfb160394"),
4040
("paho-mqtt-cpp/1.2.0@#cb70f45760e60655faa35251a394b1d2"),
41-
("protobuf/3.21.9@#515ceb0a1653cf84363d9968b812d6be")
41+
("protobuf/3.21.9@#515ceb0a1653cf84363d9968b812d6be"),
42+
("zlib/1.3")
4243
]
4344
generators = "cmake"
4445
author = "Robert Bosch GmbH"
@@ -93,7 +94,7 @@ def build(self):
9394
"build_type", default="Release").lower()
9495
option = "-r" if build_type == "release" else "-d"
9596
subprocess.call(
96-
f"cd ../.. && ./install_dependencies.sh && ./build.sh {option} --no-examples", shell=True)
97+
f"cd ../.. && ./install_dependencies.sh && ./build.sh {option} --no-examples --no-tests", shell=True)
9798

9899
def package(self):
99100
subprocess.call("pwd", shell=True)

sdk/Dockerfile

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
# syntax = docker/dockerfile:1.3
1616

17-
FROM alpine:3.16.0
17+
FROM alpine:3.18.3
1818

1919
RUN apk update && \
2020
apk add ninja && \
@@ -26,12 +26,20 @@ RUN apk update && \
2626
apk add linux-headers && \
2727
apk add perl && \
2828
apk add bash && \
29+
apk add git && \
30+
apk add nodejs && \
31+
apk add npm && \
2932
pip3 install "conan==1.60.2"
3033

3134
COPY . /sdk
3235

3336
RUN --mount=type=cache,target=/root/.conan
3437

35-
RUN cd /sdk && \
36-
./install_dependencies.sh -r --build-all-deps && \
37-
cd / && rm -rf /sdk
38+
#RUN cd /sdk && \
39+
# ./install_dependencies.sh -r --build-all-deps && \
40+
# cd / && rm -rf /sdk
41+
42+
# install CLI
43+
#RUN git clone https://github.com/eclipse-velocitas/cli.git && \
44+
# cd cli && \
45+
# npm i && npm run build && npx oclif manifest && npm i -g .

0 commit comments

Comments
 (0)