Skip to content

Commit

Permalink
Remove bundled python dependencies in favour of pip installed ones
Browse files Browse the repository at this point in the history
  • Loading branch information
ostefano committed Aug 6, 2024
1 parent 1a2a515 commit 2f24067
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 2 deletions.
12 changes: 10 additions & 2 deletions core/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ FROM php-base AS python-build
ARG PYPI_MIXBOX_VERSION
ARG PYPI_CYBOX_VERSION
ARG PYPI_PYMISP_VERSION
ARG PYPI_MISP_STIX_VERSION

RUN apt-get install -y --no-install-recommends \
git \
Expand Down Expand Up @@ -129,7 +130,7 @@ EOF
# 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.
set -- "redis" "lief" "pydeep2" "python-magic" "misp-lib-stix2" "maec" "mixbox" "cybox" "pymisp"
set -- "redis" "lief" "pydeep2" "python-magic" "misp-lib-stix2" "maec" "mixbox" "cybox" "pymisp" "misp-stix"
for mod in "$@"; do
mod_version_var=$(echo "PYPI_${mod}_VERSION" | tr '[:lower:]' '[:upper:]' | tr '-' '_')
mod_version=$(eval "echo \"\$$mod_version_var\"")
Expand All @@ -151,11 +152,18 @@ EOF
pip wheel --no-cache-dir -w /wheels/ -r /var/www/MISP/requirements.txt

# Remove files we do not care for
rm -r /var/www/MISP/PyMISP
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 {} +
# Remove libraries' submodules
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
EOF


Expand Down
4 changes: 4 additions & 0 deletions docker-bake.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ variable "PYPI_PYMISP_VERSION" {
default = ""
}

variable "PYPI_MISP_STIX" {
default = ""
}

variable "NAMESPACE" {
default = null
}
Expand Down
1 change: 1 addition & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ services:
- PYPI_MIXBOX_VERSION=${PYPI_MIXBOX_VERSION}
- PYPI_CYBOX_VERSION=${PYPI_CYBOX_VERSION}
- PYPI_PYMISP_VERSION=${PYPI_PYMISP_VERSION}
- PYPI_MISP_STIX_VERSION=${PYPI_MISP_STIX_VERSION}
depends_on:
redis:
condition: service_healthy
Expand Down
1 change: 1 addition & 0 deletions template.env
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ LIBFAUP_COMMIT=3a26d0a
# PYPI_MIXBOX_VERSION="==1.0.*"
# PYPI_CYBOX_VERSION="==2.1.*"
# PYPI_PYMISP_VERSION="==2.4.178"
# PYPI_MISP_STIX_VERSION"==2.4.194"

# CORE_COMMIT takes precedence over CORE_TAG
# CORE_COMMIT=c56d537
Expand Down

0 comments on commit 2f24067

Please sign in to comment.