Skip to content

Commit

Permalink
Add cpp base image (#8)
Browse files Browse the repository at this point in the history
  • Loading branch information
doosuu authored Dec 21, 2022
1 parent 1dd721a commit 8ab1ec2
Show file tree
Hide file tree
Showing 8 changed files with 123 additions and 10 deletions.
11 changes: 9 additions & 2 deletions .github/workflows/build-base-images.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ concurrency:
cancel-in-progress: true

on:
schedule:
- cron: '0 5 * * 0'
workflow_dispatch:
push:
# Run only on branches/commits and not tags
Expand All @@ -29,6 +31,10 @@ on:

jobs:
build-image:
strategy:
matrix:
language: [Python, Cpp]

name: "Building image"
runs-on: ubuntu-latest

Expand All @@ -54,7 +60,7 @@ jobs:
uses: docker/metadata-action@v4
with:
images: |
ghcr.io/${{ github.repository }}/Python
ghcr.io/${{ github.repository }}/${{ matrix.language }}
tags: |
type=sha
type=ref,event=tag
Expand All @@ -67,7 +73,8 @@ jobs:
uses: docker/build-push-action@v3
with:
push: true
context: "./Dockerfiles/Python/"
context: "."
file: ./Dockerfiles/${{ matrix.language }}/Dockerfile
platforms: linux/amd64, linux/arm64
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
109 changes: 109 additions & 0 deletions Dockerfiles/Cpp/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
# Copyright (c) 2022 Robert Bosch GmbH
#
# This program and the accompanying materials are made available under the
# terms of the Apache License, Version 2.0 which is available at
# https://www.apache.org/licenses/LICENSE-2.0.
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
#
# SPDX-License-Identifier: Apache-2.0

##############################################################################
# Builder step (cross compile from BUILD to HOST, if needed)
##############################################################################

FROM --platform=$BUILDPLATFORM ubuntu:22.04 as builder

RUN apt-get update && apt-get upgrade -y && \
apt-get install -y apt-utils openssh-client gnupg2 dirmngr iproute2 \
procps lsof htop net-tools psmisc manpages manpages-dev \
curl wget ca-certificates unzip init-system-helpers \
bzip2 zip git zsh pigz \
apt-transport-https dialog libkrb5-3 \
libgssapi-krb5-2 libicu[0-9][0-9] liblttng-ust[0-9] \
locales sudo ncdu cmake \
build-essential build-essential \
gcc-aarch64-linux-gnu g++-aarch64-linux-gnu binutils-aarch64-linux-gnu \
gcc-x86-64-linux-gnu g++-x86-64-linux-gnu binutils-x86-64-linux-gnu && \
apt-get autoremove -y && apt-get clean -y && rm -rf /var/lib/apt/lists/*


ADD https://raw.githubusercontent.com/devcontainers/features/7fa90110d762797cc0b1c2fe8fcc028c9b813d56/src/common-utils/install.sh /container/scripts/install-common.sh
RUN UID="4000" bash /container/scripts/install-common.sh

ADD --chown=4000 https://raw.githubusercontent.com/eclipse-velocitas/vehicle-app-cpp-sdk/main/conanfile.py /container/cpp/

# Get all profiles from the SDK
ADD --chown=4000 https://raw.githubusercontent.com/eclipse-velocitas/vehicle-app-cpp-sdk/main/.conan/profiles/linux_aarch64_release /container/cpp/.conan/profiles/
ADD --chown=4000 https://raw.githubusercontent.com/eclipse-velocitas/vehicle-app-cpp-sdk/main/.conan/profiles/linux_x86_64_release /container/cpp/.conan/profiles/
ADD --chown=4000 https://raw.githubusercontent.com/eclipse-velocitas/vehicle-app-cpp-sdk/main/.scripts/common.sh /container/cpp/.scripts/
ADD --chown=4000 https://raw.githubusercontent.com/eclipse-velocitas/vehicle-app-cpp-sdk/main/install_dependencies.sh /container/cpp/
ADD --chown=4000 https://raw.githubusercontent.com/eclipse-velocitas/vehicle-app-cpp-sdk/main/requirements.txt /container/cpp/

COPY ./common/ /scripts/

# Install conan
WORKDIR /scripts
RUN ./install-python.sh && pip3 install -r /container/cpp/requirements.txt

# Build dependencies for target architecture
WORKDIR /container/cpp
USER 4000
WORKDIR /container/cpp/build
WORKDIR /container/cpp
ARG TARGETARCH
RUN bash ./install_dependencies.sh -x $TARGETARCH

# Remove build files for final image
RUN conan remove --builds --src --force '*'


##############################################################################
# Final step (run on TARGET, QEMU if needed)
##############################################################################

FROM --platform=$TARGETPLATFORM ubuntu:22.04 as final

RUN apt-get --fix-missing update && apt-get upgrade -y && \
apt-get install -y apt-utils openssh-client gnupg2 dirmngr iproute2 \
procps lsof htop net-tools psmisc manpages manpages-dev \
curl tree wget ca-certificates unzip init-system-helpers \
bzip2 zip nano vim-tiny less jq lsb-release git zsh pigz \
apt-transport-https dialog libgcc1 libkrb5-3 iptables \
libgssapi-krb5-2 libicu[0-9][0-9] liblttng-ust[0-9] \
libstdc++6 zlib1g locales sudo ncdu man-db strace gnupg2 \
# install cpp packages
build-essential cmake clang lldb llvm gdb ninja-build cppcheck clang-format-14 clang-tidy-14 && \
# clean-up
apt-get autoremove -y && apt-get clean -y && rm -rf /var/lib/apt/lists/* && \
# redirect format and tidy to the versioned variants
update-alternatives --install /usr/bin/clang-format clang-format /usr/bin/clang-format-14 100 && \
update-alternatives --install /usr/bin/clang-tidy clang-tidy /usr/bin/clang-tidy-14 100

ADD https://raw.githubusercontent.com/devcontainers/features/7fa90110d762797cc0b1c2fe8fcc028c9b813d56/src/common-utils/install.sh /container/scripts/install-common.sh
RUN UID="4000" bash /container/scripts/install-common.sh
ADD https://raw.githubusercontent.com/devcontainers/features/7fa90110d762797cc0b1c2fe8fcc028c9b813d56/src/docker-in-docker/install.sh /container/scripts/install-dind.sh
RUN VERSION="latest" bash /container/scripts/install-dind.sh

COPY ./common/ /scripts/

WORKDIR /scripts
RUN ./install-python.sh && \
./install-dapr-cli.sh && \
./install-k3d-prerequisites.sh \
./install-k3d-tooling.sh

USER 4000
ADD --chown=4000 https://raw.githubusercontent.com/eclipse-velocitas/vehicle-app-cpp-sdk/main/requirements.txt /container/requirements.txt
# Install Python requirements as vscode user and clean up
RUN pip3 install -r /container/requirements.txt && sudo rm /container/requirements.txt

# We need to set the USER back to root at the end, otherwise we get errors when using this in our repo.
USER root

# Obtain pre-build dependencies
COPY --from=builder /home/vscode/.conan /home/vscode/.conan
13 changes: 5 additions & 8 deletions Dockerfiles/Python/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,8 @@

FROM ubuntu:22.04

RUN apt-get update && apt-get upgrade -y

# install devcontainer feature prerequisites
RUN apt-get install -y apt-utils openssh-client gnupg2 dirmngr iproute2 \
RUN apt-get update && apt-get upgrade -y && \
apt-get install -y apt-utils openssh-client gnupg2 dirmngr iproute2 \
procps lsof htop net-tools psmisc manpages manpages-dev \
curl tree wget rsync ca-certificates unzip init-system-helpers \
bzip2 zip nano vim-tiny less jq lsb-release git zsh pigz \
Expand All @@ -26,12 +24,11 @@ RUN apt-get install -y apt-utils openssh-client gnupg2 dirmngr iproute2 \
libstdc++6 zlib1g locales sudo ncdu man-db strace gnupg2 \
build-essential python3-dev

ADD https://raw.githubusercontent.com/devcontainers/features/main/src/common-utils/install.sh /tmp/scripts/install-common.sh
ADD https://raw.githubusercontent.com/devcontainers/features/7fa90110d762797cc0b1c2fe8fcc028c9b813d56/src/common-utils/install.sh /tmp/scripts/install-common.sh
RUN UID="4000" bash /tmp/scripts/install-common.sh
ADD https://raw.githubusercontent.com/devcontainers/features/main/src/docker-in-docker/install.sh /tmp/scripts/install-dind.sh
ADD https://raw.githubusercontent.com/devcontainers/features/7fa90110d762797cc0b1c2fe8fcc028c9b813d56/src/docker-in-docker/install.sh /tmp/scripts/install-dind.sh
RUN VERSION="latest" bash /tmp/scripts/install-dind.sh

COPY ./scripts/ /scripts/
COPY ./common/ /scripts/

WORKDIR /scripts
RUN ./install-python.sh
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit 8ab1ec2

Please sign in to comment.