feat: Zephyr 2.3.0 & SDK 0.11.4
Foundation version of GitHub workflow and Dockerfile. Based on: https://docs.zephyrproject.org/2.3.0/getting_started/index.html https://docs.zephyrproject.org/2.3.0/getting_started/installation_linux.html#install-requirements-and-dependencies + SDK 0.11.4
This commit is contained in:
		
							
								
								
									
										134
									
								
								.github/workflows/containers.yml
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										134
									
								
								.github/workflows/containers.yml
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,134 @@
 | 
			
		||||
name: Containers
 | 
			
		||||
 | 
			
		||||
env:
 | 
			
		||||
  zephyr-version: 2.3.0
 | 
			
		||||
  zephyr-sdk-version: 0.11.4
 | 
			
		||||
 | 
			
		||||
on:
 | 
			
		||||
  push:
 | 
			
		||||
  pull_request:
 | 
			
		||||
  workflow_dispatch:
 | 
			
		||||
 | 
			
		||||
jobs:
 | 
			
		||||
  docker:
 | 
			
		||||
    runs-on: ubuntu-latest
 | 
			
		||||
    strategy:
 | 
			
		||||
      max-parallel: 1 # takes advantage of caching between types
 | 
			
		||||
      matrix:
 | 
			
		||||
        architecture:
 | 
			
		||||
          - arm
 | 
			
		||||
        target: # ordered from biggest to smallest to take advantage of the registry cache
 | 
			
		||||
          - dev
 | 
			
		||||
          - build
 | 
			
		||||
        include:
 | 
			
		||||
          - target: dev
 | 
			
		||||
            cache-to: dev
 | 
			
		||||
            push-cache: true
 | 
			
		||||
          - target: build
 | 
			
		||||
            cache-to: build
 | 
			
		||||
            push-cache: false
 | 
			
		||||
    steps:
 | 
			
		||||
      - name: Login to GitHub Container Registry
 | 
			
		||||
        uses: docker/login-action@v1
 | 
			
		||||
        with:
 | 
			
		||||
          registry: ghcr.io
 | 
			
		||||
          username: ${{ secrets.GHCR_USERNAME }}
 | 
			
		||||
          password: ${{ secrets.GHCR_TOKEN }}
 | 
			
		||||
      - name: Login to DockerHub
 | 
			
		||||
        uses: docker/login-action@v1
 | 
			
		||||
        with:
 | 
			
		||||
          username: ${{ secrets.DOCKER_HUB_USERNAME }}
 | 
			
		||||
          password: ${{ secrets.DOCKER_HUB_TOKEN }}
 | 
			
		||||
      - name: Prepare variables
 | 
			
		||||
        id: vars
 | 
			
		||||
        run: |
 | 
			
		||||
          NAME=zmk-${{ matrix.target }}-${{ matrix.architecture }}
 | 
			
		||||
          echo ::set-output name=name::${NAME}
 | 
			
		||||
 | 
			
		||||
          CACHE_NAME=zmk-docker-cache
 | 
			
		||||
          CACHE_FROM=${CACHE_NAME}:dev
 | 
			
		||||
          CACHE_TO=${CACHE_NAME}:${{ matrix.cache-to }}
 | 
			
		||||
          echo ::set-output name=cache-from::${CACHE_FROM}
 | 
			
		||||
          echo ::set-output name=cache-to::${CACHE_TO}
 | 
			
		||||
 | 
			
		||||
          CANDIDATE_TAG=${NAME}:${{ github.sha }}
 | 
			
		||||
          echo ::set-output name=candidate-tag::${CANDIDATE_TAG}
 | 
			
		||||
 | 
			
		||||
          VERSIONS_TAG=${NAME}:${{ env.zephyr-version }}-${{ env.zephyr-sdk-version }}
 | 
			
		||||
          echo ::set-output name=versions-tag::${VERSIONS_TAG}
 | 
			
		||||
 | 
			
		||||
          MAJOR=$(echo ${{ env.zephyr-version }} | cut -d'.' -f 1)
 | 
			
		||||
          MINOR=$(echo ${{ env.zephyr-version }} | cut -d'.' -f 2)
 | 
			
		||||
          MAJOR_MINOR=${MAJOR}.${MINOR}
 | 
			
		||||
          echo ::set-output name=major-minor::${MAJOR_MINOR}
 | 
			
		||||
 | 
			
		||||
          LATEST_TAG=${NAME}:${MAJOR_MINOR}
 | 
			
		||||
          echo ::set-output name=latest-tag::${LATEST_TAG}
 | 
			
		||||
 | 
			
		||||
          TAG_TRIGGER_REF=refs/tags/${{ env.zephyr-version }}-${{ env.zephyr-sdk-version }}
 | 
			
		||||
          echo ::set-output name=tag-trigger-ref::${TAG_TRIGGER_REF}
 | 
			
		||||
      - name: Set up QEMU
 | 
			
		||||
        if: ${{ !startsWith(github.ref, 'refs/tags') }}
 | 
			
		||||
        uses: docker/setup-qemu-action@v1
 | 
			
		||||
      - name: Set up Docker Buildx
 | 
			
		||||
        if: ${{ !startsWith(github.ref, 'refs/tags') }}
 | 
			
		||||
        uses: docker/setup-buildx-action@v1
 | 
			
		||||
      - name: Build and push (candidate)
 | 
			
		||||
        id: build-push
 | 
			
		||||
        if: ${{ !startsWith(github.ref, 'refs/tags') }}
 | 
			
		||||
        uses: docker/build-push-action@v2
 | 
			
		||||
        with:
 | 
			
		||||
          target: ${{ matrix.target }}
 | 
			
		||||
          build-args: |
 | 
			
		||||
            ZEPHYR_VERSION=${{ env.zephyr-version }}
 | 
			
		||||
            ARCHITECTURE=${{ matrix.architecture }}
 | 
			
		||||
            ZEPHYR_SDK_VERSION=${{ env.zephyr-sdk-version }}
 | 
			
		||||
            REPOSITORY_URL=${{ github.server_url }}/${{ github.repository }}
 | 
			
		||||
          tags: |
 | 
			
		||||
            docker.io/${{ secrets.DOCKER_HUB_NAMESPACE }}/${{ steps.vars.outputs.candidate-tag }}
 | 
			
		||||
          cache-from: type=registry,ref=docker.io/${{ secrets.DOCKER_HUB_NAMESPACE }}/${{ steps.vars.outputs.cache-from }},push=false
 | 
			
		||||
          cache-to: type=registry,ref=docker.io/${{ secrets.DOCKER_HUB_NAMESPACE }}/${{ steps.vars.outputs.cache-to }},mode=max,push=${{ matrix.push-cache }}
 | 
			
		||||
          push: true
 | 
			
		||||
      - name: Image digest
 | 
			
		||||
        if: ${{ !startsWith(github.ref, 'refs/tags') }}
 | 
			
		||||
        run: echo ${{ steps.build-push.outputs.digest }}
 | 
			
		||||
      - name: Tag (pull candidate, tag, push)
 | 
			
		||||
        if: ${{ github.ref == steps.vars.outputs.tag-trigger-ref }}
 | 
			
		||||
        run: |
 | 
			
		||||
          docker pull docker.io/${{ secrets.DOCKER_HUB_NAMESPACE }}/${{ steps.vars.outputs.candidate-tag }}
 | 
			
		||||
          docker tag docker.io/${{ secrets.DOCKER_HUB_NAMESPACE }}/${{ steps.vars.outputs.candidate-tag }} docker.io/${{ secrets.DOCKER_HUB_NAMESPACE }}/${{ steps.vars.outputs.versions-tag }}
 | 
			
		||||
          docker tag docker.io/${{ secrets.DOCKER_HUB_NAMESPACE }}/${{ steps.vars.outputs.candidate-tag }} docker.io/${{ secrets.DOCKER_HUB_NAMESPACE }}/${{ steps.vars.outputs.latest-tag }}
 | 
			
		||||
          docker tag docker.io/${{ secrets.DOCKER_HUB_NAMESPACE }}/${{ steps.vars.outputs.candidate-tag }} ghcr.io/${{ github.repository_owner }}/${{ steps.vars.outputs.candidate-tag }}
 | 
			
		||||
          docker tag docker.io/${{ secrets.DOCKER_HUB_NAMESPACE }}/${{ steps.vars.outputs.candidate-tag }} ghcr.io/${{ github.repository_owner }}/${{ steps.vars.outputs.versions-tag }}
 | 
			
		||||
          docker tag docker.io/${{ secrets.DOCKER_HUB_NAMESPACE }}/${{ steps.vars.outputs.candidate-tag }} ghcr.io/${{ github.repository_owner }}/${{ steps.vars.outputs.latest-tag }}
 | 
			
		||||
          docker push docker.io/${{ secrets.DOCKER_HUB_NAMESPACE }}/${{ steps.vars.outputs.candidate-tag }}
 | 
			
		||||
          docker push docker.io/${{ secrets.DOCKER_HUB_NAMESPACE }}/${{ steps.vars.outputs.versions-tag }}
 | 
			
		||||
          docker push docker.io/${{ secrets.DOCKER_HUB_NAMESPACE }}/${{ steps.vars.outputs.latest-tag }}
 | 
			
		||||
          docker push ghcr.io/${{ github.repository_owner }}/${{ steps.vars.outputs.candidate-tag }}
 | 
			
		||||
          docker push ghcr.io/${{ github.repository_owner }}/${{ steps.vars.outputs.versions-tag }}
 | 
			
		||||
          docker push ghcr.io/${{ github.repository_owner }}/${{ steps.vars.outputs.latest-tag }}
 | 
			
		||||
  git:
 | 
			
		||||
    runs-on: ubuntu-latest
 | 
			
		||||
    needs: docker
 | 
			
		||||
    if: ${{ startsWith(github.ref, 'refs/tags') }}
 | 
			
		||||
    steps:
 | 
			
		||||
      - name: Prepare variables
 | 
			
		||||
        id: vars
 | 
			
		||||
        run: |
 | 
			
		||||
          MAJOR=$(echo ${{ env.zephyr-version }} | cut -d'.' -f 1)
 | 
			
		||||
          MINOR=$(echo ${{ env.zephyr-version }} | cut -d'.' -f 2)
 | 
			
		||||
          MAJOR_MINOR=${MAJOR}.${MINOR}
 | 
			
		||||
          echo ::set-output name=major-minor::${MAJOR_MINOR}
 | 
			
		||||
 | 
			
		||||
          TAG_TRIGGER_REF=refs/tags/${{ env.zephyr-version }}-${{ env.zephyr-sdk-version }}
 | 
			
		||||
          echo ::set-output name=tag-trigger-ref::${TAG_TRIGGER_REF}
 | 
			
		||||
      - name: Checkout
 | 
			
		||||
        uses: actions/checkout@v2
 | 
			
		||||
        if: ${{ github.ref == steps.vars.outputs.tag-trigger-ref }}
 | 
			
		||||
      - name: Tag
 | 
			
		||||
        if: ${{ github.ref == steps.vars.outputs.tag-trigger-ref }}
 | 
			
		||||
        env:
 | 
			
		||||
          TAG: ${{ steps.vars.outputs.major-minor }}
 | 
			
		||||
        run: |
 | 
			
		||||
          git tag ${TAG}
 | 
			
		||||
          git push -f origin ${TAG}
 | 
			
		||||
							
								
								
									
										86
									
								
								Dockerfile
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										86
									
								
								Dockerfile
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,86 @@
 | 
			
		||||
FROM debian:stable-20201117-slim AS common
 | 
			
		||||
 | 
			
		||||
CMD ["/bin/bash"]
 | 
			
		||||
 | 
			
		||||
ARG REPOSITORY_URL=https://github.com/innovaker/zmk-docker
 | 
			
		||||
LABEL org.opencontainers.image.source ${REPOSITORY_URL}
 | 
			
		||||
 | 
			
		||||
ARG ZEPHYR_VERSION
 | 
			
		||||
ENV ZEPHYR_VERSION=${ZEPHYR_VERSION}
 | 
			
		||||
RUN \
 | 
			
		||||
  apt-get -y update \
 | 
			
		||||
  && apt-get -y install --no-install-recommends \
 | 
			
		||||
  ccache \
 | 
			
		||||
  cmake \
 | 
			
		||||
  file \
 | 
			
		||||
  gcc \
 | 
			
		||||
  gcc-multilib \
 | 
			
		||||
  git \
 | 
			
		||||
  gperf \
 | 
			
		||||
  make \
 | 
			
		||||
  ninja-build \
 | 
			
		||||
  python3 \
 | 
			
		||||
  python3-pip \
 | 
			
		||||
  python3-setuptools \
 | 
			
		||||
  python3-wheel \
 | 
			
		||||
  && pip3 install \
 | 
			
		||||
  -r https://raw.githubusercontent.com/zephyrproject-rtos/zephyr/v${ZEPHYR_VERSION}/scripts/requirements-base.txt \
 | 
			
		||||
  && apt-get remove -y --purge \
 | 
			
		||||
  python3-pip \
 | 
			
		||||
  python3-setuptools \
 | 
			
		||||
  python3-wheel \
 | 
			
		||||
  && apt-get clean \
 | 
			
		||||
  && rm -rf /var/lib/apt/lists/*
 | 
			
		||||
 | 
			
		||||
#------------------------------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
FROM common AS dev-generic
 | 
			
		||||
 | 
			
		||||
RUN \
 | 
			
		||||
  apt-get -y update \
 | 
			
		||||
  && apt-get -y install --no-install-recommends \
 | 
			
		||||
  g++-multilib \
 | 
			
		||||
  libsdl2-dev \
 | 
			
		||||
  python3 \
 | 
			
		||||
  python3-dev \
 | 
			
		||||
  python3-pip \
 | 
			
		||||
  python3-setuptools \
 | 
			
		||||
  python3-tk \
 | 
			
		||||
  python3-wheel \
 | 
			
		||||
  wget \
 | 
			
		||||
  xz-utils \
 | 
			
		||||
  && pip3 install \
 | 
			
		||||
  -r https://raw.githubusercontent.com/zephyrproject-rtos/zephyr/v${ZEPHYR_VERSION}/scripts/requirements-build-test.txt \
 | 
			
		||||
  -r https://raw.githubusercontent.com/zephyrproject-rtos/zephyr/v${ZEPHYR_VERSION}/scripts/requirements-run-test.txt \
 | 
			
		||||
  && apt-get clean \
 | 
			
		||||
  && rm -rf /var/lib/apt/lists/*
 | 
			
		||||
 | 
			
		||||
#------------------------------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
FROM common AS build
 | 
			
		||||
 | 
			
		||||
ARG ARCHITECTURE
 | 
			
		||||
ARG ZEPHYR_SDK_VERSION
 | 
			
		||||
ARG ZEPHYR_SDK_SETUP_FILENAME=zephyr-toolchain-${ARCHITECTURE}-${ZEPHYR_SDK_VERSION}-setup.run
 | 
			
		||||
ARG ZEPHYR_SDK_INSTALL_DIR=/opt/zephyr-sdk-${ZEPHYR_SDK_VERSION}
 | 
			
		||||
RUN \
 | 
			
		||||
  apt-get -y update \
 | 
			
		||||
  && apt-get -y install --no-install-recommends \
 | 
			
		||||
  bzip2 \
 | 
			
		||||
  wget \
 | 
			
		||||
  xz-utils \
 | 
			
		||||
  && wget -q "https://github.com/zephyrproject-rtos/sdk-ng/releases/download/v${ZEPHYR_SDK_VERSION}/${ZEPHYR_SDK_SETUP_FILENAME}" \
 | 
			
		||||
  && sh ${ZEPHYR_SDK_SETUP_FILENAME} --quiet -- -d ${ZEPHYR_SDK_INSTALL_DIR} \
 | 
			
		||||
  && rm ${ZEPHYR_SDK_SETUP_FILENAME} \
 | 
			
		||||
  && apt-get remove -y --purge \
 | 
			
		||||
  bzip2 \
 | 
			
		||||
  wget \
 | 
			
		||||
  xz-utils \
 | 
			
		||||
  && apt-get clean \
 | 
			
		||||
  && rm -rf /var/lib/apt/lists/*
 | 
			
		||||
 | 
			
		||||
#------------------------------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
FROM dev-generic AS dev
 | 
			
		||||
 | 
			
		||||
COPY --from=build ${ZEPHYR_SDK_INSTALL_DIR} ${ZEPHYR_SDK_INSTALL_DIR}
 | 
			
		||||
		Reference in New Issue
	
	Block a user