Skip to content

Commit

Permalink
add a new base layer without a toolchain
Browse files Browse the repository at this point in the history
Add a new base layer without toolchains to allow for downstream
customization and usage with non zephyr-sdk toolchains.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
  • Loading branch information
nashif authored and galak committed Dec 8, 2022
1 parent fd7660b commit a7da32b
Show file tree
Hide file tree
Showing 4 changed files with 207 additions and 124 deletions.
68 changes: 67 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,13 @@ jobs:
- name: Checkout
uses: actions/checkout@v3

- name: Generate local metadata for base image
id: meta_ci_base
uses: docker/metadata-action@v4
with:
images: |
localhost:5000/zephyrproject-rtos/ci-base
- name: Generate local metadata for CI image
id: meta_ci
uses: docker/metadata-action@v4
Expand All @@ -59,6 +66,21 @@ jobs:
images: |
localhost:5000/zephyrproject-rtos/zephyr-build
- name: Generate push metadata for base image
if: ${{ github.event_name != 'pull_request' }}
id: meta_ci_base_push
uses: docker/metadata-action@v4
with:
images: |
docker.io/zephyrprojectrtos/ci-base
ghcr.io/zephyrproject-rtos/ci-base
flavor: |
latest=false
suffix=-${{ matrix.variant.arch }}
tags: |
type=ref,event=branch
type=ref,event=tag
- name: Generate push metadata for CI image
if: ${{ github.event_name != 'pull_request' }}
id: meta_ci_push
Expand Down Expand Up @@ -94,15 +116,27 @@ jobs:
with:
driver-opts: network=host

- name: Build base docker image
uses: docker/build-push-action@v3
with:
context: .
file: Dockerfile.base
platforms: ${{ matrix.variant.platform }}
push: true
tags: ${{ steps.meta_ci_base.outputs.tags }}
labels: ${{ steps.meta_ci_base.outputs.labels }}

- name: Build CI docker image
uses: docker/build-push-action@v3
with:
context: .
file: Dockerfile
file: Dockerfile.ci
platforms: ${{ matrix.variant.platform }}
push: true
tags: ${{ steps.meta_ci.outputs.tags }}
labels: ${{ steps.meta_ci.outputs.labels }}
build-args: |
BASE_IMAGE=localhost:5000/zephyrproject-rtos/ci-base:${{ steps.meta_ci_base.outputs.version }}
- name: Build Developer docker image
uses: docker/build-push-action@v3
Expand Down Expand Up @@ -132,6 +166,13 @@ jobs:
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Push base docker image
if: ${{ github.event_name != 'pull_request' }}
uses: stephanosio/tag-push-action@v2.1.0
with:
src: localhost:5000/zephyrproject-rtos/ci-base:${{ steps.meta_ci_base.outputs.version }}
dst: ${{ steps.meta_ci_base_push.outputs.tags }}

- name: Push CI docker image
if: ${{ github.event_name != 'pull_request' }}
uses: stephanosio/tag-push-action@v2.1.0
Expand Down Expand Up @@ -167,6 +208,20 @@ jobs:
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Generate push metadata for base docker image
id: meta_ci_base_push
uses: docker/metadata-action@v4
with:
images: |
docker.io/zephyrprojectrtos/ci-base
ghcr.io/zephyrproject-rtos/ci-base
flavor: |
latest=false
tags: |
type=ref,event=branch
type=ref,event=tag
type=raw,value=latest,enable={{is_default_branch}}
- name: Generate push metadata for CI image
id: meta_ci_push
uses: docker/metadata-action@v4
Expand Down Expand Up @@ -198,27 +253,38 @@ jobs:
- name: Create multi-architecture image
run: |
archs=(amd64 arm64)
ci_base_image="ghcr.io/zephyrproject-rtos/ci-base:${{ steps.meta_ci_base_push.outputs.version }}"
ci_image="ghcr.io/zephyrproject-rtos/ci:${{ steps.meta_ci_push.outputs.version }}"
developer_image="ghcr.io/zephyrproject-rtos/zephyr-build:${{ steps.meta_developer_push.outputs.version }}"
# Pull architecture-specific images
for arch in ${archs[@]}; do
docker pull ${ci_base_image}-${arch}
docker pull ${ci_image}-${arch}
docker pull ${developer_image}-${arch}
done
# Create multi-architecture image
for arch in ${archs[@]}; do
ci_base_image_amend_flags+="--amend ${ci_base_image}-${arch} "
ci_image_amend_flags+="--amend ${ci_image}-${arch} "
developer_image_amend_flags+="--amend ${developer_image}-${arch} "
done
docker manifest create ${ci_base_image} ${ci_base_image_amend_flags}
docker manifest create ${ci_image} ${ci_image_amend_flags}
docker manifest create ${developer_image} ${developer_image_amend_flags}
docker manifest push ${ci_base_image}
docker manifest push ${ci_image}
docker manifest push ${developer_image}
- name: Push base docker image
uses: stephanosio/tag-push-action@v2.1.0
with:
src: ghcr.io/zephyrproject-rtos/ci-base:${{ steps.meta_ci_base_push.outputs.version }}
dst: ${{ steps.meta_ci_base_push.outputs.tags }}

- name: Push CI docker image
uses: stephanosio/tag-push-action@v2.1.0
with:
Expand Down
134 changes: 134 additions & 0 deletions Dockerfile.base
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
FROM ubuntu:20.04

ARG CMAKE_VERSION=3.20.5
ARG WGET_ARGS="-q --show-progress --progress=bar:force:noscroll --no-check-certificate"

ARG UID=1000
ARG GID=1000

# Set default shell during Docker image build to bash
SHELL ["/bin/bash", "-c"]

# Set non-interactive frontend for apt-get to skip any user confirmations
ENV DEBIAN_FRONTEND=noninteractive

# Install base packages
RUN apt-get -y update && \
apt-get -y upgrade && \
apt-get install --no-install-recommends -y \
software-properties-common \
lsb-release \
autoconf \
automake \
bison \
build-essential \
ca-certificates \
ccache \
chrpath \
cpio \
device-tree-compiler \
dfu-util \
diffstat \
dos2unix \
doxygen \
file \
flex \
g++ \
gawk \
gcc \
gcovr \
git \
git-core \
gnupg \
gperf \
gtk-sharp2 \
help2man \
iproute2 \
lcov \
libglib2.0-dev \
libgtk2.0-0 \
liblocale-gettext-perl \
libncurses5-dev \
libpcap-dev \
libpopt0 \
libsdl1.2-dev \
libsdl2-dev \
libssl-dev \
libtool \
libtool-bin \
locales \
make \
net-tools \
ninja-build \
openssh-client \
pkg-config \
python3-dev \
python3-pip \
python3-ply \
python3-setuptools \
python-is-python3 \
qemu \
rsync \
socat \
srecord \
sudo \
texinfo \
unzip \
valgrind \
wget \
ovmf \
xz-utils

# Install multi-lib gcc (x86 only)
RUN if [ "${HOSTTYPE}" = "x86_64" ]; then \
apt-get install --no-install-recommends -y \
gcc-multilib \
g++-multilib \
; fi

# Install i386 packages (x86 only)
RUN if [ "${HOSTTYPE}" = "x86_64" ]; then \
dpkg --add-architecture i386 && \
apt-get -y update && \
apt-get -y upgrade && \
apt-get install --no-install-recommends -y \
libsdl2-dev:i386 \
; fi

# Initialise system locale
RUN locale-gen en_US.UTF-8
ENV LANG=en_US.UTF-8
ENV LANGUAGE=en_US:en
ENV LC_ALL=en_US.UTF-8

# Install CMake
RUN wget ${WGET_ARGS} https://github.com/Kitware/CMake/releases/download/v${CMAKE_VERSION}/cmake-${CMAKE_VERSION}-Linux-${HOSTTYPE}.sh && \
chmod +x cmake-${CMAKE_VERSION}-Linux-${HOSTTYPE}.sh && \
./cmake-${CMAKE_VERSION}-Linux-${HOSTTYPE}.sh --skip-license --prefix=/usr/local && \
rm -f ./cmake-${CMAKE_VERSION}-Linux-${HOSTTYPE}.sh

# Install Python dependencies
RUN pip3 install wheel pip -U &&\
pip3 install -r https://raw.githubusercontent.com/zephyrproject-rtos/zephyr/master/scripts/requirements.txt && \
pip3 install -r https://raw.githubusercontent.com/zephyrproject-rtos/mcuboot/master/scripts/requirements.txt && \
pip3 install west &&\
pip3 install sh &&\
pip3 install awscli PyGithub junitparser pylint \
statistics numpy \
imgtool \
protobuf \
GitPython

# Clean up stale packages
RUN apt-get clean -y && \
apt-get autoremove --purge -y && \
rm -rf /var/lib/apt/lists/*

# Create 'user' account
RUN groupadd -g $GID -o user

RUN useradd -u $UID -m -g user -G plugdev user \
&& echo 'user ALL = NOPASSWD: ALL' > /etc/sudoers.d/user \
&& chmod 0440 /etc/sudoers.d/user

USER root
Loading

0 comments on commit a7da32b

Please sign in to comment.