forked from unframework/licheepi-nano-buildroot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
98 lines (80 loc) · 2.31 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
FROM ubuntu:18.04 AS base
# Buildroot release version
ARG BUILDROOT_RELEASE=2023.02
ENV DEBIAN_FRONTEND=noninteractive
# cache apt-get update results
RUN apt-get update
# install build prerequisites
# @todo remove python3-distutils after upgrading U-Boot
RUN apt-get install -qy \
bc \
bison \
build-essential \
bzr \
chrpath \
cpio \
cvs \
devscripts \
diffstat \
dosfstools \
fakeroot \
flex \
gawk \
git \
libncurses5-dev \
libssl-dev \
locales \
python3-dev \
python3-distutils \
python3-setuptools \
rsync \
subversion \
swig \
texinfo \
unzip \
wget \
whiptail
# external toolchain needs this
RUN update-locale LC_ALL=C
# get Buildroot image
WORKDIR /root/buildroot
RUN wget -qO- http://buildroot.org/downloads/buildroot-${BUILDROOT_RELEASE}.tar.gz | tar --strip-components=1 -xz
# build the cross-compilation toolchain as a separate cacheable image
FROM base AS sdk
# configure a skeleton setup for `make sdk` only at first
# (we take special care to not include other unrelated config files)
WORKDIR /root/licheepi-nano-sdk
RUN echo 'name: LICHEEPI_NANO_SDK' >> external.desc
RUN echo 'desc: LicheePi Nano SDK only' >> external.desc
RUN touch external.mk Config.in
COPY configs/licheepi_nano_sdk_defconfig configs/
# compile the SDK (this takes a while!)
WORKDIR /root/buildroot
RUN BR2_EXTERNAL=/root/licheepi-nano-sdk make licheepi_nano_sdk_defconfig
RUN make sdk
# start main build using the generated toolchain bundle
FROM base AS main
# copy over the SDK tarball (keeping the name)
COPY --from=sdk /root/buildroot/output/images/arm-buildroot-linux-gnueabi_sdk-buildroot.tar.gz /root/
# copy over the main config
WORKDIR /root/licheepi-nano
COPY board/ board/
COPY configs/ configs/
COPY \
Config.in \
external.desc \
external.mk \
./
# set up the defconfig
WORKDIR /root/buildroot
RUN BR2_EXTERNAL=/root/licheepi-nano make licheepi_nano_defconfig
# prep the toolchain from the tarball
RUN make toolchain
# prepare for builds (broken out separately to cache more granularly, especially Linux source fetch)
RUN make linux-source
RUN make uboot-source
# run the main build command
RUN make
# expose built image files in standalone root folder
FROM scratch AS dist
COPY --from=main /root/buildroot/output/images/ .