-
-
Notifications
You must be signed in to change notification settings - Fork 198
Expand file tree
/
Copy pathDockerfile.common
More file actions
343 lines (318 loc) · 13.4 KB
/
Dockerfile.common
File metadata and controls
343 lines (318 loc) · 13.4 KB
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
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
# syntax=docker/dockerfile:1.4
#
# baseimage-gui Dockerfile
#
# https://github.com/jlesage/docker-baseimage-gui
#
# Get Dockerfile cross-compilation helpers.
FROM --platform=$BUILDPLATFORM tonistiigi/xx AS xx
# Get UPX (statically linked).
# NOTE: UPX 5.x is not compatible with old kernels (e.g. 3.10) used by some
# Synology NASes. See https://github.com/upx/upx/issues/902
FROM --platform=$BUILDPLATFORM alpine:3.20 AS upx
ARG UPX_VERSION=4.2.4
RUN \
if echo "${UPX_VERSION}" | grep -q '^[0-9]\+\.[0-9]\+\.[0-9]\+$'; then \
apk --no-cache add curl && \
mkdir /tmp/upx && \
curl -# -L https://github.com/upx/upx/releases/download/v${UPX_VERSION}/upx-${UPX_VERSION}-amd64_linux.tar.xz | tar xJ --strip 1 -C /tmp/upx && \
cp -v /tmp/upx/upx /usr/bin/upx; \
else \
apk --no-cache add build-base cmake clang git && \
git clone https://github.com/upx/upx.git && \
git -C upx reset --hard ${UPX_VERSION} && \
git -C upx submodule update --init && \
make -C upx build/extra/gcc/all CC="clang" CXX="clang++" CFLAGS="-static" CXXFLAGS="-static" LDFLAGS="-Wl,--strip-all" && \
cp -v upx/build/extra/gcc/release/upx /usr/bin/upx; \
fi
# Build Intel CLC
FROM --platform=$BUILDPLATFORM alpine:3.21 AS intel_clc
ARG TARGETPLATFORM
COPY --from=xx / /
COPY src/intel_clc /build
RUN /build/build.sh
# Build TigerVNC server.
FROM --platform=$BUILDPLATFORM alpine:3.21 AS tigervnc
ARG TARGETPLATFORM
COPY --from=xx / /
COPY --from=intel_clc /tmp/intel_clc_install /
COPY src/tigervnc /build
RUN /build/build.sh
RUN xx-verify /tmp/tigervnc-rootfs/opt/base/bin/Xvnc
RUN xx-verify /tmp/tigervnc-rootfs/opt/base/lib/*.*
RUN xx-verify /tmp/tigervnc-rootfs/opt/base/lib/*/*
RUN xx-verify --static /tmp/tigervnc-rootfs/opt/base/bin/vncpasswd
COPY --from=upx /usr/bin/upx /usr/bin/upx
RUN upx /tmp/tigervnc-rootfs/opt/base/bin/Xvnc
RUN upx /tmp/tigervnc-rootfs/opt/base/bin/vncpasswd
# Build xkeyboard-config.
FROM --platform=$BUILDPLATFORM alpine:3.20 AS xkeyboard-config
ARG TARGETPLATFORM
COPY --from=xx / /
COPY src/xkeyboard-config /build
RUN /build/build.sh
# Build xkbcomp.
FROM --platform=$BUILDPLATFORM alpine:3.20 AS xkbcomp
ARG TARGETPLATFORM
COPY --from=xx / /
COPY src/xkbcomp /build
RUN /build/build.sh
RUN xx-verify --static /tmp/xkbcomp-install/usr/bin/xkbcomp
COPY --from=upx /usr/bin/upx /usr/bin/upx
RUN upx /tmp/xkbcomp-install/usr/bin/xkbcomp
# Build Fontconfig.
FROM --platform=$BUILDPLATFORM alpine:3.20 AS fontconfig
ARG TARGETPLATFORM
COPY --from=xx / /
COPY src/fontconfig/build.sh /tmp/build-fontconfig.sh
RUN /tmp/build-fontconfig.sh
# Build Openbox.
FROM --platform=$BUILDPLATFORM alpine:3.20 AS openbox
ARG TARGETPLATFORM
COPY --from=xx / /
COPY --from=fontconfig /tmp/fontconfig-install /tmp/fontconfig-install
COPY src/openbox /tmp/build
RUN /tmp/build/build.sh
RUN xx-verify --static \
/tmp/openbox-install/usr/bin/openbox \
/tmp/openbox-install/usr/bin/obxprop
COPY --from=upx /usr/bin/upx /usr/bin/upx
RUN upx /tmp/openbox-install/usr/bin/openbox
RUN upx /tmp/openbox-install/usr/bin/obxprop
# Build xrdb.
FROM --platform=$BUILDPLATFORM alpine:3.20 AS xrdb
ARG TARGETPLATFORM
COPY --from=xx / /
COPY src/xrdb /build
RUN /build/build.sh
RUN xx-verify --static /tmp/xrdb-install/usr/bin/xrdb
COPY --from=upx /usr/bin/upx /usr/bin/upx
RUN upx /tmp/xrdb-install/usr/bin/xrdb
# Build fastcompmgr.
FROM --platform=$BUILDPLATFORM alpine:3.20 AS fastcompmgr
ARG TARGETPLATFORM
COPY --from=xx / /
COPY src/fastcompmgr /build
RUN /build/build.sh
RUN xx-verify --static /tmp/fastcompmgr-install/usr/bin/fastcompmgr
COPY --from=upx /usr/bin/upx /usr/bin/upx
RUN upx /tmp/fastcompmgr-install/usr/bin/fastcompmgr
# Build hsetroot.
FROM --platform=$BUILDPLATFORM alpine:3.20 AS hsetroot
ARG TARGETPLATFORM
COPY --from=xx / /
COPY src/hsetroot /build
RUN /build/build.sh
RUN xx-verify --static /tmp/hsetroot-install/usr/bin/hsetroot
COPY --from=upx /usr/bin/upx /usr/bin/upx
RUN upx /tmp/hsetroot-install/usr/bin/hsetroot
# Build xdpyprobe.
# Used to determine if the X server (Xvnc) is ready.
FROM --platform=$BUILDPLATFORM alpine:3.20 AS xdpyprobe
ARG TARGETPLATFORM
COPY --from=xx / /
COPY src/xdpyprobe /tmp/xdpyprobe
RUN apk --no-cache add make clang lld
RUN xx-apk --no-cache add gcc musl-dev libx11-dev libx11-static libxcb-static
RUN CC=xx-clang \
make -C /tmp/xdpyprobe
RUN xx-verify --static /tmp/xdpyprobe/xdpyprobe
COPY --from=upx /usr/bin/upx /usr/bin/upx
RUN upx /tmp/xdpyprobe/xdpyprobe
# Build dbus-daemon.
FROM --platform=$BUILDPLATFORM alpine:3.20 AS dbus
ARG TARGETPLATFORM
COPY --from=xx / /
COPY src/dbus-daemon /build
RUN /build/build.sh
RUN xx-verify --static /tmp/dbus-install/usr/bin/dbus-daemon
COPY --from=upx /usr/bin/upx /usr/bin/upx
RUN upx /tmp/dbus-install/usr/bin/dbus-daemon
# Build notify-send.
FROM --platform=$BUILDPLATFORM golang:1.23-alpine AS notify-send
ARG TARGETPLATFORM
ENV CGO_ENABLED=0
COPY --from=xx / /
COPY src/notify-send /tmp/build-notify-send
RUN cd /tmp/build-notify-send && xx-go build -ldflags "-s -w"
RUN xx-verify --static /tmp/build-notify-send/notify-send
COPY --from=upx /usr/bin/upx /usr/bin/upx
RUN upx /tmp/build-notify-send/notify-send
# Build yad.
FROM --platform=$BUILDPLATFORM alpine:3.20 AS yad
ARG TARGETPLATFORM
COPY --from=xx / /
COPY --from=fontconfig /tmp/fontconfig-install /tmp/fontconfig-install
COPY src/yad /build
RUN /build/build.sh
RUN xx-verify --static /tmp/yad-install/usr/bin/yad
COPY --from=upx /usr/bin/upx /usr/bin/upx
RUN upx /tmp/yad-install/usr/bin/yad
# Build Nginx.
FROM --platform=$BUILDPLATFORM alpine:3.20 AS nginx
ARG TARGETPLATFORM
COPY --from=xx / /
COPY src/nginx/build.sh /tmp/build-nginx.sh
RUN /tmp/build-nginx.sh
RUN xx-verify --static /tmp/nginx-install/sbin/nginx
COPY --from=upx /usr/bin/upx /usr/bin/upx
RUN upx /tmp/nginx-install/sbin/nginx
# NOTE: Extended attributes are kept by buildx when using the COPY command.
# See https://wildwolf.name/multi-stage-docker-builds-and-xattrs/.
RUN apk --no-cache add libcap && setcap cap_net_bind_service=ep /tmp/nginx-install/sbin/nginx
# Build PulseAudio.
FROM --platform=$BUILDPLATFORM alpine:3.20 AS pulseaudio
ARG TARGETPLATFORM
COPY --from=xx / /
COPY src/pulseaudio /build-pulseaudio
RUN /build-pulseaudio/build.sh
RUN xx-verify --static /tmp/pulseaudio-install/usr/bin/pulseaudio
COPY --from=upx /usr/bin/upx /usr/bin/upx
RUN upx /tmp/pulseaudio-install/usr/bin/pulseaudio
# Build the audio recorder.
FROM --platform=$BUILDPLATFORM alpine:3.20 AS audiorecorder
ARG TARGETPLATFORM
COPY --from=xx / /
COPY src/audiorecorder /tmp/build-audiorecorder
RUN /tmp/build-audiorecorder/build.sh
RUN xx-verify --static /tmp/build-audiorecorder/audiorecorder
COPY --from=upx /usr/bin/upx /usr/bin/upx
RUN upx /tmp/build-audiorecorder/audiorecorder
# Build the web authenticator.
FROM --platform=$BUILDPLATFORM golang:1.24-alpine AS webauth
ARG TARGETPLATFORM
ENV CGO_ENABLED=0
COPY --from=xx / /
COPY src/webauth /tmp/build-webauth
RUN cd /tmp/build-webauth && xx-go build -ldflags "-s -w"
RUN xx-verify --static /tmp/build-webauth/webauth
COPY --from=upx /usr/bin/upx /usr/bin/upx
RUN upx /tmp/build-webauth/webauth
# Build the web services daemon.
FROM --platform=$BUILDPLATFORM golang:1.23-alpine AS webservices
ARG TARGETPLATFORM
ENV CGO_ENABLED=0
COPY --from=xx / /
COPY src/webservices /tmp/build-webservices
RUN cd /tmp/build-webservices && xx-go build -ldflags "-s -w"
RUN xx-verify --static /tmp/build-webservices/webservices
COPY --from=upx /usr/bin/upx /usr/bin/upx
RUN upx /tmp/build-webservices/webservices
# Build htpasswd
FROM --platform=$BUILDPLATFORM alpine:3.20 AS htpasswd
ARG TARGETPLATFORM
COPY --from=xx / /
COPY src/htpasswd /tmp/build-htpasswd
RUN /tmp/build-htpasswd/build.sh
RUN xx-verify --static /tmp/httpd-install/usr/bin/htpasswd
COPY --from=upx /usr/bin/upx /usr/bin/upx
RUN upx /tmp/httpd-install/usr/bin/htpasswd
# Build noVNC.
FROM --platform=$BUILDPLATFORM alpine:3.20 AS noVNC
ARG NOVNC_VERSION=1.7.0
ARG BOOTSTRAP_VERSION=5.3.3
ARG FONTAWESOME_VERSION=5.15.4
ARG XTERM_VERSION=6.0.0
ARG XTERM_ADDON_FIT_VERSION=0.11.0
ARG NOVNC_URL=https://github.com/novnc/noVNC/archive/refs/tags/v${NOVNC_VERSION}.tar.gz
ARG BOOTSTRAP_URL=https://github.com/twbs/bootstrap/releases/download/v${BOOTSTRAP_VERSION}/bootstrap-${BOOTSTRAP_VERSION}-dist.zip
ARG FONTAWESOME_URL=https://github.com/FortAwesome/Font-Awesome/releases/download/${FONTAWESOME_VERSION}/fontawesome-free-${FONTAWESOME_VERSION}-web.zip
ARG XTERM_JS_URL=https://cdn.jsdelivr.net/npm/@xterm/xterm@${XTERM_VERSION}/lib/xterm.js
ARG XTERM_JS_MAP_URL=https://cdn.jsdelivr.net/npm/@xterm/xterm@${XTERM_VERSION}/lib/xterm.js.map
ARG XTERM_CSS_URL=https://cdn.jsdelivr.net/npm/@xterm/xterm@${XTERM_VERSION}/css/xterm.css
ARG XTERM_ADDON_FIT_URL=https://cdn.jsdelivr.net/npm/@xterm/addon-fit@${XTERM_ADDON_FIT_VERSION}/lib/addon-fit.min.js
ARG XTERM_ADDON_FIT_MAP_URL=https://cdn.jsdelivr.net/npm/@xterm/addon-fit@${XTERM_ADDON_FIT_VERSION}/lib/addon-fit.min.js.map
WORKDIR /tmp
COPY src/novnc /build
COPY helpers/* /usr/bin/
COPY rootfs/opt/noVNC/index.html /opt/noVNC/index.html
COPY rootfs/opt/noVNC/app/notificationService.js /opt/noVNC/app/notificationService.js
COPY rootfs/opt/noVNC/app/pcm-player.js /tmp/pcm-player.js
COPY rootfs/opt/noVNC/app/unmute.js /tmp/unmute.js
COPY rootfs/opt/noVNC/login/index.html /opt/noVNC/login/index.html
RUN \
# Install required tools.
apk --no-cache add \
curl \
patch \
libarchive-tools \
sed \
jq \
npm \
minify \
imagemagick \
&& \
npm install clean-css-cli -g
RUN \
# Create required directories.
mkdir -p \
/opt/noVNC/app/styles \
/opt/noVNC/app/fonts
RUN \
# Install noVNC.
mkdir /tmp/noVNC && \
curl -# -L ${NOVNC_URL} | tar -xz --strip 1 -C /tmp/noVNC && \
patch --no-backup-if-mismatch -p1 -d /tmp/noVNC < /build/auto-clipboard-sync.patch && \
patch --no-backup-if-mismatch -p1 -d /tmp/noVNC < /build/mac-key-remap.patch && \
cp -vr /tmp/noVNC/core /opt/noVNC/ && \
cp -vr /tmp/noVNC/vendor /opt/noVNC/
RUN \
# Install Bootstrap.
curl -sS -L -O ${BOOTSTRAP_URL} && \
unzip bootstrap-${BOOTSTRAP_VERSION}-dist.zip && \
cp -v bootstrap-${BOOTSTRAP_VERSION}-dist/css/bootstrap.min.css /opt/noVNC/app/styles/ && \
cp -v bootstrap-${BOOTSTRAP_VERSION}-dist/js/bootstrap.bundle.min.js* /opt/noVNC/app/
RUN \
# Install Font Awesome.
mkdir /tmp/fontawesome && \
curl -# -L ${FONTAWESOME_URL} | bsdtar xf - --strip-components=1 -C /tmp/fontawesome && \
find /tmp/fontawesome/webfonts -name "fa-solid-900.*" -not -name "*.svg" -exec cp -v {} /opt/noVNC/app/fonts/ ';' && \
cp -v /tmp/fontawesome/css/solid.min.css /opt/noVNC/app/styles/ && \
cp -v /tmp/fontawesome/css/fontawesome.min.css /opt/noVNC/app/styles/ && \
sed -i 's/webfonts/fonts/g' /opt/noVNC/app/styles/solid.min.css
RUN \
# Install xterm.js.
curl -# -L -o /opt/noVNC/app/xterm.js ${XTERM_JS_URL} && \
curl -# -L -o /opt/noVNC/app/xterm.js.map ${XTERM_JS_MAP_URL} && \
curl -# -L -o /opt/noVNC/app/styles/xterm.css ${XTERM_CSS_URL} && \
curl -# -L -o /opt/noVNC/app/xterm-addon-fit.js ${XTERM_ADDON_FIT_URL} && \
curl -# -L -o /opt/noVNC/app/xterm-addon-fit.js.map ${XTERM_ADDON_FIT_MAP_URL}
RUN \
# Set version of CSS and JavaScript file URLs.
date | md5sum | cut -c1-10 > /tmp/unique_version && \
sed "s/UNIQUE_VERSION/$(cat /tmp/unique_version)/g" -i /opt/noVNC/app/notificationService.js && \
sed "s/UNIQUE_VERSION/$(cat /tmp/unique_version)/g" -i /opt/noVNC/index.html && \
sed "s/UNIQUE_VERSION/$(cat /tmp/unique_version)/g" -i /opt/noVNC/login/index.html
RUN \
# Minify Javascript.
minify -o /opt/noVNC/app/pcm-player.min.js /tmp/pcm-player.js && \
minify -o /opt/noVNC/app/unmute.min.js /tmp/unmute.js
RUN \
# Generate favicons.
APP_ICON_URL=https://github.com/jlesage/docker-templates/raw/master/jlesage/images/generic-app-icon.png && \
install_app_icon.sh --no-tools-install "$APP_ICON_URL"
# Pull the scratch image.
FROM scratch
# Add files.
COPY --link helpers/* /opt/base/bin/
COPY --link rootfs/ /
COPY --link --from=tigervnc /tmp/tigervnc-rootfs /
COPY --link --from=xkeyboard-config /tmp/xkb-install/usr/share/X11/xkb /opt/base/share/X11/xkb
COPY --link --from=xrdb /tmp/xrdb-install/usr/bin/xrdb /opt/base/bin/
COPY --link --from=xkbcomp /tmp/xkbcomp-install/usr/bin/xkbcomp /opt/base/bin/
COPY --link --from=openbox /tmp/openbox-install/usr/bin/openbox /opt/base/bin/
COPY --link --from=openbox /tmp/openbox-install/usr/bin/obxprop /opt/base/bin/
COPY --link --from=fastcompmgr /tmp/fastcompmgr-install/usr/bin/fastcompmgr /opt/base/bin/
COPY --link --from=hsetroot /tmp/hsetroot-install/usr/bin/hsetroot /opt/base/bin/
COPY --link --from=fontconfig /tmp/fontconfig-install/opt /opt
COPY --link --from=xdpyprobe /tmp/xdpyprobe/xdpyprobe /opt/base/bin/
COPY --link --from=dbus /tmp/dbus-install/usr/bin/dbus-daemon /opt/base/bin/
COPY --link --from=notify-send /tmp/build-notify-send/notify-send /opt/base/bin/
COPY --link --from=yad /tmp/yad-install/usr/bin/yad /opt/base/bin/
COPY --link --from=nginx /tmp/nginx-install /opt/base/
COPY --link --from=pulseaudio /tmp/pulseaudio-install/usr/bin/pulseaudio /opt/base/bin/pulseaudio
COPY --link --from=audiorecorder /tmp/build-audiorecorder/audiorecorder /opt/base/bin/audiorecorder
COPY --link --from=webauth /tmp/build-webauth/webauth /opt/base/bin/webauth
COPY --link --from=webservices /tmp/build-webservices/webservices /opt/base/bin/webservices
COPY --link --from=htpasswd /tmp/httpd-install/usr/bin/htpasswd /opt/base/bin/htpasswd
COPY --link --from=noVNC /opt/noVNC /opt/noVNC