Skip to content

[mongodb] Fix docker builds by removing apt-get and improving healthchecks#17507

Merged
shmsr merged 4 commits intoelastic:mainfrom
shmsr:fix-mongo-docker-issue
Feb 23, 2026
Merged

[mongodb] Fix docker builds by removing apt-get and improving healthchecks#17507
shmsr merged 4 commits intoelastic:mainfrom
shmsr:fix-mongo-docker-issue

Conversation

@shmsr
Copy link
Member

@shmsr shmsr commented Feb 22, 2026

Proposed commit message

This PR fixes broken docker builds and improves the overall setup for the mongodb package.

Key improvements:

  • Fix GPG key expiration: We completely bypass the expired mongodb-org.list GPG key issue by removing the apt-get update step altogether. (bugfix, that caused CI failures)
  • Improved Healthcheck: Instead of relying on netcat-openbsd to check if the TCP port is listening, we now use the native mongo (or mongosh) client to run a ping command. This ensures the database is fully ready to accept queries, not just that the port is open.
  • Faster Builds: By eliminating the apt-get dependency installations, the docker image builds instantaneously.
  • Consolidate Dockerfiles: The duplicate creator/Dockerfile was removed. Both mongodb and mongodb-log services now use the single Dockerfile at the root.
  • Docker Compose cleanup: Removed the deprecated version: '2.3' attribute and implemented YAML anchors (x-mongodb-base) to reuse the common build config between mongodb and mongodb-log services.
  • Default log directory fallback: Defined a fallback directory ./logs for the SERVICE_LOGS_DIR volume mount, preventing the "blank string" warning and broken mounts when the variable isn't explicitly set.

Checklist

  • I have reviewed tips for building integrations and this pull request is aligned with them.
  • I have verified that all data streams collect metrics or logs.
  • I have added an entry to my package's changelog.yml file.
  • I have verified that Kibana version constraints are current according to guidelines.
  • I have verified that any added dashboard complies with Kibana's Dashboard good practices

Related issues

@shmsr shmsr requested a review from a team as a code owner February 22, 2026 21:31
@shmsr shmsr self-assigned this Feb 22, 2026
@shmsr shmsr requested a review from Copilot February 22, 2026 21:31
@shmsr shmsr added the bugfix Pull request that fixes a bug issue label Feb 22, 2026
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes Docker image build failures in the MongoDB integration's test infrastructure caused by an expired GPG key in the mongodb-org.list repository file. The fix removes the problematic repository list file before running apt update and package installation.

Changes:

  • Removes the mongodb-org.list file (which contains an expired GPG key) instead of just removing jessie-updates from sources.list
  • Updates package installation to use netcat-openbsd instead of netcat
  • Combines the removal and installation steps into a single RUN command for better Docker layer caching
Comments suppressed due to low confidence (1)

packages/mongodb/_dev/deploy/docker/Dockerfile:6

  • The command should follow standard Dockerfile practices: use 'apt-get' instead of 'apt' for better stability in scripts, and use the '-y' flag instead of piping 'yes'. The recommended command would be: 'apt-get update && apt-get install -y netcat-openbsd'. The 'apt' command is meant for interactive use, while 'apt-get' is more stable for scripting contexts like Dockerfiles.
    apt update && \
    yes | apt install netcat-openbsd

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

shmsr and others added 2 commits February 23, 2026 03:06
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…ealthchecks

- The previous `apt-get update` was failing on old `mongo:5.0` images due to expired `mongodb-org.list` GPG keys.
- By switching from `netcat` to native `mongo/mongosh` ping commands for the `HEALTHCHECK`, we no longer need to install `netcat-openbsd`.
- This allows us to completely remove the `apt-get` installation step, which naturally avoids the expired GPG key issue altogether and dramatically speeds up image build times.
- Furthermore, the `mongo/mongosh` healthcheck is much more robust as it guarantees the database is ready to accept queries, not just that the TCP port is listening.
- Removes duplicate `creator/Dockerfile` and consolidates build configuration inside a single base `Dockerfile`.
- Removes obsolete `version: '2.3'` from `docker-compose.yml` and uses YAML anchors (`x-mongodb-base`) for DRY configuration.
- Adds default fallback volume path `./logs` for `SERVICE_LOGS_DIR`.
@shmsr shmsr changed the title mongodb: Fix docker image building step [mongodb] Fix docker builds by removing apt-get and improving healthchecks Feb 23, 2026
@shmsr shmsr added the enhancement New feature or request label Feb 23, 2026
@elastic-vault-github-plugin-prod

🚀 Benchmarks report

To see the full report comment with /test benchmark fullreport

@elasticmachine
Copy link

💚 Build Succeeded

History

cc @shmsr

Copy link
Contributor

@mykola-elastic mykola-elastic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Backport to all active?

@shmsr
Copy link
Member Author

shmsr commented Feb 23, 2026

LGTM

Backport to all active?

This is integrations 😅

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment