diff --git a/Dockerfile b/Dockerfile index 8598d8ccb..f7a399157 100644 --- a/Dockerfile +++ b/Dockerfile @@ -132,6 +132,15 @@ ENV LOGGER_LEVEL="$LOGGER_LEVEL" ENV LC_ALL=en_US.UTF-8 WORKDIR /app + +# Copy and set up entrypoint script for installing extra packages +COPY docker-entrypoint.sh /docker-entrypoint.sh +RUN chmod +x /docker-entrypoint.sh + +# Set entrypoint to handle EXTRA_PACKAGES env var +ENTRYPOINT ["/docker-entrypoint.sh"] + +# Default command (can be overridden in docker-compose.yml) CMD ["python", "./changedetection.py", "-d", "/datastore"] diff --git a/docker-compose.yml b/docker-compose.yml index 9d353dd8e..834ca9c2b 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -16,6 +16,13 @@ services: # Log output levels: TRACE, DEBUG(default), INFO, SUCCESS, WARNING, ERROR, CRITICAL # - LOGGER_LEVEL=TRACE # + # Install additional Python packages (processor plugins, etc.) + # Packages are installed at container startup and cached to avoid reinstalling on every restart + # Example: Install the OSINT reconnaissance processor plugin + # - EXTRA_PACKAGES=changedetection-osint-processor + # Multiple packages can be installed by separating with spaces: + # - EXTRA_PACKAGES=changedetection-osint-processor another-plugin + # # # Uncomment below and the "sockpuppetbrowser" to use a real Chrome browser (It uses the "playwright" protocol) # - PLAYWRIGHT_DRIVER_URL=ws://browser-sockpuppet-chrome:3000 diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh new file mode 100755 index 000000000..ac243289c --- /dev/null +++ b/docker-entrypoint.sh @@ -0,0 +1,28 @@ +#!/bin/bash +set -e + +# Install additional packages from EXTRA_PACKAGES env var +# Uses a marker file to avoid reinstalling on every container restart +INSTALLED_MARKER="/datastore/.extra_packages_installed" +CURRENT_PACKAGES="$EXTRA_PACKAGES" + +if [ -n "$EXTRA_PACKAGES" ]; then + # Check if we need to install/update packages + if [ ! -f "$INSTALLED_MARKER" ] || [ "$(cat $INSTALLED_MARKER 2>/dev/null)" != "$CURRENT_PACKAGES" ]; then + echo "Installing extra packages: $EXTRA_PACKAGES" + pip3 install --no-cache-dir $EXTRA_PACKAGES + + if [ $? -eq 0 ]; then + echo "$CURRENT_PACKAGES" > "$INSTALLED_MARKER" + echo "Extra packages installed successfully" + else + echo "ERROR: Failed to install extra packages" + exit 1 + fi + else + echo "Extra packages already installed: $EXTRA_PACKAGES" + fi +fi + +# Execute the main command +exec "$@"