Skip to content

Commit

Permalink
unify docker images
Browse files Browse the repository at this point in the history
This unify docker images and moves all docker images to one repository.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
  • Loading branch information
nashif committed Apr 21, 2021
1 parent c224751 commit 39e4402
Show file tree
Hide file tree
Showing 9 changed files with 124 additions and 127 deletions.
18 changes: 11 additions & 7 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,28 @@

name: Docker Image CI

on:
pull_request:
paths:
- 'Dockerfile'
- 'entrypoint.sh'
on: [pull_request]

env:
DOCKER_USER: zephyrprojectrtos
DOCKER_REPO: zephyr-build
DOCKER_REPO: ci
DOCKER_REPO2: zephyr-build

jobs:

build:
name: "Build Docker image"
runs-on: ubuntu-latest
if: github.repository == 'zephyrproject-rtos/docker-image'
steps:
- uses: actions/checkout@v2

- name: Build the Docker image
run: |
df -h
# remove a few things to free up space
sudo rm -rf "/usr/local/share/boost"
sudo rm -rf "/usr/local/lib/android"
sudo rm -rf "$AGENT_TOOLSDIRECTORY"
df -h
docker build . --file Dockerfile --tag docker.io/${DOCKER_USER}/${DOCKER_REPO}:${{ github.sha }}
docker build . --build-arg FROM_TAG=${{ github.sha }} --file Dockerfile.user --tag docker.io/${DOCKER_USER}/${DOCKER_REPO2}:latest
51 changes: 0 additions & 51 deletions .github/workflows/issue_count.yml

This file was deleted.

17 changes: 0 additions & 17 deletions .github/workflows/issues-report-config.json

This file was deleted.

22 changes: 12 additions & 10 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,17 @@

name: Docker Publish

on:
push:
paths:
- 'Dockerfile'
- 'entrypoint.sh'
tags:
- 'v*'
on: [push]

env:
DOCKER_USER: zephyrprojectrtos
DOCKER_REPO: zephyr-build
DOCKER_REPO: ci
DOCKER_REPO2: zephyr-build

jobs:
build:
runs-on: ubuntu-latest

if: github.repository == 'zephyrproject-rtos/docker-image'
steps:
- name: Docker Tag
id: docker_tag
Expand All @@ -47,11 +42,18 @@ jobs:
env:
DOCKER_TAG: ${{ steps.docker_tag.outputs.DOCKER_TAG }}
run: |
df -h
# remove a few things to free up space
sudo rm -rf "/usr/local/share/boost"
sudo rm -rf "/usr/local/lib/android"
sudo rm -rf "$AGENT_TOOLSDIRECTORY"
df -h
docker build . --file Dockerfile --tag docker.io/${DOCKER_USER}/${DOCKER_REPO}:${DOCKER_TAG}
docker build . --file Dockerfile.user --build-arg FROM_TAG=${DOCKER_TAG} --tag docker.io/${DOCKER_USER}/${DOCKER_REPO2}:${DOCKER_TAG}
- name: push
env:
DOCKER_TAG: ${{ steps.docker_tag.outputs.DOCKER_TAG }}
run: |
pwd
docker push docker.io/${DOCKER_USER}/${DOCKER_REPO}:${DOCKER_TAG}
docker push docker.io/${DOCKER_USER}/${DOCKER_REPO2}:${DOCKER_TAG}
81 changes: 44 additions & 37 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ ARG ZSDK_VERSION=0.12.4
ARG GCC_ARM_NAME=gcc-arm-none-eabi-10-2020-q4-major
ARG CMAKE_VERSION=3.18.3
ARG RENODE_VERSION=1.12.0
ARG LLVM_VERSION=12
ARG BSIM_VERSION=v1.0.3
ARG WGET_ARGS="-q --show-progress --progress=bar:force:noscroll --no-check-certificate"

ARG UID=1000
ARG GID=1000
Expand All @@ -14,20 +17,14 @@ RUN dpkg --add-architecture i386 && \
apt-get -y update && \
apt-get -y upgrade && \
apt-get install --no-install-recommends -y \
wget

RUN wget -q --show-progress --progress=bar:force:noscroll --no-check-certificate https://github.com/renode/renode/releases/download/v${RENODE_VERSION}/renode_${RENODE_VERSION}_amd64.deb && \
wget -q --show-progress --progress=bar:force:noscroll --no-check-certificate https://github.com/zephyrproject-rtos/sdk-ng/releases/download/v${ZSDK_VERSION}/zephyr-sdk-${ZSDK_VERSION}-x86_64-linux-setup.run && \
wget -q --show-progress --progress=bar:force:noscroll --no-check-certificate https://developer.arm.com/-/media/Files/downloads/gnu-rm/10-2020q4/${GCC_ARM_NAME}-x86_64-linux.tar.bz2 && \
wget -q --show-progress --progress=bar:force:noscroll --no-check-certificate https://github.com/Kitware/CMake/releases/download/v${CMAKE_VERSION}/cmake-${CMAKE_VERSION}-Linux-x86_64.sh

RUN apt-get install --no-install-recommends -y \
gnupg \
ca-certificates && \
apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF && \
echo "deb https://download.mono-project.com/repo/ubuntu stable-bionic main" | tee /etc/apt/sources.list.d/mono-official-stable.list && \
apt-get -y update && \
apt-get install --no-install-recommends -y \
software-properties-common \
lsb-release \
autoconf \
automake \
build-essential \
Expand All @@ -52,28 +49,30 @@ RUN apt-get install --no-install-recommends -y \
libgtk2.0-0 \
libpcap-dev \
libsdl2-dev:i386 \
libsdl1.2-dev \
libsdl2-dev \
libtool \
locales \
make \
mono-complete \
net-tools \
ninja-build \
openbox \
pkg-config \
protobuf-compiler \
python3-dev \
python3-pip \
python3-ply \
python3-setuptools \
python-xdg \
qemu \
socat \
srecord \
sudo \
texinfo \
valgrind \
x11vnc \
xterm \
xvfb \
wget \
xz-utils && \
apt remove libclang1-10 -y && \
apt autoremove -y && \
wget ${WGET_ARGS} https://github.com/renode/renode/releases/download/v${RENODE_VERSION}/renode_${RENODE_VERSION}_amd64.deb && \
apt install -y ./renode_${RENODE_VERSION}_amd64.deb && \
rm renode_${RENODE_VERSION}_amd64.deb && \
rm -rf /var/lib/apt/lists/*
Expand All @@ -87,20 +86,47 @@ 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 sh &&\
pip3 install awscli PyGithub junitparser pylint \
statistics numpy \
imgtool \
protobuf


RUN mkdir -p /opt/toolchains

RUN sh "zephyr-sdk-${ZSDK_VERSION}-x86_64-linux-setup.run" --quiet -- -d /opt/toolchains/zephyr-sdk-${ZSDK_VERSION} && \
RUN wget ${WGET_ARGS} https://github.com/zephyrproject-rtos/sdk-ng/releases/download/v${ZSDK_VERSION}/zephyr-sdk-${ZSDK_VERSION}-x86_64-linux-setup.run && \
sh "zephyr-sdk-${ZSDK_VERSION}-x86_64-linux-setup.run" --quiet -- -d /opt/toolchains/zephyr-sdk-${ZSDK_VERSION} && \
rm "zephyr-sdk-${ZSDK_VERSION}-x86_64-linux-setup.run"

RUN tar -xf ${GCC_ARM_NAME}-x86_64-linux.tar.bz2 -C /opt/toolchains/ && \
RUN wget ${WGET_ARGS} https://developer.arm.com/-/media/Files/downloads/gnu-rm/10-2020q4/${GCC_ARM_NAME}-x86_64-linux.tar.bz2 && \
tar -xf ${GCC_ARM_NAME}-x86_64-linux.tar.bz2 -C /opt/toolchains/ && \
rm -f ${GCC_ARM_NAME}-x86_64-linux.tar.bz2

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

RUN wget ${WGET_ARGS} https://apt.llvm.org/llvm.sh && \
chmod +x llvm.sh && \
./llvm.sh ${LLVM_VERSION} && \
rm llvm.sh

RUN mkdir -p /opt/bsim
RUN cd /opt/bsim && \
rm -f repo && \
wget ${WGET_ARGS} https://storage.googleapis.com/git-repo-downloads/repo && \
chmod a+x ./repo && \
python3 ./repo init -u https://github.com/BabbleSim/manifest.git -m zephyr_docker.xml -b ${BSIM_VERSION} --depth 1 &&\
python3 ./repo sync && \
make everything -j 8 && \
echo ${BSIM_VERSION} > ./version && \
chmod ag+w . -R

RUN apt-get clean && \
sudo apt-get autoremove --purge

RUN groupadd -g $GID -o user

RUN useradd -u $UID -m -g user -G plugdev user \
Expand All @@ -110,24 +136,5 @@ RUN useradd -u $UID -m -g user -G plugdev user \
# Set the locale
ENV ZEPHYR_TOOLCHAIN_VARIANT=zephyr
ENV ZEPHYR_SDK_INSTALL_DIR=/opt/toolchains/zephyr-sdk-${ZSDK_VERSION}
ENV ZEPHYR_BASE=/workdir
ENV GNUARMEMB_TOOLCHAIN_PATH=/opt/toolchains/${GCC_ARM_NAME}
ENV PKG_CONFIG_PATH=/usr/lib/i386-linux-gnu/pkgconfig
ENV DISPLAY=:0

RUN chown -R user:user /home/user

ADD ./entrypoint.sh /home/user/entrypoint.sh
RUN dos2unix /home/user/entrypoint.sh

EXPOSE 5900

ENTRYPOINT ["/home/user/entrypoint.sh"]
CMD ["/bin/bash"]
USER user
WORKDIR /workdir
VOLUME ["/workdir"]

ARG VNCPASSWD=zephyr
RUN mkdir ~/.vnc && x11vnc -storepasswd ${VNCPASSWD} ~/.vnc/passwd

39 changes: 39 additions & 0 deletions Dockerfile.user
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
ARG FROM_TAG
FROM zephyrprojectrtos/ci:${FROM_TAG:-latest}

RUN dpkg --add-architecture i386 && \
apt-get -y update && \
apt-get -y upgrade && \
apt-get install --no-install-recommends -y \
openbox \
python-xdg \
libpython3.8-dev \
x11vnc \
xvfb \
xterm \
xz-utils && \
rm -rf /var/lib/apt/lists/*

ENV DISPLAY=:0
ENV ZEPHYR_BASE=/workdir/zephyr

ADD ./entrypoint.sh /home/user/entrypoint.sh
ADD ./bash_completion /home/user/.bash_completion
RUN mkdir -p /home/user/.bash_completion.d
RUN chown -R user:user /home/user

RUN dos2unix /home/user/entrypoint.sh

EXPOSE 5900

ENTRYPOINT ["/home/user/entrypoint.sh"]
CMD ["/bin/bash"]
USER user

WORKDIR /workdir
VOLUME ["/workdir"]


ARG VNCPASSWD=zephyr
RUN mkdir ~/.vnc && x11vnc -storepasswd ${VNCPASSWD} ~/.vnc/passwd

5 changes: 3 additions & 2 deletions LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -178,15 +178,15 @@
APPENDIX: How to apply the Apache License to your work.

To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
boilerplate notice, with the fields enclosed by brackets "{}"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.

Copyright [yyyy] [name of copyright owner]
Copyright {yyyy} {name of copyright owner}

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand All @@ -199,3 +199,4 @@
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.

13 changes: 10 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,18 @@
# docker-image
Docker image suitable for development, similar to what we have in CI.
# Zephyr Docker Images

We have 2 images:

- CI Image: This is the image used in CI, we try to keep this self-contained.
The image only has the minimal set of software needed for CI operation.
- Developer Image: Based on the base CI image, we provide additional tools that
can be used for development anywhere.

## Developer Docker Image

This docker image can be built with

```
docker build --build-arg UID=$(id -u) --build-arg GID=$(id -g) -t zephyr-build:v<tag> .
docker build -f Dockerfile.user --build-arg UID=$(id -u) --build-arg GID=$(id -g) -t zephyr-build:v<tag> .
```

and can be used for development and building zephyr samples and tests,
Expand Down
5 changes: 5 additions & 0 deletions bash_completion
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
for bcfile in ~/.bash_completion.d/* ; do
. $bcfile
done


0 comments on commit 39e4402

Please sign in to comment.