forked from 3mdeb/esp-open-sdk-docker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
110 lines (90 loc) · 3.12 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
99
100
101
102
103
104
105
106
107
108
109
110
# It is a multi-stages docker build with following stages:
# - "esp-opensdk-builder" stage has all the stuff required to build esp-open-sdk
# - "esp-openrtos-bulder" stage takes only the binary toolchain from the first
# stage + only a few prerequisites to perform esp-openrtos-build
# if set, remove the SDK build directory from the final container
# greate if you only need the xtensa compiler binary file and don't care about anything else (default)
FROM ubuntu:20.04 as esp-opensdk-base
ARG MAKEFLAGS=-j$(nproc)
ARG REMOVE_SDK_BUILD_DIR=1
ARG DEBIAN_FRONTEND=noninteractive
# the 'python-is-python2' package makes /usr/bin/python be python2 (needed for esptool)
RUN apt-get update && apt-get upgrade -y && \
apt-get install -y --no-install-recommends \
make \
python2 \
python-is-python2 \
python3 \
python3-serial \
ca-certificates \
bash \
curl
# python2 stuff is for esptool.py
RUN curl https://bootstrap.pypa.io/pip/2.7/get-pip.py -o get-pip.py && python2 get-pip.py && pip2 install pyserial && rm -f get-pip.py
### "esp-opensdk-builder" stage ###
FROM esp-opensdk-base as esp-opensdk-builder
USER root
RUN apt-get update && apt-get upgrade -y && \
apt-get install -y --no-install-recommends \
unrar-free \
autoconf \
automake \
libtool \
gcc \
g++ \
gperf \
flex \
bison \
texinfo \
gawk \
ncurses-dev \
libexpat-dev \
python3-dev \
python3-pip \
python3-setuptools \
sed \
git \
unzip \
help2man \
wget \
bzip2 \
libtool-bin \
patch
RUN pip install --upgrade pip
RUN mkdir /opt/esp-open-sdk && chown 1000:1000 /opt/esp-open-sdk
RUN useradd --uid 1000 build
# esp-open-sdk build must NOT be performed by root.
USER build
RUN cd /opt/esp-open-sdk && \
git clone --recursive https://github.com/Unit-e/esp-open-sdk && \
cd esp-open-sdk && \
make toolchain esptool libhal STANDALONE=n && \
cd ../ && \
mv esp-open-sdk/xtensa-lx106-elf . && \
/bin/bash -c "if [[ \"${REMOVE_SDK_BUILD_DIR}\" == '1' ]]; then rm -rf esp-open-sdk/; else echo 'Keeping build dir.'; fi"
# or, do it as a second step (ineffecient but useful for debugging docker container builds)
# RUN cd /opt/esp-open-sdk && rm -rf esp-open-sdk
### "esp-openrtos-builder" stage ###
FROM esp-opensdk-base as esp-openrtos-builder
# original (bulk of work)
LABEL author="Maciej Pijanowski <[email protected]>"
LABEL author2="Dominic Cerquetti <dom at cerquetti dot solutions>"
# gcc and libusb-dev needed for stuff in web/ folder in LSC
RUN apt-get update && apt-get upgrade -y && \
apt-get install -y --no-install-recommends \
make \
python3 \
python3-serial \
bash \
gcc \
g++ \
libusb-1.0-0-dev
RUN useradd --uid 1000 build
COPY --from=esp-opensdk-builder /opt/esp-open-sdk /opt/esp-open-sdk
RUN mkdir -p /opt/esp-open-sdk/esptool/ && \
ln -s /opt/esp-open-sdk/xtensa-lx106-elf/bin/esptool.py /opt/esp-open-sdk/esptool/esptool.py && \
chown -R root:root /opt/esp-open-sdk/
USER build
WORKDIR /home/build/src/
ENV PATH="/opt/esp-open-sdk/xtensa-lx106-elf/bin:${PATH}"
ENV ESP_ROOT="/opt/esp-open-sdk"