This repository has been archived by the owner on May 2, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
142 lines (123 loc) · 3.82 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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
FROM ubuntu:22.04 as build-base
ARG \
DEBIAN_FRONTEND="noninteractive" \
\
BUILD_OPENWRT_VERSION="v23.05.2"
LABEL version="0.0.1"
#- -----------------------------------------------------------------------------
#- - Base
#- -----------------------------------------------------------------------------
# Build system setup
# Ref: https://openwrt.org/docs/guide-developer/toolchain/install-buildsystem
RUN set -eux \
&& apt-get update \
&& apt-get install -y --no-install-recommends \
bison \
build-essential \
ca-certificates \
clang \
file \
flex \
g++ \
g++-multilib \
gawk \
gcc-multilib \
gettext \
git \
libcurl4-openssl-dev \
libncurses-dev \
libssl-dev \
python3-distutils \
rsync \
unzip \
wget \
zlib1g-dev \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
# Debug settings
RUN set -eux \
&& apt-get update \
&& apt-get install -y --no-install-recommends \
bash \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
# Set git patching
RUN set -eux \
&& apt-get update \
&& apt-get install -y --no-install-recommends \
apt-transport-https \
ca-certificates \
curl \
software-properties-common \
gpg-agent \
&& add-apt-repository -y -u ppa:git-core/ppa \
&& apt-get update \
&& apt-get install -y --no-install-recommends git \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* \
&& git --version --build-options
# gitconfig global
RUN set -eux \
&& git config --global user.name "user" \
&& git config --global user.email "user@example.com" \
&& git config --global http.postBuffer 500M \
&& git config --global https.postBuffer 500M
RUN mkdir -p /opt/openwrt
#- -----------------------------------------------------------------------------
#- - Preparing the source code
#- -----------------------------------------------------------------------------
# Build system usage
# Ref: https://openwrt.org/docs/guide-developer/toolchain/use-buildsystem
FROM build-base as openwrt-base
# Download and update the sources
RUN set -eux \
&& git clone --verbose --progress --depth 1 --branch "${BUILD_OPENWRT_VERSION}" \
https://github.com/openwrt/openwrt.git /opt/openwrt \
&& cd /opt/openwrt
# # # Update the feeds
RUN set -eux \
&& cd /opt/openwrt \
&& sed -i'' \
-e 's@git.openwrt.org/feed@github.com/openwrt@g' \
-e 's@git.openwrt.org/project@github.com/openwrt@g' ./feeds.conf.default \
&& cat ./feeds.conf.default \
&& ./scripts/feeds update -a \
&& ./scripts/feeds install -a
#- -----------------------------------------------------------------------------
#- - Runner
#- -----------------------------------------------------------------------------
# I pre-compile the toolchain and store it in a Docker image layer.
# This allows it to be used as a layer cache.
FROM openwrt-base as runner
ARG \
BUILD_MAKE_OPTIONS=${BUILD_MAKE_OPTIONS:-V=sc}
COPY --chown=root:root \
config/mvebu-cortexa9-fortinet_fg-50e.ini "/opt/openwrt/.config"
RUN set -eux \
&& id \
&& bash --version \
&& bzip2 --version \
&& git --version \
&& gcc --version \
&& gawk --version \
&& gzip --version \
&& make --version \
&& openssl version \
&& patch --version \
&& perl --version \
&& python3 --version \
&& ls -la /usr/bin/python3*
RUN set -eux \
&& cd /opt/openwrt \
&& make defconfig
# DO NOT set -e
RUN set -ux \
&& cd /opt/openwrt \
&& rm -fv staging_dir/host/.prereq-build \
&& make prereq
ENV GCC_COLORS='error=01;31:warning=01;35:note=01;36:caret=01;32:locus=01:quote=01'
RUN set -eux \
&& make --directory /opt/openwrt -j $(($(nproc)+1)) ${BUILD_MAKE_OPTIONS} download
# DO NOT set -eu
RUN set -x \
&& make --directory /opt/openwrt -j $(($(nproc)+1)) ${BUILD_MAKE_OPTIONS} world