-
-
Notifications
You must be signed in to change notification settings - Fork 17
/
Dockerfile
167 lines (134 loc) · 4.76 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
FROM ubuntu:bionic as base
LABEL maintainer="devel@jochenbauer.net"
LABEL stage=qt-build-base
# UID/GID injection on build if wanted
ARG USER_UID=
ARG USER_GID=
# In case you have to build behind a proxy
ARG PROXY=
ENV http_proxy=$PROXY
ENV https_proxy=$PROXY
# Name of the regular user. Does not look useful but can save a bit time when changing
ENV QT_USERNAME=qt
# Needed in both builder and qt stages, so has to be defined here
ENV QT_PREFIX=/usr/local
# Install all build dependencies
RUN apt-get update && apt-get -y dist-upgrade && apt-get -y --no-install-recommends install \
ca-certificates \
# sudo to be able to modify the container as the user, if needed.
sudo \
curl \
python \
gperf \
bison \
flex \
build-essential \
pkg-config \
libgl1-mesa-dev \
libicu-dev \
firebird-dev \
libmysqlclient-dev \
libpq-dev \
# bc suggested for openssl tests
bc \
libssl-dev \
# git is needed to build openssl in older versions
git \
# xcb dependencies
libfontconfig1-dev \
libfreetype6-dev \
libx11-dev \
libxext-dev \
libxfixes-dev \
libxi-dev \
libxrender-dev \
libxcb1-dev \
libx11-xcb-dev \
libxcb-glx0-dev \
libxkbcommon-x11-dev \
libxcb-shm0-dev \
libxcb-icccm4-dev \
libxcb-image0-dev \
libxcb-keysyms1-dev \
libxcb-render-util0-dev \
libxcb-xinerama0-dev \
libxcb-util-dev \
x11proto-record-dev \
libxtst-dev \
libatspi2.0-dev \
libatk-bridge2.0-dev \
# bash needed for argument substitution in entrypoint
bash \
# since 5.14.0 we apparently need libdbus-1-dev and libnss3-dev
libnss3-dev \
libdbus-1-dev \
&& apt-get -qq clean \
&& rm -rf /var/lib/apt/lists/* \
&& printf "#!/bin/sh\nls -lah" > /usr/local/bin/ll && chmod +x /usr/local/bin/ll
# Adding regular user
RUN if [ ${USER_GID} ]; then \
addgroup -g ${USER_GID} ${QT_USERNAME}; \
else \
addgroup ${QT_USERNAME}; \
fi \
&& if [ ${USER_UID} ]; then \
useradd -u ${USER_UID} -g ${QT_USERNAME} ${QT_USERNAME}; \
else \
useradd -g ${QT_USERNAME} ${QT_USERNAME}; \
fi && mkdir /home/${QT_USERNAME}
# make sure the user is able to sudo if needed
RUN adduser ${QT_USERNAME} sudo
RUN echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers
# build stage
FROM base as builder
LABEL stage=qt-build-builder
# QT Version
ARG QT_VERSION_MAJOR=5
ARG QT_VERSION_MINOR=11
ARG QT_VERSION_PATCH=3
ENV QT_BUILD_ROOT=/tmp/qt_build
# They switched the tarball naming scheme from 5.9 to 5.10. This ARG shall provide a possibility to reflect that
ARG QT_TARBALL_NAMING_SCHEME=everywhere
# Providing flag for archived or stable versions
ARG QT_DOWNLOAD_BRANCH=official_releases
ENV QT_BUILD_DIR=${QT_BUILD_ROOT}/qt-${QT_TARBALL_NAMING_SCHEME}-src-${QT_VERSION_MAJOR}.${QT_VERSION_MINOR}.${QT_VERSION_PATCH}/build
# Installing from here
WORKDIR ${QT_BUILD_ROOT}
# Download sources
RUN curl -sSL https://download.qt.io/${QT_DOWNLOAD_BRANCH}/qt/${QT_VERSION_MAJOR}.${QT_VERSION_MINOR}/${QT_VERSION_MAJOR}.${QT_VERSION_MINOR}.${QT_VERSION_PATCH}/single/qt-${QT_TARBALL_NAMING_SCHEME}-src-${QT_VERSION_MAJOR}.${QT_VERSION_MINOR}.${QT_VERSION_PATCH}.tar.xz | tar xJ
WORKDIR ${QT_BUILD_DIR}
# Possibility to make outputs less verbose when required for a ci build
ARG CI_BUILD=
ENV CI_BUILD=${CI_BUILD}
# Speeding up make depending of your system
ARG CORE_COUNT=1
ENV CORE_COUNT=${CORE_COUNT}
# Configure, make, install
ADD buildconfig/configure-${QT_VERSION_MAJOR}.${QT_VERSION_MINOR}.${QT_VERSION_PATCH}.sh configure.sh
# before running the configuration, adding a directory to copy additional contents to the final image
RUN mkdir /opt/extra-dependencies && chmod +x ./configure.sh && ./configure.sh ${CORE_COUNT} ${CI_BUILD}
COPY buildconfig/build.sh build.sh
RUN ./build.sh ${CI_BUILD} ${CORE_COUNT}
# install it
RUN make install
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# resulting image with environment
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
FROM base as qt
ENV ENTRYPOINT_DIR=/usr/local/bin
ENV APP_BUILDDIR=/var/build
COPY --from=builder ${QT_PREFIX} ${QT_PREFIX}
# the next copy statement failed often. My only guess is, that the extra dependencies are not existent and somehow that
# triggers a failure here.... A workaround for similar issues is to put an empty run statement in between: https://github.com/moby/moby/issues/37965
RUN true
COPY --from=builder /opt/extra-dependencies /opt/extra-dependencies
#for modifications during configuration
ENV LD_LIBRARY_PATH=/opt/extra-dependencies/lib:${LD_LIBRARY_PATH}
# the next copy statement failed often. My only guess is, that the extra dependencies are not existent and somehow that
# triggers a failure here.... A workaround for similar issues is to put an empty run statement in between: https://github.com/moby/moby/issues/37965
RUN true
COPY entrypoint.sh ${ENTRYPOINT_DIR}
RUN chmod +x ${ENTRYPOINT_DIR}/entrypoint.sh
VOLUME ["${APP_BUILDDIR}"]
USER ${QT_USERNAME}
ENTRYPOINT ["entrypoint.sh"]