2022-09-15 19:35:42 +02:00
|
|
|
ARG DOCKER_HUB_PROXY=""
|
|
|
|
|
2024-07-18 16:36:06 +02:00
|
|
|
|
2024-07-18 16:54:57 +02:00
|
|
|
FROM "${DOCKER_HUB_PROXY}python:3.12-slim-bookworm" AS php-base
|
2024-07-18 16:36:06 +02:00
|
|
|
ENV DEBIAN_FRONTEND noninteractive
|
|
|
|
|
|
|
|
# Uncomment when building in corporate environments
|
|
|
|
# COPY ./rootca.crt /usr/local/share/ca-certificates/rootca.pem
|
|
|
|
# COPY ./rootca.crt /usr/lib/ssl/cert.pem
|
|
|
|
|
|
|
|
RUN apt-get update; apt-get install -y --no-install-recommends \
|
|
|
|
lsb-release \
|
|
|
|
ca-certificates \
|
|
|
|
curl
|
|
|
|
RUN curl -sSLo /tmp/debsuryorg-archive-keyring.deb https://packages.sury.org/debsuryorg-archive-keyring.deb
|
|
|
|
RUN dpkg -i /tmp/debsuryorg-archive-keyring.deb
|
|
|
|
RUN echo "deb [signed-by=/usr/share/keyrings/deb.sury.org-php.gpg] https://packages.sury.org/php/ $(lsb_release -sc) main" > /etc/apt/sources.list.d/php.list
|
|
|
|
RUN apt-get update
|
|
|
|
|
|
|
|
|
2024-07-18 16:54:57 +02:00
|
|
|
FROM php-base AS composer-build
|
2023-06-09 15:42:41 +02:00
|
|
|
ENV DEBIAN_FRONTEND noninteractive
|
2023-06-15 12:43:41 +02:00
|
|
|
ENV COMPOSER_ALLOW_SUPERUSER 1
|
2023-12-08 09:45:49 +01:00
|
|
|
ARG CORE_TAG
|
|
|
|
ARG CORE_COMMIT
|
2023-09-17 13:37:02 +02:00
|
|
|
|
2024-07-18 16:36:06 +02:00
|
|
|
RUN apt-get install -y --no-install-recommends \
|
|
|
|
php7.4 \
|
|
|
|
php7.4-apcu \
|
|
|
|
php7.4-curl \
|
|
|
|
php7.4-xml \
|
|
|
|
php7.4-intl \
|
|
|
|
php7.4-bcmath \
|
|
|
|
php7.4-mbstring \
|
|
|
|
php7.4-mysql \
|
|
|
|
php7.4-redis \
|
|
|
|
php7.4-gd \
|
|
|
|
php7.4-fpm \
|
|
|
|
php7.4-zip \
|
2023-09-15 12:50:30 +02:00
|
|
|
unzip \
|
2023-06-09 15:42:41 +02:00
|
|
|
&& apt-get autoremove -y && apt-get clean -y && rm -rf /var/lib/apt/lists/*
|
2023-09-17 13:37:02 +02:00
|
|
|
|
2023-06-12 10:41:19 +02:00
|
|
|
WORKDIR /tmp
|
2023-12-08 09:45:49 +01:00
|
|
|
ADD https://raw.githubusercontent.com/MISP/MISP/${CORE_COMMIT:-${CORE_TAG}}/app/composer.json /tmp
|
2023-06-15 12:43:41 +02:00
|
|
|
COPY --from=composer:latest /usr/bin/composer /usr/bin/composer
|
|
|
|
RUN composer config --no-interaction allow-plugins.composer/installers true
|
2023-06-09 15:42:41 +02:00
|
|
|
RUN composer install
|
2023-09-15 12:50:30 +02:00
|
|
|
RUN composer require --with-all-dependencies --no-interaction \
|
2024-07-18 16:36:06 +02:00
|
|
|
supervisorphp/supervisor:^4.0 \
|
2024-07-18 16:54:57 +02:00
|
|
|
guzzlehttp/guzzle:^7.4.5 \
|
2024-07-18 16:36:06 +02:00
|
|
|
lstrojny/fxmlrpc \
|
|
|
|
php-http/message \
|
|
|
|
php-http/message-factory \
|
|
|
|
# docker image specific dependencies
|
|
|
|
elasticsearch/elasticsearch:^8.7.0 \
|
|
|
|
jakub-onderka/openid-connect-php:^1.0.0 \
|
|
|
|
aws/aws-sdk-php
|
|
|
|
|
|
|
|
|
2024-07-18 16:54:57 +02:00
|
|
|
FROM php-base AS php-build
|
2023-06-09 15:42:41 +02:00
|
|
|
ENV DEBIAN_FRONTEND noninteractive
|
2023-09-15 12:50:30 +02:00
|
|
|
ENV TZ Etc/UTC
|
2023-09-17 13:37:02 +02:00
|
|
|
|
2024-07-18 16:36:06 +02:00
|
|
|
RUN apt-get install -y --no-install-recommends \
|
2019-11-28 17:33:12 +01:00
|
|
|
gcc \
|
2023-04-13 16:02:02 +02:00
|
|
|
g++ \
|
2019-11-28 17:33:12 +01:00
|
|
|
make \
|
2024-07-18 16:36:06 +02:00
|
|
|
php7.4 \
|
|
|
|
php7.4-dev \
|
|
|
|
php7.4-xml \
|
2024-07-18 16:54:57 +02:00
|
|
|
php-pear \
|
|
|
|
libbrotli-dev \
|
2019-11-28 17:33:12 +01:00
|
|
|
libfuzzy-dev \
|
2021-04-14 14:02:31 +02:00
|
|
|
librdkafka-dev \
|
2023-04-13 16:02:02 +02:00
|
|
|
libsimdjson-dev \
|
2024-03-08 11:43:28 +01:00
|
|
|
libzstd-dev \
|
2019-11-28 17:33:12 +01:00
|
|
|
&& apt-get autoremove -y && apt-get clean -y && rm -rf /var/lib/apt/lists/*
|
2023-09-17 13:37:02 +02:00
|
|
|
|
2024-07-18 16:36:06 +02:00
|
|
|
RUN update-alternatives --set php /usr/bin/php7.4
|
|
|
|
RUN update-alternatives --set php-config /usr/bin/php-config7.4
|
|
|
|
RUN update-alternatives --set phpize /usr/bin/phpize7.4
|
|
|
|
|
|
|
|
RUN cp "/usr/lib/$(gcc -dumpmachine)"/libfuzzy.* /usr/lib
|
|
|
|
RUN pecl channel-update pecl.php.net && \
|
|
|
|
pecl install ssdeep && \
|
|
|
|
pecl install rdkafka && \
|
|
|
|
pecl install simdjson && \
|
2024-07-18 16:54:57 +02:00
|
|
|
pecl install zstd && \
|
|
|
|
pecl install brotli
|
2024-07-18 16:36:06 +02:00
|
|
|
|
2019-11-28 17:33:12 +01:00
|
|
|
|
2024-07-18 16:54:57 +02:00
|
|
|
FROM php-base AS python-build
|
2023-09-17 13:37:02 +02:00
|
|
|
ENV DEBIAN_FRONTEND noninteractive
|
2023-12-08 09:45:49 +01:00
|
|
|
ARG CORE_TAG
|
|
|
|
ARG CORE_COMMIT
|
2023-09-17 13:37:02 +02:00
|
|
|
ARG PYPI_REDIS_VERSION
|
|
|
|
ARG PYPI_LIEF_VERSION
|
|
|
|
ARG PYPI_PYDEEP2_VERSION
|
|
|
|
ARG PYPI_PYTHON_MAGIC_VERSION
|
|
|
|
ARG PYPI_MISP_LIB_STIX2_VERSION
|
|
|
|
ARG PYPI_MAEC_VERSION
|
|
|
|
ARG PYPI_MIXBOX_VERSION
|
|
|
|
ARG PYPI_CYBOX_VERSION
|
|
|
|
ARG PYPI_PYMISP_VERSION
|
2024-08-06 13:37:15 +02:00
|
|
|
ARG PYPI_MISP_STIX_VERSION
|
2023-09-17 13:37:02 +02:00
|
|
|
|
2024-07-18 16:36:06 +02:00
|
|
|
RUN apt-get install -y --no-install-recommends \
|
2023-09-17 13:37:02 +02:00
|
|
|
git \
|
|
|
|
&& apt-get autoremove -y && apt-get clean -y && rm -rf /var/lib/apt/lists/*
|
2024-07-18 16:54:57 +02:00
|
|
|
|
2023-09-15 12:50:30 +02:00
|
|
|
# Download MISP using git in the /var/www/ directory. Remove unnecessary items.
|
|
|
|
RUN <<-EOF
|
2023-12-08 09:45:49 +01:00
|
|
|
if [ ! -z "${CORE_COMMIT}" ]; then
|
|
|
|
git clone https://github.com/MISP/MISP.git /var/www/MISP && cd /var/www/MISP && git checkout "${CORE_COMMIT}"
|
2023-09-15 12:50:30 +02:00
|
|
|
else
|
2023-12-08 09:45:49 +01:00
|
|
|
git clone --branch "${CORE_TAG}" --depth 1 https://github.com/MISP/MISP.git /var/www/MISP
|
2023-09-15 12:50:30 +02:00
|
|
|
fi
|
|
|
|
cd /var/www/MISP || exit; git submodule update --init --recursive .
|
|
|
|
EOF
|
|
|
|
|
|
|
|
RUN <<-EOF
|
|
|
|
mkdir /wheels
|
|
|
|
|
|
|
|
# Add additional dependencies (container specific)
|
|
|
|
# The "set" line contains the list of modules we want to ensure are present.
|
|
|
|
# PYPI_MODULE_NAME_VERSION env vars can be set to specify the version desired,
|
|
|
|
# e.g. PYPI_SURICATA_VERSION="==2.0" to specify exactly version 2.0 for the suricata package
|
|
|
|
#
|
|
|
|
# 1. Check for presence of each module in requirements.txt
|
|
|
|
# 2. If missing, add it (with optional version from env (defaults to empty string))
|
|
|
|
# 3. If present, replace with our specified version if it exists, otherwise leave
|
|
|
|
# the upstream version alone.
|
2024-08-06 13:37:15 +02:00
|
|
|
set -- "redis" "lief" "pydeep2" "python-magic" "misp-lib-stix2" "maec" "mixbox" "cybox" "pymisp" "misp-stix"
|
2023-09-15 12:50:30 +02:00
|
|
|
for mod in "$@"; do
|
|
|
|
mod_version_var=$(echo "PYPI_${mod}_VERSION" | tr '[:lower:]' '[:upper:]' | tr '-' '_')
|
|
|
|
mod_version=$(eval "echo \"\$$mod_version_var\"")
|
|
|
|
grep -q ${mod} /var/www/MISP/requirements.txt
|
|
|
|
exists=$?
|
|
|
|
if [ "${exists}" -eq "1" ]; then
|
|
|
|
echo "Adding missing module ${mod} with version '${mod_version}'"
|
|
|
|
echo ${mod}${mod_version} >> /var/www/MISP/requirements.txt
|
|
|
|
else
|
|
|
|
if [ "$(echo ${mod_version} | wc -m)" -gt 1 ]; then
|
|
|
|
echo "Overwriting existing module ${mod}, version '${mod_version}'"
|
|
|
|
sed -i "/${mod}/s/.*/${mod}${mod_version}/" /var/www/MISP/requirements.txt
|
|
|
|
else
|
|
|
|
echo "Skipping overwriting ${mod} due to missing version variable"
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
done;
|
|
|
|
|
2024-07-18 16:36:06 +02:00
|
|
|
pip wheel --no-cache-dir -w /wheels/ -r /var/www/MISP/requirements.txt
|
2024-07-19 12:30:36 +02:00
|
|
|
|
2023-09-15 12:50:30 +02:00
|
|
|
# Remove files we do not care for
|
|
|
|
find /var/www/MISP/INSTALL/* ! -name 'MYSQL.sql' -type f -exec rm {} +
|
|
|
|
find /var/www/MISP/INSTALL/* ! -name 'MYSQL.sql' -type l -exec rm {} +
|
|
|
|
# Remove most files in .git - we do not use git functionality in docker
|
|
|
|
find /var/www/MISP/.git/* ! -name HEAD -exec rm -rf {} +
|
2024-08-13 15:23:29 +02:00
|
|
|
# Remove libraries submodules
|
2024-08-06 13:37:15 +02:00
|
|
|
rm -r /var/www/MISP/PyMISP
|
|
|
|
rm -r /var/www/MISP/app/files/scripts/cti-python-stix2
|
|
|
|
rm -r /var/www/MISP/app/files/scripts/misp-stix
|
|
|
|
rm -r /var/www/MISP/app/files/scripts/mixbox
|
|
|
|
rm -r /var/www/MISP/app/files/scripts/python-cybox
|
|
|
|
rm -r /var/www/MISP/app/files/scripts/python-maec
|
|
|
|
rm -r /var/www/MISP/app/files/scripts/python-stix
|
2023-09-15 12:50:30 +02:00
|
|
|
EOF
|
2021-02-16 23:37:51 +01:00
|
|
|
|
2024-07-18 16:36:06 +02:00
|
|
|
|
|
|
|
FROM php-base
|
2023-05-16 16:26:20 +02:00
|
|
|
ENV DEBIAN_FRONTEND noninteractive
|
2023-12-08 09:45:49 +01:00
|
|
|
ARG CORE_TAG
|
|
|
|
ARG CORE_COMMIT
|
2023-05-16 16:26:20 +02:00
|
|
|
ARG PHP_VER
|
2023-09-17 13:37:02 +02:00
|
|
|
|
2024-07-18 16:36:06 +02:00
|
|
|
RUN apt-get install -y --no-install-recommends \
|
2024-06-06 10:30:12 +02:00
|
|
|
gettext \
|
2020-02-25 02:14:47 +01:00
|
|
|
procps \
|
2019-11-25 22:58:18 +01:00
|
|
|
sudo \
|
2020-02-20 02:21:49 +01:00
|
|
|
nginx \
|
2019-11-25 22:58:18 +01:00
|
|
|
supervisor \
|
2019-11-26 22:18:52 +01:00
|
|
|
cron \
|
2019-11-25 22:58:18 +01:00
|
|
|
openssl \
|
2023-09-15 12:50:30 +02:00
|
|
|
gpg \
|
|
|
|
gpg-agent \
|
2019-11-28 17:48:44 +01:00
|
|
|
mariadb-client \
|
2020-05-29 01:49:27 +02:00
|
|
|
rsync \
|
2019-11-28 17:48:44 +01:00
|
|
|
# PHP Requirements
|
2024-07-18 16:36:06 +02:00
|
|
|
php7.4 \
|
|
|
|
php7.4-apcu \
|
|
|
|
php7.4-curl \
|
|
|
|
php7.4-xml \
|
|
|
|
php7.4-intl \
|
|
|
|
php7.4-bcmath \
|
|
|
|
php7.4-mbstring \
|
|
|
|
php7.4-mysql \
|
|
|
|
php7.4-redis \
|
|
|
|
php7.4-gd \
|
|
|
|
php7.4-fpm \
|
|
|
|
php7.4-zip \
|
|
|
|
php7.4-ldap \
|
|
|
|
libmagic1 \
|
2024-02-21 18:04:41 +01:00
|
|
|
libldap-common \
|
2021-04-14 14:06:54 +02:00
|
|
|
librdkafka1 \
|
2021-04-14 14:13:37 +02:00
|
|
|
libbrotli1 \
|
2024-07-18 16:36:06 +02:00
|
|
|
libsimdjson14 \
|
2024-03-08 11:43:28 +01:00
|
|
|
libzstd1 \
|
2024-07-18 16:36:06 +02:00
|
|
|
ssdeep \
|
|
|
|
libfuzzy2 \
|
2019-11-28 17:48:44 +01:00
|
|
|
# Unsure we need these
|
|
|
|
zip unzip \
|
2022-11-04 18:22:12 +01:00
|
|
|
# Require for advanced an unattended configuration
|
|
|
|
curl jq \
|
2020-05-18 15:22:41 +02:00
|
|
|
&& apt-get autoremove -y && apt-get clean -y && rm -rf /var/lib/apt/lists/*
|
2019-11-25 22:58:18 +01:00
|
|
|
|
2024-07-18 16:36:06 +02:00
|
|
|
RUN update-alternatives --set php /usr/bin/php7.4
|
|
|
|
|
2023-09-15 12:50:30 +02:00
|
|
|
# Install python modules
|
2019-12-11 15:09:57 +01:00
|
|
|
COPY --from=python-build /wheels /wheels
|
2024-07-18 16:36:06 +02:00
|
|
|
RUN pip install --no-cache-dir /wheels/*.whl && rm -rf /wheels
|
2019-11-25 22:58:18 +01:00
|
|
|
|
2023-06-12 10:41:19 +02:00
|
|
|
# PHP: install prebuilt libraries, then install the app's PHP deps
|
2024-03-08 11:43:28 +01:00
|
|
|
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}/"]
|
2021-04-14 14:02:31 +02:00
|
|
|
|
2023-06-02 14:44:23 +02:00
|
|
|
# Do an early chown to limit image size
|
2023-09-15 12:50:30 +02:00
|
|
|
COPY --from=python-build --chown=www-data:www-data --chmod=0550 /var/www/MISP /var/www/MISP
|
2024-07-19 17:43:15 +02:00
|
|
|
COPY --from=composer-build --chown=www-data:www-data --chmod=0550 /tmp/composer.lock /var/www/MISP/app/composer.lock
|
2023-09-15 12:50:30 +02:00
|
|
|
COPY --from=composer-build --chown=www-data:www-data --chmod=0550 /tmp/Vendor /var/www/MISP/app/Vendor
|
|
|
|
COPY --from=composer-build --chown=www-data:www-data --chmod=0550 /tmp/Plugin /var/www/MISP/app/Plugin
|
|
|
|
|
2024-09-16 10:58:10 +02:00
|
|
|
# 'setuptools' is needed at runtime by 'mixbox'
|
|
|
|
RUN pip install setuptools
|
|
|
|
RUN cp /usr/local/lib/python3.12/site-packages/setuptools/_distutils/version.py \
|
2024-09-08 12:05:24 +02:00
|
|
|
/usr/local/lib/python3.12/site-packages/mixbox/distutils_version.py
|
|
|
|
RUN sed -i 's/from distutils\.version/from mixbox.distutils_version/' \
|
|
|
|
/usr/local/lib/python3.12/site-packages/mixbox/parser.py
|
2024-09-16 10:58:10 +02:00
|
|
|
RUN pip uninstall -y setuptools pip
|
2024-09-08 12:05:24 +02:00
|
|
|
|
2023-09-15 12:50:30 +02:00
|
|
|
# Gather these in one layer, only act on actual directories under /etc/php/
|
|
|
|
RUN <<-EOF
|
2024-03-08 11:43:28 +01:00
|
|
|
set -- "ssdeep" "rdkafka" "brotli" "simdjson" "zstd"
|
2023-09-15 12:50:30 +02:00
|
|
|
for mod in "$@"; do
|
|
|
|
for dir in /etc/php/*/; do
|
|
|
|
echo "extension=${mod}.so" > "${dir}mods-available/${mod}.ini"
|
|
|
|
done;
|
|
|
|
phpenmod "${mod}"
|
|
|
|
done;
|
|
|
|
phpenmod redis
|
|
|
|
EOF
|
2019-11-25 22:58:18 +01:00
|
|
|
|
2023-05-16 16:26:20 +02:00
|
|
|
# nginx
|
2024-07-18 16:36:06 +02:00
|
|
|
RUN rm /etc/nginx/sites-enabled/*; mkdir -p /run/php /etc/nginx/certs
|
2019-11-25 22:58:18 +01:00
|
|
|
|
2023-06-02 14:44:23 +02:00
|
|
|
# Make a copy of the file and configuration stores, so we can sync from it
|
|
|
|
|
2023-09-15 12:50:30 +02:00
|
|
|
# The spirit of the upstream dockerization is to make:
|
2023-06-02 14:44:23 +02:00
|
|
|
# 1) User and group aligned in terms of permissions
|
|
|
|
# 2) Files executable and read only, because of some rogue scripts like 'cake'
|
2023-09-15 12:50:30 +02:00
|
|
|
# 3) Directories writable, because sometimes MISP add new files
|
|
|
|
|
|
|
|
RUN <<-EOF
|
|
|
|
cp -R /var/www/MISP/app/files /var/www/MISP/app/files.dist
|
|
|
|
cp -R /var/www/MISP/app/Config /var/www/MISP/app/Config.dist
|
|
|
|
find /var/www/MISP \( ! -user www-data -or ! -group www-data \) -exec chown www-data:www-data '{}' +;
|
|
|
|
find /var/www/MISP -not -perm 550 -type f -exec chmod 0550 '{}' +;
|
2023-06-02 14:44:23 +02:00
|
|
|
find /var/www/MISP -not -perm 770 -type d -exec chmod 0770 '{}' +;
|
2023-09-15 12:50:30 +02:00
|
|
|
# Diagnostics wants this file to be present and writable even if we do not use git in docker land
|
|
|
|
touch /var/www/MISP/.git/ORIG_HEAD && chmod 0600 /var/www/MISP/.git/ORIG_HEAD && chown www-data:www-data /var/www/MISP/.git/ORIG_HEAD
|
|
|
|
EOF
|
2023-04-13 16:02:02 +02:00
|
|
|
|
2023-09-15 12:50:30 +02:00
|
|
|
# Copy all our image specific files to appropriate locations
|
|
|
|
COPY files/ /
|
2019-11-25 22:58:18 +01:00
|
|
|
ENTRYPOINT [ "/entrypoint.sh" ]
|
|
|
|
|
2023-05-16 16:26:20 +02:00
|
|
|
# Change Workdirectory
|
2019-11-26 01:23:59 +01:00
|
|
|
WORKDIR /var/www/MISP
|