Skip to content

Commit 9c02f21

Browse files
btashtonxiaoxiang781216
authored andcommitted
Add Dockerfile for CI system and hook into GitHub Actions
Signed-off-by: Brennan Ashton <bashton@brennanashton.com>
1 parent aa8a4cf commit 9c02f21

File tree

2 files changed

+225
-0
lines changed

2 files changed

+225
-0
lines changed

.github/workflows/docker_linux.yml

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# Licensed under the Apache License, Version 2.0 (the "License");
2+
# you may not use this file except in compliance with the License.
3+
# You may obtain a copy of the License at
4+
#
5+
# http://www.apache.org/licenses/LICENSE-2.0
6+
#
7+
# Unless required by applicable law or agreed to in writing, software
8+
# distributed under the License is distributed on an "AS IS" BASIS,
9+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10+
# See the License for the specific language governing permissions and
11+
# limitations under the License.
12+
#
13+
name: Docker-Linux
14+
15+
on:
16+
push:
17+
# Publish `master` as Docker `latest` image.
18+
branches:
19+
- master
20+
paths:
21+
- 'docker/linux/**'
22+
23+
# Run builds for any PRs.
24+
pull_request:
25+
paths:
26+
- 'docker/linux/**'
27+
28+
env:
29+
# TODO: Change variable to your image's name.
30+
IMAGE_NAME: nuttx-ci-linux
31+
32+
jobs:
33+
# Push image to GitHub Packages.
34+
push:
35+
runs-on: ubuntu-latest
36+
env:
37+
DOCKER_BUILDKIT: 1
38+
IMAGE_TAG: docker.pkg.github.com/${{ github.repository }}/nuttx-ci-linux
39+
steps:
40+
- uses: actions/checkout@v2
41+
42+
- name: Log into registry
43+
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login docker.pkg.github.com -u ${{ github.actor }} --password-stdin
44+
45+
- name: Build Linux image
46+
run: |
47+
echo "Building Linux Image using cache from $IMAGE_TAG"
48+
49+
docker build \
50+
--build-arg BUILDKIT_INLINE_CACHE=1 \
51+
--cache-from $IMAGE_TAG \
52+
--tag $IMAGE_TAG \
53+
-f ./docker/linux/Dockerfile ./docker/
54+
55+
- name: Push Linux image
56+
if: (github.event_name == 'push') && (github.ref == 'refs/heads/master')
57+
run: |
58+
docker push $IMAGE_TAG

docker/linux/Dockerfile

Lines changed: 167 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,167 @@
1+
# Licensed to the Apache Software Foundation (ASF) under one or more
2+
# contributor license agreements. See the NOTICE file distributed with
3+
# this work for additional information regarding copyright ownership. The
4+
# ASF licenses this file to you under the Apache License, Version 2.0 (the
5+
# "License"); you may not use this file except in compliance with the
6+
# License. You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13+
# License for the specific language governing permissions and limitations
14+
# under the License.
15+
16+
FROM ubuntu:19.04 AS builder-base
17+
# NOTE WE ARE NOT REMOVEING APT CACHE.
18+
# This should only be used for temp build images that artifacts will be copied from
19+
RUN apt-get update -qq && apt-get install -y -qq \
20+
curl \
21+
xz-utils
22+
23+
###############################################################################
24+
# Base image that should be used to prepare tools from nuttx-tools
25+
###############################################################################
26+
FROM builder-base AS nuttx-tools
27+
28+
RUN apt-get install -y -qq \
29+
flex \
30+
bison \
31+
gperf \
32+
libncurses5-dev \
33+
make
34+
35+
RUN mkdir /tools
36+
WORKDIR /tools
37+
38+
RUN mkdir -p /tools/nuttx-tools
39+
RUN curl -s -L https://bitbucket.org/nuttx/tools/get/9ad3e1ee75c7.tar.gz \
40+
| tar -C nuttx-tools --strip-components=1 -xz
41+
42+
RUN cd nuttx-tools/kconfig-frontends \
43+
&& ./configure --enable-mconf --disable-gconf --disable-qconf --enable-static --prefix=/tools/kconfig-frontends \
44+
&& make install
45+
46+
RUN cd nuttx-tools \
47+
&& mkdir genromfs \
48+
&& tar -C genromfs --strip-components=1 -xf genromfs-0.5.2.tar.gz \
49+
&& cd genromfs \
50+
&& make install PREFIX=/tools/genromfs
51+
52+
CMD [ "/bin/bash" ]
53+
54+
###############################################################################
55+
# Base image that should be used to prepare arch build images
56+
###############################################################################
57+
FROM builder-base AS nuttx-toolchain-base
58+
59+
RUN mkdir /tools
60+
WORKDIR /tools
61+
62+
###############################################################################
63+
# Build image for tool required by ARM builds
64+
###############################################################################
65+
FROM nuttx-toolchain-base AS nuttx-toolchain-arm
66+
# Download the latest ARM GCC toolchain prebuilt by ARM
67+
RUN mkdir gcc-arm-none-eabi && \
68+
curl -s -L "https://developer.arm.com/-/media/Files/downloads/gnu-rm/9-2019q4/gcc-arm-none-eabi-9-2019-q4-major-x86_64-linux.tar.bz2?revision=108bd959-44bd-4619-9c19-26187abf5225&la=en&hash=E788CE92E5DFD64B2A8C246BBA91A249CB8E2D2D" \
69+
| tar -C gcc-arm-none-eabi --strip-components 1 -xj
70+
71+
###############################################################################
72+
# Build image for tool required by Pinguino builds
73+
###############################################################################
74+
FROM nuttx-toolchain-base AS nuttx-toolchain-pinguino
75+
# Download the pinguino compilers. Note this includes both 8bit and 32bit
76+
# toolchains and builds for multiple host systems. Only copy what is needed.
77+
RUN mkdir pinguino-compilers && \
78+
curl -s -L "https://github.com/PinguinoIDE/pinguino-compilers/archive/62db5158d7f6d41c6fadb05de81cc31dd81a1958.tar.gz" \
79+
| tar -C pinguino-compilers --strip-components=2 --wildcards -xz */linux64
80+
81+
###############################################################################
82+
# Build image for tool required by RISCV builds
83+
###############################################################################
84+
FROM nuttx-toolchain-base AS nuttx-toolchain-riscv
85+
# Download the latest RISCV GCC toolchain prebuilt by SiFive
86+
RUN mkdir riscv64-unknown-elf-gcc && \
87+
curl -s -L "https://static.dev.sifive.com/dev-tools/riscv64-unknown-elf-gcc-8.3.0-2019.08.0-x86_64-linux-ubuntu14.tar.gz" \
88+
| tar -C riscv64-unknown-elf-gcc --strip-components 1 -xz
89+
90+
###############################################################################
91+
# Build image for tool required by ESP32 builds
92+
###############################################################################
93+
FROM nuttx-toolchain-base AS nuttx-toolchain-esp32
94+
# Download the latest ESP32 GCC toolchain prebuilt by Espressif
95+
RUN mkdir xtensa-esp32-elf-gcc && \
96+
curl -s -L "https://dl.espressif.com/dl/xtensa-esp32-elf-gcc8_2_0-esp32-2019r1-rc2-linux-amd64.tar.xz" \
97+
| tar -C xtensa-esp32-elf-gcc --strip-components 1 -xJ
98+
99+
100+
###############################################################################
101+
# Final Docker image used for running CI system. This includes all toolchains
102+
# supported by the CI system.
103+
###############################################################################
104+
FROM ubuntu:19.04
105+
LABEL maintainer="dev@nuttx.apache.org"
106+
107+
RUN dpkg --add-architecture i386
108+
# This is used for the final images so make sure to not store apt cache
109+
RUN apt-get update -qq && apt-get install -y -qq --no-install-recommends \
110+
git \
111+
build-essential \
112+
wget \
113+
libx11-dev \
114+
libxext-dev \
115+
u-boot-tools \
116+
lib32z1-dev \
117+
libc6-dev-i386 \
118+
libx11-dev:i386 \
119+
libxext-dev:i386 \
120+
curl \
121+
gettext \
122+
libcurl4-openssl-dev \
123+
xxd \
124+
unzip \
125+
python3 \
126+
python3-pip \
127+
&& rm -rf /var/lib/apt/lists/*
128+
129+
130+
# Configure out base setup for adding python packages
131+
ENV PIP_DISABLE_PIP_VERSION_CHECK=true
132+
# This disables the cache with value 0. We do not want caching as it
133+
# increases the images size.
134+
ENV PIP_NO_CACHE_DIR=0
135+
# We are using the minimal python installation from the system so include
136+
# setuptools and also wheel so we can use the binary releases of packages
137+
# instead of requiring them to be compiled.
138+
RUN pip3 install setuptools wheel
139+
140+
RUN mkdir /tools
141+
WORKDIR /tools
142+
143+
# Pull in the tools we just built for nuttx
144+
COPY --from=nuttx-tools /tools/genromfs/ /tools/genromfs/
145+
ENV PATH="/tools/genromfs/usr/bin:$PATH"
146+
COPY --from=nuttx-tools /tools/kconfig-frontends/ kconfig-frontends/
147+
ENV PATH="/tools/kconfig-frontends/bin:$PATH"
148+
149+
# ARM toolchain
150+
COPY --from=nuttx-toolchain-arm /tools/gcc-arm-none-eabi/ gcc-arm-none-eabi/
151+
ENV PATH="/tools/gcc-arm-none-eabi/bin:$PATH"
152+
153+
COPY --from=nuttx-toolchain-pinguino /tools/pinguino-compilers/p32/ pinguino-compilers/p32/
154+
ENV PATH="/tools/pinguino-compilers/p32/bin:$PATH"
155+
#COPY --from=nuttx-toolchain-pinguino /tools/pinguino-compilers/p8/ pinguino-compilers/p8/
156+
#ENV PATH="/tools/pinguino-compilers/p8/bin:$PATH"
157+
158+
# RISCV toolchain
159+
COPY --from=nuttx-toolchain-riscv /tools/riscv64-unknown-elf-gcc/ riscv64-unknown-elf-gcc/
160+
ENV PATH="/tools/riscv64-unknown-elf-gcc/bin:$PATH"
161+
162+
# ESP32 toolchain
163+
COPY --from=nuttx-toolchain-esp32 /tools/xtensa-esp32-elf-gcc/ xtensa-esp32-elf-gcc/
164+
ENV PATH="/tools/xtensa-esp32-elf-gcc/bin:$PATH"
165+
RUN pip3 install esptool
166+
167+
ENTRYPOINT [ "/bin/bash" ]

0 commit comments

Comments
 (0)