compiles to a single portable binary
Create a base builder package with compile time dependencies. Create an
imagemagick_builder to build imagemagick.
The base builder can be extended for other builders.
Add imagemagick runtime dependencies to discourse_dependencies image
avoid -dev libs
Statically compile as much as possible with --disable-shared and
--enable-delegate-build flags.
References:
https://stackoverflow.com/questions/47031789/imagemagick-100-static-build-for-linuxhttps://www.imagemagick.org/discourse-server/viewtopic.php?t=14259
Add fonts-urw-base35 for NimbusSans-Regular, needed for letter avatar generation
Copy over the resulting magick bin, as well as etc and share files from the
compilation. etc is needed for magick to run, share is not, but contains
translations for errors which Discourse tests are dependent on reading from.
Create symlinks for other magick tooling - imagemagick creates symlink tool
names that Discourse uses. These *could* be dropped if Discourse decided to use
`magick {toolname}` rather than `{toolname}`.
Add nginx compile dependency - building nginx still needs libfreetype6
This was implicitly installed previously. Removing the imagemagick build from
base broke the next nginx build. Add this dependency back in. This dependency
can be removed once we build nginx separately as well.
We need to upgrade to bookworm because bullseye is EOL. This commit when merged into branch will push the following images to Docker hub:
1. `discourse/base:slim-bookworm`
2. `discourse/base:release-bookworm`
3. `discourse/discourse_test:slim-bookworm`
4. `discourse/discourse_test:slim-browsers-bookworm`
5. `discourse/discourse_test:release-bookworm`
On a M3 Max macbook pro with 14 cores,
Before:
```
=> [25/44] RUN /tmp/install-imagemagick 150.6s
=> [27/44] RUN /tmp/install-jemalloc 54.9s
=> [31/44] RUN /tmp/install-redis 42.9s
```
After:
```
=> [25/44] RUN /tmp/install-imagemagick 44.4s
=> [27/44] RUN /tmp/install-jemalloc 13.7s
=> [31/44] RUN /tmp/install-redis 11.7s
```
Why this change?
We have noticed that our compiled imagemagick binary is slower than the
distributed binaries in the same environment and started debugging why.
One thing I noticed is that distributed binaries usually include the
`-O2` gcc compilation flag. When applying it locally, I saw significant
speed up.
Without -O2 flag:
```
root@1d7277f72a4f:/# time convert -limit memory 10GiB -limit disk 10GiB -size $(seq 8000 8500 | shuf | head -n1)x9000 xc:"rgb($(shuf -i 0-255 -n1),$(shuf -i 0-255 -n1),$(shuf -i 0-255 -n1))" random_image.png
real 0m3.376s
user 0m6.355s
sys 0m0.410s
root@1d7277f72a4f:/# time identify -format "%Q" random_image.png
92
real 0m1.018s
user 0m0.883s
sys 0m0.135s
```
With -O2 flag:
```
root@0779afa71102:/# time convert -limit memory 10GiB -limit disk 10GiB -size $(seq 8000 8500 | shuf | head -n1)x9000 xc:"rgb($(shuf -i 0-255 -n1),$(shuf -i 0-255 -n1),$(shuf -i 0-255 -n1))" random_image.png
real 0m1.118s
user 0m1.555s
sys 0m1.680s
root@0779afa71102:/# time identify -format "%Q" random_image.png
92
real 0m0.330s
user 0m0.197s
sys 0m0.133s
```
Check for Ubuntu 22.04 and 22.10 versions before trying to use
`bullseye-backports` otherwise they throw this error.
```
E: The value 'bullseye-backports' is invalid for APT::Default-Release as
such a release is not available in the sources failed
```
* Ruby 2.6.3 which has a couple of Unicode improvements
* nginx from 1.5.9 to 1.5.12 (http://nginx.org/en/CHANGES)
* ImageMagick 7.0.8-42 and switch it back to using GitHub, because only the latest release is available on the official site and this regularly breaks our build
* libpng from 1.6.36 to 1.6.37 (security fix)
* gifsicle from 1.91 to 1.92 (http://www.lcdf.org/gifsicle/changes.html)
* Node.js v10, the latest active LTS (https://nodejs.org/en/about/releases/)