This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
Objectivity and Honesty: Never tell me what I want to hear. I want you to look at things objectively, contradict me when needed. If you think otherwise, go with your strong opinion.
Security and Best Practices: You are a senior software developer with DevOps and security experience. Apply these principles:
- Never log or expose secrets: Always mask private or sensitive data (API keys, tokens, credentials, internal URLs)
- Public Repository Awareness: Assume this repository is publicly accessible. Never commit sensitive information or suggest solutions that expose internal systems
- SOLID Principles: Keep methods and classes focused and maintainable. Avoid very long and complex methods/classes when they can be split based on SOLID principles
- Code Reuse: Define global variables when needed and extract reusable functions to avoid duplication
- Validation First: Always validate inputs, especially in scripts that modify files or deploy infrastructure
This repository contains Docker base images for Mend.io products (controller, scanner, remediate services). These base images are published to Docker Hub and contain only open-source tools, no proprietary Mend logic. The images are built from upstream Mend product Dockerfiles that are truncated at a marker comment # END OF BASE IMAGE.
- Extract Base Images: Source Dockerfiles from
tmp/agent-4-github-enterprise-{VERSION}/are truncated at the# END OF BASE IMAGEmarker to create base images - Apply Modifications: Configuration-driven modifications are applied to Dockerfiles via
config/*-modifications.txtfiles - Build: Docker images are built with multiple language runtime versions (Java 8/11/17/21, Python 2.7/3.6-3.13, Node 24, etc.)
- Validate: Automated validation ensures modifications were applied correctly
- Publish: Images are pushed to Docker Hub (Mend Hub) or ECR
repo-integrations/: Contains generated Dockerfiles for each servicecontroller/Dockerfile: Controller service base imagescanner/Dockerfile: SCA scanner base imagescanner/Dockerfile.full: Full SCA scanner with all toolsscanner/DockerfileSast: SAST scanner base imageremediate/Dockerfile: Remediate service base image
bin/: Shell scripts for the build/publish pipelineconfig/: Modification configuration files for customizing Dockerfiles
The repository uses a custom modification system to customize Dockerfiles:
Configuration Files (config/*-modifications.txt):
- Format:
ACTION:PATTERN:REPLACEMENT - Actions:
COMMENT: Comment out single lines matching patternCOMMENT_PAIR: Comment out a matched line and the immediately following non-empty line, only when both match their respective patterns (format:COMMENT_PAIR:pattern1:pattern2). Use forARG + RUNversion pairs.COMMENT_BLOCK: Comment out entire multi-line RUN blocks (searches for pattern in comments or RUN commands)REMOVE: Delete lines matching patternREPLACE: Replace entire line with new contentADD_AFTER: Insert line after matching patternADD_BEFORE: Insert line before matching pattern
Example from config/scanner-modifications.txt:
COMMENT_BLOCK:Install Mono
COMMENT_BLOCK:Install Nuget CLI
COMMENT:apt-get install.*nuget
Base images use containerbase for consistent tool installation:
ARG TOOL_VERSION=x.y.z
RUN install-tool toolnameMultiple versions can be installed; the last one becomes the default. See repo-integrations/scanner/Dockerfile for examples with Java, Python, Gradle, etc.
# Build all images with a version tag and registry prefix
./bin/build.sh <VERSION> <REGISTRY_PREFIX> [COPY_VERSIONS_JSON]
# Example for ECR testing
./bin/build.sh 25.10.1 054331651301.dkr.ecr.us-east-1.amazonaws.com# Extract base images from upstream Mend product releases
./bin/copy.sh <VERSION> [COPY_VERSIONS_JSON]
# Example
./bin/copy.sh 25.10.1 trueThis script:
- Extracts Dockerfiles from
tmp/agent-4-github-enterprise-{VERSION}/ - Truncates at
# END OF BASE IMAGEmarker - Applies modifications from
config/*-modifications.txt - Optionally appends version scanning script support
# Apply modifications to a Dockerfile using a config file
./bin/modify-dockerfile.sh <DOCKERFILE> <CONFIG_FILE>
# Example
./bin/modify-dockerfile.sh repo-integrations/scanner/Dockerfile config/scanner-modifications.txt# Validate that all modifications were applied correctly
./bin/validate-modifications.shThis checks each Dockerfile against its configuration to ensure:
- Patterns marked for COMMENT/COMMENT_BLOCK are commented
- Patterns marked for REMOVE are removed
- Patterns marked for REPLACE were replaced
# Test COMMENT_BLOCK functionality on mono installation
./test-mono-comment-block.sh# Generate JSON of installed tool versions from a Dockerfile
./generate_versions_json.sh <DOCKERFILE_PATH>Outputs JSON mapping tool names to their installed versions.
# Publish to Docker Hub (production)
./bin/prod-publish.sh <VERSION>
# Publish to Mend Hub
./bin/publish-to-mend-hub.sh <VERSION># Download images from ECR
./bin/download-ecr-images.sh <VERSION> <ECR_REGISTRY>
# Tag ECR images for Mend Hub
./bin/tag-ecr-images.sh <VERSION> <ECR_REGISTRY>Workflow: prod-from-version-build-push-tag-base-image.yaml
- Triggered manually with version input
- Downloads pre-built images from ECR
- Tags and publishes to Mend Hub (Docker Hub)
- Optionally merges release branch to main
Workflow: stg-from-version-build-push-tag-base-image.yaml
- Similar to production but for staging environment
- Base Image Marker: All source Dockerfiles must have
# END OF BASE IMAGEcomment to mark truncation point - Open Source Only: Base images must contain only open-source tools, no proprietary Mend code
- Tool Versions: Last installed version of a tool becomes the default (e.g., Java 17 is default because it's installed last)
- CVE Annotations: Dockerfiles contain CVE comment blocks documenting known vulnerabilities in specific versions
- Modification Validation: All modifications must pass validation checks before images can be published
When adding or updating tools:
- Modify source Dockerfiles in
repo-integrations/directly, OR - Update
config/*-modifications.txtto apply transformations - Run
./bin/validate-modifications.shto ensure changes are correct - Test locally with
./bin/build.sh - Use GitHub Actions for official releases
- The repository uses Renovate for automated dependency updates (see
renovate:comments in Dockerfiles) containerbaseprovides theinstall-toolcommand and user/directory setup- Environment variables like
MEND_JAVApoint to specific tool versions for Mend products - The
generate_versions_json.shscript creates metadata about installed tools for runtime discovery