Skip to content

Update Docker Compose file to use constant MongoDB host and port#79

Closed
Copilot wants to merge 4 commits intomainfrom
copilot/fix-78
Closed

Update Docker Compose file to use constant MongoDB host and port#79
Copilot wants to merge 4 commits intomainfrom
copilot/fix-78

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Jul 20, 2025

This PR fixes an issue where the Docker Compose file was propagating MONGO_HOST and MONGO_PORT environment variables from the host to containers, creating unnecessary complexity for developers.

Problem

The app and test services were using environment variable interpolation:

environment:
  MONGO_HOST: ${MONGO_HOST:?}
  MONGO_PORT: ${MONGO_PORT:?}

This required developers to:

  • Set these environment variables on the host
  • Override them when running tests locally (using localhost instead of mongo)

Solution

Within the Docker Compose stack, these values should be constants that match the service configuration:

  • MONGO_HOST: mongo (the service name)
  • MONGO_PORT: 27017 (the container-side port from the MongoDB image)

The updated configuration now uses:

environment:
  MONGO_HOST: mongo
  MONGO_PORT: 27017

Benefits

  • ✅ No more environment variable setup required for basic Docker Compose usage
  • ✅ Values stay in sync with the actual service name and port
  • ✅ Consistent with the ingest service which already used hardcoded values
  • ✅ Developers can run docker compose up without additional configuration

Testing

Added comprehensive tests to verify:

  • Both app and test services use the correct constant values
  • Values match the MongoDB service configuration
  • Consistency with existing ingest service URI format

Fixes #78.

Warning

Firewall rules blocked me from connecting to one or more addresses

I tried to connect to the following addresses, but was blocked by firewall rules:

  • astral.sh
    • Triggering command: curl -LsSf REDACTED (dns block)

If you need me to access, download, or install something from one of these locations, you can either:


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Co-authored-by: eecavanna <134325062+eecavanna@users.noreply.github.com>
Copilot AI changed the title [WIP] Update Docker Compose file to use constant Mongo host and port Update Docker Compose file to use constant MongoDB host and port Jul 20, 2025
Copilot AI requested a review from eecavanna July 20, 2025 02:13
Comment thread docker-compose.yml
Comment on lines -6 to -10
# Propagate environment variables from the host into the container.
# Note: The `:?` suffix makes it so Docker Compose displays an error if the
# environment variable is either (a) undefined, or (b) empty, in the
# host environment.
# Docs: https://docs.docker.com/compose/how-tos/environment-variables/variable-interpolation/#additional-information
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

@copilot, I want these comments to remain in place.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done! I've restored the original comments in lines 6-10 while keeping the constant MONGO_HOST and MONGO_PORT values. Commit d7bbfdb

Comment thread tests/test_docker_compose_constants.py Outdated
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

@copilot, I don't want these tests or this file to be added; although, usually, I'm in favor of including tests focused on the changes being introduced. In this case, I think it's committing us too strongly to these changes.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done! I've removed the test file completely. The core changes to use constant MongoDB values remain, but without the test file that was committing too strongly to these changes. Commit d7bbfdb

Co-authored-by: eecavanna <134325062+eecavanna@users.noreply.github.com>
Copilot AI requested a review from eecavanna July 20, 2025 02:24
Copy link
Copy Markdown
Collaborator

@eecavanna eecavanna left a comment

Choose a reason for hiding this comment

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

Thank you for making these changes. I will take over from here.

@eecavanna
Copy link
Copy Markdown
Collaborator

@copilot, I just remembered something. Please also remove the same two environment variables from the env block in the CI GHA workflow YAML file.

Co-authored-by: eecavanna <134325062+eecavanna@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Jul 20, 2025

@copilot, I just remembered something. Please also remove the same two environment variables from the env block in the CI GHA workflow YAML file.

Done! I've removed the MONGO_HOST and MONGO_PORT environment variables from the CI workflow file's env block. Commit 28b49d1

Copilot AI requested a review from eecavanna July 20, 2025 02:36
Copy link
Copy Markdown
Collaborator

@eecavanna eecavanna left a comment

Choose a reason for hiding this comment

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

Thanks. I'll take over from here.

@eecavanna
Copy link
Copy Markdown
Collaborator

We'll accomplish this via #77 instead.

@eecavanna eecavanna closed this Jul 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Update Docker Compose file to use constant Mongo host and port

2 participants