Repository navigation
Expand file tree
/
Copy pathDockerfile
More file actions
357 lines (333 loc) · 11.7 KB
/
Copy pathDockerfile
File metadata and controls
357 lines (333 loc) · 11.7 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
344
345
346
347
348
349
350
351
352
353
354
355
356
357
# syntax=docker/dockerfile:1
# Download the apt lists once at the start. The RUN --mount options ensure
# the lists are shared readonly but the lockable parts aren't to permit
# maximum opportunity for parallel stages.
FROM ubuntu:24.04 AS common
USER root
ENV DEBIAN_FRONTEND='noninteractive' TZ='UTC'
COPY --link <<-EOT /etc/apt/apt.conf.d/00_no-cache
APT::Install-Recommends "0";
APT::Install-Suggests "0";
Dir::Cache::pkgcache "";
Dir::Cache::srcpkgcache "";
EOT
# Some python packages are required here (such as lxml) because they are
# required during build and force pip to use the system versions, some libs
# such as libpangoft2 are runtime dependencies of weasyprint.
FROM common AS base
RUN --mount=type=cache,target=/var/cache/apt,sharing=private \
--mount=type=cache,target=/var/lib/apt,sharing=private \
<<EOT
apt-get update
apt-get install -y \
ca-certificates \
git \
gpg \
locales \
libcairo2 \
libpangoft2-1.0-0 \
libwoff1 \
python3-appdirs \
python3-chardet \
python3-brotli \
python3-fs \
python3-freetype \
python3-gi \
python3-icu \
python3-idna \
python3-lxml \
python3-lz4 \
python3-pkg-resources \
python3-yaml \
python3-requests \
python3-jinja2 \
python3-poetry \
python3-full \
python3-cairo \
libgl1 \
ipython3 \
apt-utils \
python3-venv \
jq \
asciidoctor \
ruby-rouge \
flake8 \
black \
python3-pytest \
wget
apt-get remove python3-packaging python3-pip python3-setuptools python3-wheel python3-setuptools-scm -y
wget https://bootstrap.pypa.io/get-pip.py
python3 get-pip.py --break-system-packages
# from https://discuss.python.org/t/information-for-python-users-regarding-emudhra-emsign-ca-certificate-security-incident/109576
python3 -m pip install --break-system-packages "pip @ https://files.pythonhosted.org/packages/3f/06/3e4420302363fbb71be3c7f35ce042f54bfca330e3e66b3a2e3c4cca579f/pip-26.2.2-py3-none-any.whl#sha256=fd7f4dfa8190e014013b9f08f3e973f4e4c26ffd179a204895533a7254813a70"
#python3 -m pip config --global set global.use-deprecated legacy-resolver
python3 -m pip config --global set global.break-system-packages true
python3 -m pip config --global set global.root-user-action ignore
python3 -m pip install --uploaded-prior-to P3D uv
uv pip install --exclude-newer "2 days" --system --break-system-packages --upgrade pip certifi sigstore brotli brotlicffi
uv pip install --exclude-newer "15 days" --system --break-system-packages --upgrade packaging setuptools wheel typing_extensions build
python3 -m pip --version
uv --version
localedef -i en_US -c -f UTF-8 -A /usr/share/locale/locale.alias en_US.UTF-8
pip uninstall fs -y
EOT
# Grab the PPAs
FROM base AS ppa
RUN --mount=type=cache,target=/var/cache/apt,sharing=private \
--mount=type=cache,target=/var/lib/apt,sharing=private \
<<EOT
apt-get update
apt-get install -y gpg-agent software-properties-common ca-certificates
add-apt-repository -y ppa:sile-typesetter/sile
add-apt-repository -y ppa:silnrsi/smith-py3
EOT
# Set up basic build tooling environment
FROM base AS build
ENV PATH=$PATH:/root/.local/bin
RUN --mount=type=cache,target=/var/cache/apt,sharing=private \
--mount=type=cache,target=/var/lib/apt,sharing=private \
<<EOT
apt-get update
apt-get upgrade -y
apt-get install -y \
build-essential \
cargo \
gcc \
g++ \
python3-dev \
cmake \
make \
automake \
gcovr \
gobject-introspection \
libcairo2-dev \
libbrotli-dev \
libfreetype-dev \
libglib2.0-dev \
libgirepository1.0-dev \
libicu-dev \
libjpeg-dev \
liblz4-dev \
libpython3-dev \
libtool \
libwoff-dev \
libssl-dev \
mono-mcs \
pkg-config \
ragel \
meson \
ninja-build
EOT
# Build Glyph layout engines
FROM build AS engines-src
WORKDIR /src/graphite
RUN <<EOT
git clone --depth 1 https://github.com/silnrsi/graphite.git .
cmake -G Ninja -B build -DCMAKE_BUILD_TYPE=Release \
-DGRAPHITE2_COMPARE_RENDERER:BOOL=OFF \
-DGRAPHITE2_NTRACING:BOOL=OFF
cmake --build build
cmake --install build
uv pip install --exclude-newer "15 days" --system --break-system-packages --compile .
EOT
WORKDIR /src/harfbuzz
RUN <<EOT
git clone https://github.com/harfbuzz/harfbuzz.git .
meson setup build \
--buildtype=release \
--auto-features=enabled \
--wrap-mode=nodownload \
-Dchafa=disabled \
-Dexperimental_api=true \
-Dgraphite2=enabled \
-Dgobject=disabled \
-Dintrospection=disabled \
-Dgpu=disabled \
-Dtests=disabled \
-Ddocs=disabled
meson compile -C build
ninja -C build
ninja -C build install
ldconfig
EOT
# Build graphite compiler
FROM build AS grcompiler-src
WORKDIR /src/grcompiler
RUN <<EOT
git clone --depth 1 https://github.com/silnrsi/grcompiler.git .
cmake -G Ninja -B build -DCMAKE_BUILD_TYPE=Release
cmake --build build
cmake --install build
EOT
# Build OTS Sanitizer
FROM build AS ots-src
WORKDIR /src/ots
RUN <<EOT
git clone --depth 1 --recurse-submodules https://github.com/khaledhosny/ots.git .
uv pip install --exclude-newer "15 days" --system --break-system-packages --upgrade ninja
uv pip install --exclude-newer "15 days" --system --break-system-packages --upgrade meson
meson build --buildtype=release
ninja -C build
ninja -C build install
EOT
# Install sile and fontprooof as a "rock"
FROM build AS fontproof-src
WORKDIR /src/fontproof
COPY --from=ppa /etc/apt/ /etc/apt/
RUN --mount=type=cache,target=/var/cache/apt,sharing=private \
--mount=type=cache,target=/var/lib/apt,sharing=private \
<<EOT
apt-get update
apt-get install lua5.1 liblua5.1-dev -y
apt-get install luajit -y
apt-get install luarocks -y
luarocks config lua_version 5.1
luarocks config lua_interpreter luajit
luarocks install fontproof
EOT
# Python components
FROM build AS smith-tooling
WORKDIR /src/smith
COPY --link docker/*requirements.txt docker/*constraints.txt docker/
#RUN python3 -m pip install --use-pep517 -r docker/smith-requirements.txt
RUN uv pip install --exclude-newer "15 days" --system --break-system-packages --prerelease=allow -U -r docker/smith-requirements.txt
COPY --link . ./
#RUN python3 -m pip install .
RUN uv pip install --exclude-newer "15 days" --system --break-system-packages .
RUN uv pip install --exclude-newer "15 days" --system --break-system-packages unzone
# Rust components: fontspector
FROM build AS fontspector-src
WORKDIR /src/fontspector
COPY --from=ppa /etc/apt/ /etc/apt/
RUN --mount=type=cache,target=/var/cache/apt,sharing=private \
--mount=type=cache,target=/var/lib/apt,sharing=private \
<<EOT
apt-get update
apt-get install rustup pkgconf libssl-dev protobuf-compiler zlib1g-dev -y
rustup install stable
git clone --depth 1 https://github.com/silnrsi/fontspector .
cargo build --release
cp -v /src/fontspector/target/release/fontspector /usr/local/bin/fontspector
EOT
FROM base AS runtime
LABEL org.opencontainers.image.authors="tim_eves@sil.org, nicolas_spalinger@sil.org" \
org.opencontainers.image.title="smith" \
org.opencontainers.image.documentation="https://silnrsi.github.io/smith/" \
org.opencontainers.image.description="Smith font development toolchain" \
org.opencontainers.image.source="https://github.com/silnrsi/smith" \
org.opencontainers.image.vendor="SIL Global"
COPY --from=ppa /etc/apt/ /etc/apt/
RUN --mount=type=cache,target=/var/cache/apt,sharing=private \
--mount=type=cache,target=/var/lib/apt,sharing=private \
<<EOT
apt-get update
apt-get install -y \
fonts-roboto \
libfont-ttf-scripts-perl \
libjson-perl \
pandoc \
sile \
texlive-xetex \
ttfautohint libqt5gui5-gles \
wamerican \
wbritish \
xsltproc \
xz-utils \
dialog \
libaa-bin
paperconfig --paper a4
EOT
ARG robotomono_src=https://raw.githubusercontent.com/googlefonts/RobotoMono/main/fonts/ttf
ADD --link \
${robotomono_src}/RobotoMono-Regular.ttf \
${robotomono_src}/RobotoMono-Italic.ttf \
${robotomono_src}/RobotoMono-Bold.ttf ${robotomono_src}/RobotoMono-BoldItalic.ttf \
${robotomono_src}/RobotoMono-Light.ttf ${robotomono_src}/RobotoMono-LightItalic.ttf \
${robotomono_src}/RobotoMono-Medium.ttf ${robotomono_src}/RobotoMono-MediumItalic.ttf \
${robotomono_src}/RobotoMono-Thin.ttf ${robotomono_src}/RobotoMono-ThinItalic.ttf \
/usr/local/share/fonts/robotomono/
# Copy the fontspector profile
COPY --link docker/silfonts.toml /usr/local/share/silfonts/silfonts.toml
# Copy the layers back in
COPY --link --from=ots-src /usr/local /usr/local
COPY --link --from=fontproof-src /usr/local /usr/local
COPY --link --from=grcompiler-src /usr/local /usr/local
COPY --link --from=engines-src /usr/local /usr/local
COPY --link --from=smith-tooling /usr/local /usr/local
COPY --link --from=fontspector-src /usr/local /usr/local
# Install TeamCity build Agent, by extracting it from the official cloud image
FROM runtime AS build-agent-teamcity
RUN --mount=type=cache,target=/var/cache/apt,sharing=private \
--mount=type=cache,target=/var/lib/apt,sharing=private \
<<EOT
apt-get update
apt-get install -y \
openjdk-21-jre-headless
useradd -m buildagent
EOT
USER buildagent
COPY --link --chown=buildagent:buildagent --from=jetbrains/teamcity-minimal-agent /opt/buildagent/ /opt/buildagent/
COPY --link --chown=buildagent:buildagent --from=jetbrains/teamcity-minimal-agent /run-*.sh /
VOLUME "/data/teamcity_agent/conf"
VOLUME "/opt/buildagent/work"
VOLUME "/opt/buildagent/system"
VOLUME "/opt/buildagent/temp"
VOLUME "/opt/buildagent/logs"
VOLUME "/opt/buildagent/tools"
VOLUME "/opt/buildagent/plugins"
#COPY --link --from=jetbrains/teamcity-minimal-agent /services/ /services/
ENV CONFIG_FILE=/data/teamcity_agent/conf/buildAgent.properties \
LANG=C.UTF-8 \
DOTNET_CLI_TELEMETRY_OPTOUT=true \
DOTNET_SKIP_FIRST_TIME_EXPERIENCE=true \
ASPNETCORE_URLS=http://+:80 \
DOTNET_RUNNING_IN_CONTAINER=true \
DOTNET_USE_POLLING_FILE_WATCHER=true \
NUGET_XMLDOC_MODE=skip \
GIT_SSH_VARIANT=ssh \
DOTNET_SDK_VERSION=
CMD ["/run-services.sh"]
# Add in some user facing tools for interactive use.
FROM runtime AS interactive
ENV BUILDER_UID=
ENV BUILDER_GID=
COPY --link --chmod=750 docker/interactive-entrypoint.sh /entrypoint.sh
COPY --link bash_completion_smith /etc/bash_completion.d/smith
COPY --link docker/profile-extra-utilities-smith.sh /etc/profile.d/profile-extra-utilities-smith.sh
COPY --link docker/fix-git-execute-bits-scripts /usr/local/bin/fix-git-execute-bits-scripts
COPY --link docker/dot.bashrc /etc/skel/.bashrc
COPY --link docker/dot.gitconfig /etc/skel/.gitconfig
COPY --link docker/fontbakery /etc/bash_completion.d/fontbakery
RUN touch /etc/skel/.sudo_as_admin_successful
RUN touch /etc/skel/.hushlogin
RUN --mount=type=cache,target=/var/cache/apt,sharing=private \
--mount=type=cache,target=/var/lib/apt,sharing=private \
<<EOT
apt-get update
apt-get install -y \
bash-completion \
curl \
htop \
less \
nano \
ncdu \
perl-doc \
sudo \
tree \
unzip \
vim \
wget \
command-not-found
apt-get update
apt-get upgrade -y
apt-get autoremove -y
apt-get clean
install --owner=1005 --group=users -d /smith
EOT
COPY --link <<-EOT /etc/sudoers.d/nopasswd
builder ALL=(ALL:ALL) NOPASSWD:ALL
ubuntu ALL=(ALL:ALL) NOPASSWD:ALL
EOT
VOLUME /smith
ENTRYPOINT [ "/entrypoint.sh" ]
CMD ["/bin/bash"]