Skip to content

Commit 276c5a0

Browse files
committed
Replace Debian with Ubuntu 24.04 LTS
1 parent bbdee36 commit 276c5a0

File tree

6 files changed

+90
-54
lines changed

6 files changed

+90
-54
lines changed

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,14 @@ Notable features:
2727

2828
The underlying spirit of this project is to allow "repeatable deployments", and all pull requests in this direction will be merged post-haste.
2929

30+
## Warning
31+
32+
As part of our recent efforts to reduce the number of CVEs affecting the Docker images, we recently changed the base image from Debian Bookworm to Ubuntu 24.04.
33+
34+
While the transition did not affect MISP and MISP modules, the GitHub Action triggered a bug affecting `libcurl` and Ubuntu 24.04 when running on `linux/arm64` and establishing TLS connections to `api.github.com` when the server decides toreturn a 302. The issue is being discussed here https://github.com/curl/curl/issues/14154 and being further investigated here https://bugs.launchpad.net/ubuntu/+source/curl/+bug/2073448.
35+
36+
To allow the build to complete, we temporarily disabled TLS verification (see `core/Dockerfile` when using `composer` to install PHP dependencies; the temporary workaround affects only the build when the target platform is `linux/arm64`, leaving the `linux/amd64` build unaffected.
37+
3038
## Getting Started
3139

3240
- Copy the `template.env` to `.env`

core/Dockerfile

Lines changed: 68 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
ARG DOCKER_HUB_PROXY=""
22

33

4-
FROM "${DOCKER_HUB_PROXY}python:3.12-slim-bookworm" AS php-base
4+
FROM "${DOCKER_HUB_PROXY}ubuntu:24.04" AS php-base
55
ENV DEBIAN_FRONTEND noninteractive
66

77
# Uncomment when building in corporate environments
@@ -19,29 +19,48 @@ FROM php-base AS composer-build
1919
ENV COMPOSER_ALLOW_SUPERUSER 1
2020
ARG CORE_TAG
2121
ARG CORE_COMMIT
22+
ARG TARGETPLATFORM
2223

2324
RUN apt-get install -y --no-install-recommends \
24-
php8.2 \
25-
php8.2-apcu \
26-
php8.2-curl \
27-
php8.2-xml \
28-
php8.2-intl \
29-
php8.2-bcmath \
30-
php8.2-mbstring \
31-
php8.2-mysql \
32-
php8.2-redis \
33-
php8.2-gd \
34-
php8.2-fpm \
35-
php8.2-zip \
25+
php8.3 \
26+
php8.3-apcu \
27+
php8.3-curl \
28+
php8.3-xml \
29+
php8.3-intl \
30+
php8.3-bcmath \
31+
php8.3-mbstring \
32+
php8.3-mysql \
33+
php8.3-redis \
34+
php8.3-gd \
35+
php8.3-fpm \
36+
php8.3-zip \
3637
unzip \
3738
&& apt-get autoremove -y && apt-get clean -y && rm -rf /var/lib/apt/lists/*
3839

3940
WORKDIR /tmp
4041
RUN curl -o /tmp/composer.json https://raw.githubusercontent.com/MISP/MISP/${CORE_COMMIT:-${CORE_TAG}}/app/composer.json
41-
COPY --from=composer:latest /usr/bin/composer /usr/bin/composer
42-
RUN composer config --no-interaction allow-plugins.composer/installers true
43-
RUN composer install
44-
RUN composer require --with-all-dependencies --no-interaction \
42+
COPY --from=composer:2.7.7 /usr/bin/composer /usr/bin/composer
43+
44+
# See:
45+
# - https://github.com/curl/curl/issues/14154
46+
# - https://bugs.launchpad.net/ubuntu/+source/curl/+bug/2073448
47+
RUN <<-EOF
48+
if [ "$TARGETPLATFORM" = "linux/arm64" ]; then
49+
cp /usr/bin/composer /composer.phar
50+
mkdir /out/
51+
php -r '$phar = new Phar("/composer.phar"); $phar->extractTo("/out/");'
52+
sed -i "/'verify_peer_name' =>.*/a 'verify_peer_status' => CURLOPT_SSL_VERIFYSTATUS," /out/src/Composer/Util/Http/CurlDownloader.php
53+
sed -i "/\$options = StreamContextFactory.*/a \$options['ssl']['verify_peer'] = false;" /out/src/Composer/Util/Http/CurlDownloader.php
54+
sed -i "/\$options = StreamContextFactory.*/a \$options['ssl']['verify_peer_name'] = false;" /out/src/Composer/Util/Http/CurlDownloader.php
55+
sed -i "/\$options = StreamContextFactory.*/a \$options['ssl']['verify_peer_status'] = false;" /out/src/Composer/Util/Http/CurlDownloader.php
56+
rm /usr/bin/composer
57+
ln -s /out/bin/composer /usr/bin/composer
58+
fi
59+
EOF
60+
61+
RUN php /usr/bin/composer config --no-interaction allow-plugins.composer/installers true
62+
RUN php /usr/bin/composer install
63+
RUN php /usr/bin/composer require --with-all-dependencies --no-interaction \
4564
elasticsearch/elasticsearch:^8.7.0 \
4665
jakub-onderka/openid-connect-php:^1.0.0 \
4766
aws/aws-sdk-php
@@ -56,9 +75,9 @@ FROM php-base AS php-build
5675
g++ \
5776
git \
5877
make \
59-
php8.2 \
60-
php8.2-dev \
61-
php8.2-xml \
78+
php8.3 \
79+
php8.3-dev \
80+
php8.3-xml \
6281
php-pear \
6382
libbrotli-dev \
6483
libfuzzy-dev \
@@ -67,9 +86,9 @@ FROM php-base AS php-build
6786
libzstd-dev \
6887
&& apt-get autoremove -y && apt-get clean -y && rm -rf /var/lib/apt/lists/*
6988

70-
RUN update-alternatives --set php /usr/bin/php8.2
71-
RUN update-alternatives --set php-config /usr/bin/php-config8.2
72-
RUN update-alternatives --set phpize /usr/bin/phpize8.2
89+
RUN update-alternatives --set php /usr/bin/php8.3
90+
RUN update-alternatives --set php-config /usr/bin/php-config8.3
91+
RUN update-alternatives --set phpize /usr/bin/phpize8.3
7392

7493
RUN cp "/usr/lib/$(gcc -dumpmachine)"/libfuzzy.* /usr/lib
7594
RUN pecl channel-update pecl.php.net && \
@@ -99,6 +118,8 @@ FROM php-base AS python-build
99118

100119
RUN apt-get install -y --no-install-recommends \
101120
git \
121+
python3-pip \
122+
python3-wheel \
102123
&& apt-get autoremove -y && apt-get clean -y && rm -rf /var/lib/apt/lists/*
103124

104125
# Download MISP using git in the /var/www/ directory. Remove unnecessary items.
@@ -180,25 +201,29 @@ FROM php-base
180201
rsync \
181202
# Include rsyslog to support syslogger
182203
rsyslog \
204+
# Include python management packages
205+
python3-setuptools \
206+
python3-pip \
207+
python3-wheel \
183208
# PHP Requirements
184-
php8.2 \
185-
php8.2-apcu \
186-
php8.2-curl \
187-
php8.2-xml \
188-
php8.2-intl \
189-
php8.2-bcmath \
190-
php8.2-mbstring \
191-
php8.2-mysql \
192-
php8.2-redis \
193-
php8.2-gd \
194-
php8.2-fpm \
195-
php8.2-zip \
196-
php8.2-ldap \
209+
php8.3 \
210+
php8.3-apcu \
211+
php8.3-curl \
212+
php8.3-xml \
213+
php8.3-intl \
214+
php8.3-bcmath \
215+
php8.3-mbstring \
216+
php8.3-mysql \
217+
php8.3-redis \
218+
php8.3-gd \
219+
php8.3-fpm \
220+
php8.3-zip \
221+
php8.3-ldap \
197222
libmagic1 \
198223
libldap-common \
199224
librdkafka1 \
200225
libbrotli1 \
201-
libsimdjson14 \
226+
libsimdjson19 \
202227
libzstd1 \
203228
ssdeep \
204229
libfuzzy2 \
@@ -208,11 +233,11 @@ FROM php-base
208233
curl jq \
209234
&& apt-get autoremove -y && apt-get clean -y && rm -rf /var/lib/apt/lists/*
210235

211-
RUN update-alternatives --set php /usr/bin/php8.2
236+
RUN update-alternatives --set php /usr/bin/php8.3
212237

213238
# Install python modules
214239
COPY --from=python-build /wheels /wheels
215-
RUN pip install --no-cache-dir /wheels/*.whl && rm -rf /wheels
240+
RUN pip install --break-system-packages --no-cache-dir /wheels/*.whl && rm -rf /wheels
216241

217242
# PHP: install prebuilt libraries, then install the app's PHP deps
218243
COPY --from=php-build ["/usr/lib/php/${PHP_VER}/ssdeep.so", "/usr/lib/php/${PHP_VER}/rdkafka.so", "/usr/lib/php/${PHP_VER}/brotli.so", "/usr/lib/php/${PHP_VER}/simdjson.so", "/usr/lib/php/${PHP_VER}/zstd.so", "/usr/lib/php/${PHP_VER}/"]
@@ -224,12 +249,11 @@ FROM php-base
224249
COPY --from=composer-build --chown=www-data:www-data --chmod=0550 /tmp/Plugin /var/www/MISP/app/Plugin
225250

226251
# 'setuptools' is needed at runtime by 'mixbox'
227-
RUN pip install setuptools
228-
RUN cp /usr/local/lib/python3.12/site-packages/setuptools/_distutils/version.py \
229-
/usr/local/lib/python3.12/site-packages/mixbox/distutils_version.py
252+
RUN cp /usr/local/lib/python3.12/dist-packages/setuptools/_distutils/version.py \
253+
/usr/local/lib/python3.12/dist-packages/mixbox/distutils_version.py
230254
RUN sed -i 's/from distutils\.version/from mixbox.distutils_version/' \
231-
/usr/local/lib/python3.12/site-packages/mixbox/parser.py
232-
RUN pip uninstall -y setuptools pip
255+
/usr/local/lib/python3.12/dist-packages/mixbox/parser.py
256+
RUN apt-get remove --purge python3-pip python3-wheel python3-setuptools -y
233257

234258
# Gather these in one layer, only act on actual directories under /etc/php/
235259
RUN <<-EOF

core/files/entrypoint_fpm.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ change_php_vars() {
6565
echo "Configure PHP | Change PHP values ..." && change_php_vars
6666

6767
echo "Configure PHP | Starting PHP FPM"
68-
/usr/sbin/php-fpm8.2 -R -F & master_pid=$!
68+
/usr/sbin/php-fpm8.3 -R -F & master_pid=$!
6969

7070
# Wait for it
7171
wait "$master_pid"

core/files/etc/nginx/includes/misp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ location / {
2222

2323
location ~ ^/[^/]+\.php(/|$) {
2424
include snippets/fastcgi-php.conf;
25-
fastcgi_pass unix:/var/run/php/php8.2-fpm.sock;
25+
fastcgi_pass unix:/var/run/php/php8.3-fpm.sock;
2626
fastcgi_read_timeout 300s;
2727
fastcgi_send_timeout 300s;
2828
fastcgi_connect_timeout 300s;

modules/Dockerfile

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
ARG DOCKER_HUB_PROXY=""
22

3-
FROM "${DOCKER_HUB_PROXY}python:3.12-slim-bookworm" AS python-build
3+
FROM "${DOCKER_HUB_PROXY}ubuntu:24.04" AS python-build
44
ENV DEBIAN_FRONTEND noninteractive
55
ARG MODULES_TAG
66
ARG MODULES_COMMIT
@@ -14,6 +14,9 @@ FROM "${DOCKER_HUB_PROXY}python:3.12-slim-bookworm" AS python-build
1414
ca-certificates \
1515
cmake \
1616
git \
17+
python3-dev \
18+
python3-pip \
19+
python3-wheel \
1720
build-essential \
1821
libpoppler-cpp-dev \
1922
libfuzzy-dev \
@@ -35,8 +38,8 @@ FROM "${DOCKER_HUB_PROXY}python:3.12-slim-bookworm" AS python-build
3538
EOF
3639

3740
WORKDIR /srv/misp-modules
38-
RUN pip install poetry
39-
RUN sed -i "s/^python = .*/python = \"$(python -c 'import platform; print(platform.python_version())')\"/" pyproject.toml
41+
RUN pip install --break-system-packages poetry
42+
RUN sed -i "s/^python = .*/python = \"$(python3 -c 'import platform; print(platform.python_version())')\"/" pyproject.toml
4043
RUN poetry lock
4144
RUN poetry self add poetry-plugin-export
4245
RUN poetry export --with unstable --without-hashes -f requirements.txt -o requirements.txt
@@ -65,7 +68,7 @@ EOF
6568
RUN rm -rf /srv/faup
6669

6770

68-
FROM "${DOCKER_HUB_PROXY}python:3.12-slim-bookworm"
71+
FROM "${DOCKER_HUB_PROXY}ubuntu:24.04"
6972
ENV DEBIAN_FRONTEND noninteractive
7073

7174
RUN apt-get update && apt-get install -y --no-install-recommends \
@@ -78,18 +81,19 @@ FROM "${DOCKER_HUB_PROXY}python:3.12-slim-bookworm"
7881
libxml2 \
7982
libxslt1.1 \
8083
libzbar0 \
84+
python3-pip \
8185
&& apt-get autoremove -y && apt-get clean -y && rm -rf /var/lib/apt/lists/*
8286

8387
COPY --from=python-build /wheels /wheels
8488
COPY --from=python-build /usr/local/lib/libfaupl* /usr/local/lib/
8589
RUN ldconfig
86-
RUN pip install --no-cache-dir --use-deprecated=legacy-resolver /wheels/*.whl && rm -rf /wheels
87-
RUN pip uninstall -y pip
90+
RUN pip install --break-system-packages --no-cache-dir --use-deprecated=legacy-resolver /wheels/*.whl && rm -rf /wheels
91+
RUN apt-get remove --purge python3-pip python3-setuptools -y
8892

8993
# Since we compile faup ourselves and lua is not required anymore, we can load our own library
9094
# and skip the pre-compiled blob to improve compatibility with other architectures like ARM
9195
RUN sed -i s/LoadLibrary\(LOAD_LIB\)/LoadLibrary\(\"\\/usr\\/local\\/lib\\/libfaupl.so\"\)/ \
92-
/usr/local/lib/python3.12/site-packages/pyfaup/__init__.py
96+
/usr/local/lib/python3.12/dist-packages/pyfaup/__init__.py
9397

9498
# Disable (all) warnings raised when using 'future'
9599
RUN sed -i '/import sys/a import warnings\nwarnings.warn = lambda *args, **kwargs: None' \

template.env

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
CORE_TAG=v2.5.7
66
MODULES_TAG=v2.4.199
7-
PHP_VER=20220829
7+
PHP_VER=20230831
88
LIBFAUP_COMMIT=3a26d0a
99

1010
# PYPY_* vars take precedence over MISP's

0 commit comments

Comments
 (0)