From e74d3e126e30e5a2e872271f7fe7ca14c564bd8a Mon Sep 17 00:00:00 2001 From: Andras Fekete Date: Wed, 21 Feb 2024 16:49:35 -0500 Subject: [PATCH] Add in files for yocto build environment --- Docker/yocto/Dockerfile | 22 ++++++++++++++++++++++ Docker/yocto/buildAndPush.sh | 27 +++++++++++++++++++++++++++ 2 files changed, 49 insertions(+) create mode 100644 Docker/yocto/Dockerfile create mode 100755 Docker/yocto/buildAndPush.sh diff --git a/Docker/yocto/Dockerfile b/Docker/yocto/Dockerfile new file mode 100644 index 000000000..ec44aed71 --- /dev/null +++ b/Docker/yocto/Dockerfile @@ -0,0 +1,22 @@ +FROM ubuntu + +# Set timezone to UTC +RUN ln -snf /usr/share/zoneinfo/UTC /etc/localtime && echo UTC > /etc/timezone + +RUN DEBIAN_FRONTEND=noninteractive apt update && apt install -y gawk wget git diffstat unzip texinfo gcc build-essential chrpath socat cpio python3 python3-pip python3-pexpect xz-utils debianutils iputils-ping python3-git python3-jinja2 libegl1-mesa libsdl1.2-dev python3-subunit mesa-common-dev zstd liblz4-tool file locales libacl1 vim && apt clean -y && rm -rf /var/lib/apt/lists/* +RUN locale-gen en_US.UTF-8 + +# Add in non-root user +ENV UID_OF_DOCKERUSER 1000 +RUN useradd -m -s /bin/bash -g users -u ${UID_OF_DOCKERUSER} dockerUser +RUN chown -R dockerUser:users /home/dockerUser && chown dockerUser:users /opt + +USER dockerUser + +RUN cd /opt && git clone git://git.yoctoproject.org/poky +WORKDIR /opt/poky + +ARG YOCTO_VERSION=kirkstone +RUN git checkout -t origin/${YOCTO_VERSION} -b ${YOCTO_VERSION} && git pull + +RUN /bin/bash -c "source oe-init-build-env && bitbake core-image-minimal" diff --git a/Docker/yocto/buildAndPush.sh b/Docker/yocto/buildAndPush.sh new file mode 100755 index 000000000..d76a603e8 --- /dev/null +++ b/Docker/yocto/buildAndPush.sh @@ -0,0 +1,27 @@ +#!/bin/bash + +# Assume we're in wolfssl/Docker/yocto +WOLFSSL_DIR=$(builtin cd ${BASH_SOURCE%/*}/../..; pwd) + +DOCKER_BUILD_OPTIONS="$1" +if [ "${DOCKER_BASE_IMAGE}" != "" ]; then + DOCKER_BUILD_OPTIONS+=" --build-arg DOCKER_BASE_IMAGE=${DOCKER_BASE_IMAGE}" +fi + +NUM_FAILURES=0 + +CUR_DATE=$(date -u +%F) +for ver in kirkstone dunfell; do + echo "Building wolfssl/yocto:${ver}-${CUR_DATE} as ${DOCKER_BUILD_OPTIONS}" + docker build -t wolfssl/yocto:${ver}-${CUR_DATE} --build-arg YOCTO_VERSION=${ver} -f Dockerfile "${WOLFSSL_DIR}/Docker/yocto" && \ + docker tag wolfssl/yocto:${ver}-${CUR_DATE} wolfssl/yocto:${ver}-latest + if [ $? -eq 0 ]; then + echo "Pushing containers to DockerHub" + docker push wolfssl/yocto:${ver}-${CUR_DATE} && docker push wolfssl/yocto:${ver}-latest + else + echo "Warning: Build wolfssl/yocto:${ver} failed. Continuing" + ((NUM_FAILURES++)) + fi +done + +echo "Script completed in $SECONDS seconds. Had $NUM_FAILURES failures."