-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
289 lines (246 loc) · 8.38 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
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
ARG DISTRO=lunar
ARG USER=user
ARG UID=1000
ARG GID=1000
ARG CLANG_MAJOR=16
# clang source options:
# apt - directly use apt version
# llvm - add llvm distro repo
ARG CLANG_SOURCE=apt
ARG GCC_MAJOR=13
# gcc source options:
# apt - directly use apt version
# ppa - add toolchain ppa
ARG GCC_SOURCE=apt
ARG QTCREATOR_VERSION="10.0.1-patched"
ARG QTCREATOR_URL="https://github.com/hicknhack-software/Qt-Creator/releases/download/v10.0.1-snapshot-2023-04-02/qtcreator-linux-x64-4589869247.7z"
ARG QT_ARCH=gcc_64
ARG QT_VERSION=6.5.0
ARG QT_MODULES=qtshadertools
ARG RUNTIME_APT="libicu72 libglib2.0-0 libdbus-1-3 libpcre2-16-0"
# ARG RUNTIME_XENIAL="libicu55 libglib2.0-0"
FROM python:3.10-slim as qt_base
ARG QT_ARCH
ARG QT_VERSION
ARG QT_MODULES
ARG APT_KEY_DONT_WARN_ON_DANGEROUS_USAGE=1
ARG DEBIAN_FRONTEND=noninteractive
RUN pip install aqtinstall
RUN \
apt update --quiet \
&& apt-get install --yes --quiet --no-install-recommends \
p7zip-full \
libglib2.0-0 \
&& apt-get --yes autoremove \
&& apt-get clean autoclean \
&& rm -rf /var/lib/apt/lists/{apt,dpkg,cache,log} /tmp/* /var/tmp/*
RUN \
mkdir /qt && cd /qt \
&& aqt install-qt linux desktop ${QT_VERSION} ${QT_ARCH} -m ${QT_MODULES} --external "7z"
FROM ubuntu:${DISTRO} AS qtcreator_base
ARG DISTRO
ARG USER
ARG UID
ARG GID
ARG QTCREATOR_URL
ARG RUNTIME_APT
ARG APT_KEY_DONT_WARN_ON_DANGEROUS_USAGE=1
ARG DEBIAN_FRONTEND=noninteractive
ENV \
LANG=C.UTF-8 \
LC_ALL=C.UTF-8
# install prerequisites to run qtcreator, tools and Qt
RUN \
apt-get update --quiet \
&& apt-get upgrade --yes --quiet \
&& apt-get install --yes --quiet --no-install-recommends \
apt-transport-https \
ca-certificates \
gnupg \
wget \
&& apt-get update --quiet \
&& apt-get install --yes --quiet --no-install-recommends \
${RUNTIME_APT} \
sudo \
git \
vim \
patch \
ssh \
make \
p7zip-full \
xterm \
xdg-utils \
libpulse0 \
libdbus-1-3 \
libgl1-mesa-dri \
libgl1-mesa-glx \
libxcb-keysyms1 \
libxcb-render-util0 \
libxcb-xfixes0 \
libxcb-icccm4 \
libxcb-image0 \
libxcb-randr0 \
libxcb-shape0 \
libxcb-cursor0 \
libgssapi-krb5-2 \
libxcb-xinerama0 \
libxcb-xkb1 \
libxkbcommon-x11-0 \
libharfbuzz-icu0 \
libegl1-mesa-dev \
libglu1-mesa-dev \
libwayland-egl1 \
libwayland-cursor0 \
&& apt-get --yes autoremove \
&& apt-get clean autoclean \
&& rm -rf /var/lib/apt/lists/{apt,dpkg,cache,log} /tmp/* /var/tmp/*
# install qtcreator from CI build
RUN \
wget --progress=bar:force:noscroll -O qtcreator.7z ${QTCREATOR_URL} \
&& mkdir /opt/qtcreator \
&& 7z x -o/opt/qtcreator qtcreator.7z \
&& rm qtcreator.7z \
&& ln -s /opt/qtcreator/bin/qtcreator /usr/bin/qtcreator
# preconfigure qtcreator
COPY config/qtversion.xml /home/${USER}/.config/QtProject/qtcreator/qtversion.xml
COPY config/QtCreator.ini /home/${USER}/.config/QtProject/QtCreator.ini
# add user for development
RUN \
if [ "${UID}" = "1000" ] ; then userdel --remove ubuntu ; fi \
&& groupadd --gid ${GID} ${USER} \
&& useradd --create-home --home-dir /home/${USER} --shell /bin/bash ${USER} --uid ${UID} --gid ${GID} \
&& echo "${USER} ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers.d/${USER} \
&& chmod 0440 /etc/sudoers.d/${USER} \
&& mkdir -p /build \
&& chown ${UID}:${GID} -R /home/${USER} /build
WORKDIR /build
FROM qtcreator_base AS qtcreator_clang_base
ARG DISTRO
ARG CLANG_MAJOR
ARG CLANG_SOURCE
ARG APT_KEY_DONT_WARN_ON_DANGEROUS_USAGE=1
ARG DEBIAN_FRONTEND=noninteractive
# install Clang (https://apt.llvm.org/) with format and debugger
RUN \
if [ "$CLANG_SOURCE" = "llvm" ] ; then \
wget -qO - https://apt.llvm.org/llvm-snapshot.gpg.key | apt-key add - \
&& echo "deb http://apt.llvm.org/${DISTRO}/ llvm-toolchain-${DISTRO}-${CLANG_MAJOR} main" > /etc/apt/sources.list.d/llvm.list \
&& apt-get update --quiet \
; fi \
&& apt-get install --yes --quiet --no-install-recommends \
clang-${CLANG_MAJOR} \
clang-format-${CLANG_MAJOR} \
lldb-${CLANG_MAJOR} \
lld-${CLANG_MAJOR} \
libc++abi-${CLANG_MAJOR}-dev \
libc++-${CLANG_MAJOR}-dev \
&& update-alternatives --install /usr/bin/clang++ clang++ /usr/bin/clang++-${CLANG_MAJOR} 100 \
&& update-alternatives --install /usr/bin/clang clang /usr/bin/clang-${CLANG_MAJOR} 100 \
&& update-alternatives --install /usr/bin/clang-format clang-format /usr/bin/clang-format-${CLANG_MAJOR} 100 \
&& update-alternatives --install /usr/bin/ld ld /usr/bin/ld.lld-${CLANG_MAJOR} 10 \
&& update-alternatives --install /usr/bin/ld ld /usr/bin/ld.gold 20 \
&& update-alternatives --install /usr/bin/ld ld /usr/bin/ld.bfd 30 \
&& apt-get --yes autoremove \
&& apt-get clean autoclean \
&& rm -rf /var/lib/apt/lists/{apt,dpkg,cache,log} /tmp/* /var/tmp/*
FROM qtcreator_clang_base AS qtcreator-clang
ARG USER
ARG DISTRO
ARG CLANG_MAJOR
ARG QTCREATOR_VERSION
LABEL Description="Ubuntu ${DISTRO} - Clang-${CLANG_MAJOR} + QtCreator-${QTCREATOR_VERSION}"
LABEL org.opencontainers.image.source = "https://github.com/arBmind/qtcreator-containers"
USER ${USER}
ENV \
HOME=/home/${USER} \
XDG_RUNTIME_DIR=/tmp/runtime-${USER}
FROM qtcreator_clang_base AS qtcreator_clang_libstdcpp_base
ARG DISTRO
ARG GCC_MAJOR
ARG GCC_SOURCE
ARG APT_KEY_DONT_WARN_ON_DANGEROUS_USAGE=1
ARG DEBIAN_FRONTEND=noninteractive
RUN \
if [ "$GCC_SOURCE" = "ppa" ] ; then \
apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 60C317803A41BA51845E371A1E9377A2BA9EF27F \
&& echo "deb http://ppa.launchpad.net/ubuntu-toolchain-r/test/ubuntu ${DISTRO} main" > /etc/apt/sources.list.d/gcc.list \
&& apt-get update --quiet \
; fi \
&& apt-get install --yes --quiet --no-install-recommends \
libstdc++-${GCC_MAJOR}-dev \
&& apt-get --yes autoremove \
&& apt-get clean autoclean \
&& rm -rf /var/lib/apt/lists/{apt,dpkg,cache,log} /tmp/* /var/tmp/*
FROM qtcreator_clang_libstdcpp_base AS qtcreator-clang-libstdcpp
ARG USER
ARG DISTRO
ARG GCC_MAJOR
ARG CLANG_MAJOR
ARG QTCREATOR_VERSION
LABEL Description="Ubuntu ${DISTRO} - Clang${CLANG_MAJOR} + libstdc++-${GCC_MAJOR} + QtCreator-${QTCREATOR_VERSION}"
LABEL org.opencontainers.image.source = "https://github.com/arBmind/qtcreator-containers"
USER ${USER}
ENV \
HOME=/home/${USER} \
XDG_RUNTIME_DIR=/tmp/runtime-${USER}
FROM qtcreator_clang_libstdcpp_base AS qtcreator-clang-libstdcpp-qt
ARG USER
ARG DISTRO
ARG CLANG_MAJOR
ARG GCC_MAJOR
ARG QTCREATOR_VERSION
ARG QT_ARCH
ARG QT_VERSION
LABEL Description="Ubuntu ${DISTRO} - Clang${CLANG_MAJOR} + libstdc++-${GCC_MAJOR} + QtCreator-${QTCREATOR_VERSION} + Qt-${QT_VERSION}"
LABEL org.opencontainers.image.source = "https://github.com/arBmind/qtcreator-containers"
COPY --from=qt_base /qt/${QT_VERSION}/${QT_ARCH} /opt/qt
USER ${USER}
ENV \
HOME=/home/${USER} \
XDG_RUNTIME_DIR=/tmp/runtime-${USER}
FROM qtcreator_base AS qtcreator_gcc_base
ARG DISTRO
ARG GCC_MAJOR
ARG GCC_SOURCE
ARG APT_KEY_DONT_WARN_ON_DANGEROUS_USAGE=1
ARG DEBIAN_FRONTEND=noninteractive
# install Clang (https://apt.llvm.org/) with format and debugger
RUN \
if [ "$GCC_SOURCE" = "ppa" ] ; then \
apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 60C317803A41BA51845E371A1E9377A2BA9EF27F \
&& echo "deb http://ppa.launchpad.net/ubuntu-toolchain-r/test/ubuntu ${DISTRO} main" > /etc/apt/sources.list.d/gcc.list \
&& apt-get update --quiet \
; fi \
&& apt-get install --yes --quiet --no-install-recommends \
gcc-${GCC_MAJOR} \
g++-${GCC_MAJOR} \
libstdc++-${GCC_MAJOR}-dev \
gdb \
&& apt-get --yes autoremove \
&& apt-get clean autoclean \
&& rm -rf /var/lib/apt/lists/{apt,dpkg,cache,log} /tmp/* /var/tmp/*
FROM qtcreator_gcc_base AS qtcreator-gcc
ARG USER
ARG DISTRO
ARG GCC_MAJOR
ARG QTCREATOR_VERSION
LABEL Description="Ubuntu ${DISTRO} - GCC-${GCC_MAJOR} + QtCreator-${QTCREATOR_VERSION}"
LABEL org.opencontainers.image.source = "https://github.com/arBmind/qtcreator-containers"
USER ${USER}
ENV \
HOME=/home/${USER} \
XDG_RUNTIME_DIR=/tmp/runtime-${USER}
FROM qtcreator_gcc_base AS qtcreator-gcc-qt
ARG USER
ARG DISTRO
ARG GCC_MAJOR
ARG QTCREATOR_VERSION
ARG QT_ARCH
ARG QT_VERSION
LABEL Description="Ubuntu ${DISTRO} - GCC-${GCC_MAJOR} + QtCreator-${QTCREATOR_VERSION} + Qt-${QT_VERSION}"
LABEL org.opencontainers.image.source = "https://github.com/arBmind/qtcreator-containers"
COPY --from=qt_base /qt/${QT_VERSION}/${QT_ARCH} /opt/qt
USER ${USER}
ENV \
HOME=/home/${USER} \
XDG_RUNTIME_DIR=/tmp/runtime-${USER}