-
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDockerfile.no-cge
More file actions
278 lines (234 loc) · 12.7 KB
/
Dockerfile.no-cge
File metadata and controls
278 lines (234 loc) · 12.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
# syntax=docker/dockerfile:1
# -*- mode: shell-script -*-
#
# This Dockerfile defines the base Docker image for CGE cloud builds tools,
# exposed as "kambi/castle-engine-cloud-builds-tools:cge-none".
# This image contains prerequisites (like FPC and Android SDK) but not CGE.
# Used by build.sh.
# Docker build argument, see
# https://medium.com/@tonistiigi/advanced-multi-stage-build-patterns-6f741b852fae .
# The variable has verbose name, DOCKER_FPCLAZARUS_VERSION, to not be confused
# with (in theory independent) FPCLAZARUS_VERSION we set inside Docker environment.
# Allowed now (see bottom of this for implementation):
# - 3.2.0
# - 3.2.2
# - 3.3.1 (FPC recent snapshot from GitLab "main" branch)
ARG DOCKER_FPCLAZARUS_VERSION=3.2.2
# Base image ------------------------------------------------------------------
# We base on Debian bookworm.
# It includes Java 17 (just default-jdk gives it), required by Android Gradle Plugin 8.0.1.
# See https://hub.docker.com/_/debian about "slim" meaning.
FROM debian:bookworm-slim AS base-without-fpc
# Install and configure Debian tools -----------------------------------------
# Reasons of packages:
# - wget is for downloading in /usr/local/fpclazarus/bin/add_new_fpc_version.sh
# - libglx-dev, libgl-dev link with OpenGL
# - libgtk2.0-dev link with GTK 2 (for CGE editor with default LCL backend on Linux)
# - libgtk-3-dev link with GTK 3 (for TCastleWindow with GTK 3 backend)
# - xorg-dev to link with additional X libs, used by CASTLE_WINDOW_XLIB (used by https://github.com/castle-engine/cge-www/blob/master/Jenkinsfile.convert-to-x3d )
# - default-jdk is for Android SDK
# - unzip is needed by Android sdkmanager
# - binutils-mingw-w64 and gcc
# for CGE build tool cross-compiling to Windows (32 and 64), it needs resource compiler
# - zip for CGE build tool (to package to zip)
# - libnvtt-bin for CGE build tool (to generate compressed textures)
# - make to compile FPC, and for various jobs
# - file is used by Android compilation (although it seems it works without it too, but there's some error about "file" binary missing)
# - curl for TestFairy uploader
# - git for 1. "make tests" in pasdoc, 2. for GH Actions actions/checkout (LFS useful for some games with larger data like unholy-society) (this is unlike Jenkins, that does checkout/clone outside of Docker)
# - php-cli for "make tests" in pasdoc and in cge-www
# - asciidoctor, coderay, ruby-rouge for "make tests" in cge-www
# - imagemagick for update_image_sizes.sh in cge-www
# - libqt5pas-dev for compiling LCL applications with qt5 widgetset
RUN apt-get --allow-releaseinfo-change update && \
apt-get --no-install-recommends -y install \
asciidoctor \
coderay \
ruby-rouge \
curl \
binutils-mingw-w64 \
default-jdk \
file \
gcc \
git git-lfs \
imagemagick \
libqt5pas-dev \
libglx-dev libgl-dev \
libgtk2.0-dev \
libgtk-3-dev \
xorg-dev \
libnvtt-bin \
make \
patch \
php-cli \
unzip \
wget \
zip && \
rm -rf /var/lib/apt/lists/*
# Makes wget output shorter and better
ENV WGET_OPTIONS="--progress=bar:force:noscroll"
# Matches Debian default-jdk result, see
# https://packages.debian.org/bookworm/default-jdk
# https://packages.debian.org/bookworm/amd64/openjdk-17-jdk/filelist
# https://packages.debian.org/bookworm/amd64/openjdk-17-jdk-headless/filelist
ENV JAVA_HOME="/usr/lib/jvm/java-17-openjdk-amd64/"
# Various binaries -----------------------------------------------------------
# Notes about "--chmod" for COPY:
# https://blog.vamc19.dev/posts/dockerfile-copy-chmod/
# https://github.com/moby/moby/issues/34819#issuecomment-697130379
COPY --chmod=755 \
bin/PVRTexToolCLI \
bin/repository_cleanup \
bin/gh \
bin/compressonatorcli \
/usr/local/bin/
# Compressonator -------------------------------------------------------------
COPY compressonatorcli /usr/local/compressonatorcli
RUN chmod +x /usr/local/compressonatorcli/compressonatorcli /usr/local/compressonatorcli/compressonatorcli-bin
# Android SDK, NDK -----------------------------------------------------------
# We call thes variables CGE_JENKINS_xxx, to make it clear that CGE *ignores them*,
# they are only useful for Dockerfile and scripts inside this Docker container.
#
# CGE_JENKINS_ANDROID_PLATFORM should correspond to
# DefaultAndroidTargetSdkVersion and DefaultAndroidCompileSdkVersion
# in CGE sources tools/common-code/toolmanifest.pas .
#
# CGE_JENKINS_ANDROID_BUILD_TOOLS should correspond to
# latest revision of build tools. See
# https://developer.android.com/tools/releases/build-tools .
# Note: While releases of build tools have similar version prefix as platform number,
# it seems you should generally just use latest build tools,
# not necessarily the ones matching your platform version.
# So the CGE_JENKINS_ANDROID_BUILD_TOOLS prefix will usually be >
# CGE_JENKINS_ANDROID_PLATFORM , e.g. build tools 34.0.0 for platform 33.
ENV CGE_JENKINS_ANDROID_PLATFORM=33
ENV CGE_JENKINS_ANDROID_BUILD_TOOLS=34.0.0
ENV CGE_JENKINS_ANDROID_NDK_32_PLATFORM=16
ENV CGE_JENKINS_ANDROID_NDK_64_PLATFORM=21
ENV ANDROID_HOME=/usr/local/android/android-sdk/
ENV ANDROID_NDK_HOME=/usr/local/android/android-sdk/ndk-bundle/
# TODO: do we need path to cmdline-tools/latest ? if yes, why not add bin/ subdir?
ENV PATH="${PATH}:/usr/local/android/android-sdk/cmdline-tools/latest/:\
/usr/local/android/android-sdk/platform-tools/:\
/usr/local/android/android-sdk/ndk-bundle/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/:\
/usr/local/android/android-sdk/ndk-bundle/toolchains/aarch64-linux-android-4.9/prebuilt/linux-x86_64/bin/:\
/usr/local/android/android-sdk/ndk-bundle/"
COPY cmdline-tools/ /usr/local/android/android-sdk/cmdline-tools/latest/
# Install Android SDK and NDK.
#
# Note: android-cge-default-platform is used by our fpc.cfg
#
# Note: Relaxed permissions (chmod) in Android SDK, to allow Gradle to auto-install
# additional components, e.g. SDK platforms that are not default in the CGE build tool
# (CastleEngineManifest.xml can specify non-default versions).
#
# Note about mips: This is to woraround
# https://castle-engine.io/android_sdk_and_ndk_troubleshooting#_error_no_toolchains_found_in_the_ndk_toolchains_folder_for_abi_with_prefix_mipsel_linux_android
#
# Note that there's 1 license "January 16, 2019" that seems not available to accept
# before installing. So accept licenses *after* sdkmanager --install too.
RUN ( yes | /usr/local/android/android-sdk/cmdline-tools/latest/bin/sdkmanager --licenses ) && \
/usr/local/android/android-sdk/cmdline-tools/latest/bin/sdkmanager --install \
"platform-tools" \
"platforms;android-${CGE_JENKINS_ANDROID_PLATFORM}" \
"extras;google;google_play_services" \
"build-tools;${CGE_JENKINS_ANDROID_BUILD_TOOLS}" \
"extras;android;m2repository" \
"ndk-bundle" && \
( yes | /usr/local/android/android-sdk/cmdline-tools/latest/bin/sdkmanager --licenses ) && \
ln -s \
/usr/local/android/android-sdk/ndk-bundle/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/lib/arm-linux-androideabi/"${CGE_JENKINS_ANDROID_NDK_32_PLATFORM}" \
/usr/local/android/ndk-libs-for-cge-arm && \
ln -s \
/usr/local/android/android-sdk/ndk-bundle/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/lib/i686-linux-android/"${CGE_JENKINS_ANDROID_NDK_32_PLATFORM}" \
/usr/local/android/ndk-libs-for-cge-i686 && \
ln -s \
/usr/local/android/android-sdk/ndk-bundle/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/lib/aarch64-linux-android/"${CGE_JENKINS_ANDROID_NDK_64_PLATFORM}" \
/usr/local/android/ndk-libs-for-cge-aarch64 && \
ln -s \
/usr/local/android/android-sdk/ndk-bundle/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/lib/x86_64-linux-android/"${CGE_JENKINS_ANDROID_NDK_64_PLATFORM}" \
/usr/local/android/ndk-libs-for-cge-x86_64 && \
echo 'source /usr/local/fpclazarus/bin/setup.sh android-default' > /usr/local/android/setup.sh && \
mkdir -p $ANDROID_NDK_HOME/toolchains/mipsel-linux-android-4.9/prebuilt/linux-x86_64 && \
mkdir -p $ANDROID_NDK_HOME/toolchains/mips64el-linux-android-4.9/prebuilt/linux-x86_64 && \
chmod -R a=rwX /usr/local/android/android-sdk/
# PasDoc ----------------------------------------------------------------------
# This only sets up PasDoc source code.
# We will compile PasDoc later, once we have FPC.
COPY pasdoc/ /usr/local/pasdoc/
ENV PATH="${PATH}:/usr/local/pasdoc/bin/"
# FPC + Lazarus switchable -----------------------------------------------------
# Expect fpclazarus-switchable already downloaded here
# RUN git clone git@gitlab.com:admin-michalis.ii.uni.wroc.pl/fpclazarus-switchable.git
COPY fpclazarus-switchable /usr/local/fpclazarus
# Don't bother with permissions inside Docker container
#RUN chown -R root:staff /usr/local/fpclazarus/ && \
# chmod -R a+rX /usr/local/fpclazarus/
# As of now, this sets up a framework to switch FPC/Lazarus at runtime
# ('source /usr/local/fpclazarus/bin/setup.sh ...')
# but we actually *do not use this framework and each Docker image has
# only a single FPC / Lazarus version*.
# Reasons:
#
# - In most usage cases, the alternative FPC / Lazarus are not necessary.
# For most people, we recommend using latest stable FPC / Lazarus,
# as is recommended by CGE.
#
# - As for 2023-10, GitHub is making more and more "tightnening" of disk
# space and large Docker images are problematic. And the alternative FPC/Lazarus
# versions are responsible for most of our Docker images disk size,
# since each FPC/Lazarus comes with a number of precompiled platforms too
# (we want to precompile for Windows, Linux, Android...).
# So we get disk space errors on GitHub Actions even with 3 FPC/Lazarus versions,
# we also have no hope to support more FPC/Lazarus testable...
#
# Ergo, it is friendlier for disk space on GitHub Actions
# to have separate Docker images with separate FPC/Lazarus versions.
# About Lazarus versions:
# - For latest FPC stable 3.2.2 (used by default, used for official releases)
# we want latest Lazarus stable.
# Note that Lazarus 2.0.12 contains GTK2 fixes for right-clicking after Andrzej fixes.
# Note that Lazarus 3.0 contains IdentComplIncludeKeywords which our latest pasls needs.
# - For oldest FPC still supported by latest CGE (this means FPC 3.2.0 now,
# https://castle-engine.io/supported_compilers.php ) try oldest Lazarus supported.
# To make sure we still compile with older Lazarus versions.
# - For other FPC versions, in general try latest Lazarus version possible that works.
# FPC 3.2.0 ----------------------------------------------------------------------
FROM base-without-fpc AS fpc-3.2.0
RUN /usr/local/fpclazarus/bin/add_new_fpc_version.sh 3.2.0 3.2
# Make the default FPC available without even doing 'source /usr/local/fpclazarus/bin/setup.sh default'.
# These ENV commands simulate what 'source /usr/local/fpclazarus/bin/setup.sh default' does.
ENV FPCLAZARUS_VERSION="3.2.0"
# FPC 3.2.2 ------------------------------------------------------------------------
FROM base-without-fpc AS fpc-3.2.2
RUN /usr/local/fpclazarus/bin/add_new_fpc_version.sh 3.2.2 4.4
ENV FPCLAZARUS_VERSION="3.2.2"
# FPC 3.3.1 ------------------------------------------------------------------
FROM base-without-fpc AS fpc-3.3.1
# FPC/Lazarus latest revisions.
# See
# - https://gitlab.com/freepascal.org/fpc/source
# - https://gitlab.com/freepascal.org/lazarus/lazarus
#
# FPC hash synchronized with castle-fpc script:
# https://github.com/castle-engine/castle-fpc/blob/master/build_fpc#L92C24-L92C64
#
# Lazarus hash: latest on 2026-02-04
# (note: our castle-lazarus doesn't have now "Lazarus unstable" option,
# so nothing to synchronize with there).
RUN /usr/local/fpclazarus/bin/update_latest_fpclazarus.sh bdb427b08454cff85dca2fbaccf7249716962845 9ac18157ff81dcf01b85ae357630788a99a9ecb0
# Make the default FPC available without even doing 'source /usr/local/fpclazarus/bin/setup.sh default'.
# These ENV commands simulate what 'source /usr/local/fpclazarus/bin/setup.sh default' does.
ENV FPCLAZARUS_VERSION="3.3.1"
# ---------------------------------------------------------------------------
# Finish, last FROM ... chooses the FPC version indicated by DOCKER_FPCLAZARUS_VERSION
FROM fpc-${DOCKER_FPCLAZARUS_VERSION} AS fpc-default
RUN /usr/local/fpclazarus/bin/set_default.sh ${FPCLAZARUS_VERSION}
ENV PATH="${PATH}:/usr/local/fpclazarus/${FPCLAZARUS_VERSION}/fpc/bin/"
ENV FPCLAZARUS_REAL_VERSION="${FPCLAZARUS_VERSION}"
ENV FPCDIR="/usr/local/fpclazarus/${FPCLAZARUS_VERSION}/fpc/lib/fpc/${FPCLAZARUS_REAL_VERSION}/"
RUN cd /usr/local/pasdoc/ && make build-fpc-release build-tools
CMD echo 'Docker container with CGE Cloud Builds Tools.' && \
echo 'Default FPC version (can be changed using /usr/local/fpclazarus/bin/setup.sh):' && \
fpc -iV && \
echo 'This is a "no-cge" container, so it contains various prerequisites, but not Castle Game Engine itself!'