Skip to content

Conversation

@ktyagiapphelix2u
Copy link
Contributor

@ktyagiapphelix2u ktyagiapphelix2u commented Jul 31, 2025

Description

This PR adds dynamic port for LEARNING MFE in form of ENV variable

  • It will update all MFE related files dynamically
  • It will update python configuraiton files by referencing ENV variable

It is done in this manner so that by just changing the value here, it will update all required frontend-repositories.
And take the value dynamically.

Jira Link

[BOMS-27]

Document Link

Confluence Link

@mraman-2U mraman-2U requested a review from Copilot July 31, 2025 09:23
Copy link
Contributor

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 introduces dynamic port configuration for the LEARNING MFE (Micro Frontend) by replacing hardcoded port 2000 with environment variables that default to port 2010.

  • Updates environment variable references across Python configuration files and Docker Compose
  • Adds script to dynamically update .env.development files for all frontend applications
  • Modifies devcontainer configuration to use the new port and environment variables

Reviewed Changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
py_configuration_files/lms.py Updates CORS origins and microfrontend URL to use environment variable
py_configuration_files/enterprise_subsidy.py Changes frontend app learning URL to use environment variable
py_configuration_files/ecommerce.py Updates CORS origins with environment variable for learning MFE
py_configuration_files/course_discovery.py Updates CORS allowed origins to use environment variable
docker-compose.yml Makes port mapping dynamic using environment variables
.devcontainer/updateContentCommand.sh Adds script to update MFE .env.development files with new port configuration
.devcontainer/devcontainer.json Updates container environment and port forwarding configuration
Comments suppressed due to low confidence (1)

'localhost:18400', # frontend-app-publisher
'localhost:1993', # frontend-app-ora-grading
'localhost:1996', # frontend-app-learner-dashboard
LEARNING_MICROFRONTEND_NETLOC, # frontend-app-learning
Copy link

Copilot AI Jul 31, 2025

Choose a reason for hiding this comment

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

The variable LEARNING_MICROFRONTEND_NETLOC is used but not defined in this file. This will cause a NameError when the code runs.

Copilot uses AI. Check for mistakes.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Resolved

ENTERPRISE_CATALOG_URL = 'http://edx.devstack.enterprise-catalog:18160'
ENTERPRISE_SUBSIDY_URL = 'http://localhost:18280'
FRONTEND_APP_LEARNING_URL = 'http://localhost:2000'
FRONTEND_APP_LEARNING_URL = os.environ.get('LEARNING_MICROFRONTEND_URL', 'http://localhost:2010')
Copy link

Copilot AI Jul 31, 2025

Choose a reason for hiding this comment

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

The os module is used but not imported. Add 'import os' at the top of the file to avoid a NameError.

Copilot uses AI. Check for mistakes.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Resolved

echo "Updating .env.development files for MFE apps..."

# Define shared values
PORT=${LEARNING_MICROFRONTEND_PORT:-2000}
Copy link

Copilot AI Jul 31, 2025

Choose a reason for hiding this comment

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

The default port value 2000 is inconsistent with the new default port 2010 used elsewhere in the codebase. This should be 2010 for consistency.

Suggested change
PORT=${LEARNING_MICROFRONTEND_PORT:-2000}
PORT=${LEARNING_MICROFRONTEND_PORT:-2010}

Copilot uses AI. Check for mistakes.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Resolved

PORT=${LEARNING_MICROFRONTEND_PORT:-2000}
BASE_URL=${LEARNING_MICROFRONTEND_URL:-"http://localhost:$PORT"}

# Path to workspace
Copy link

Copilot AI Jul 31, 2025

Choose a reason for hiding this comment

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

This comment appears incomplete and doesn't describe any actual code. It should either be completed or removed.

Suggested change
# Path to workspace
# (Line removed)

Copilot uses AI. Check for mistakes.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Resolved

@ktyagiapphelix2u ktyagiapphelix2u removed the request for review from nsprenkle July 31, 2025 09:31
@ktyagiapphelix2u ktyagiapphelix2u force-pushed the ktyagi/BOMS-27 branch 2 times, most recently from 5ba9d6e to e5afcb1 Compare August 4, 2025 06:52
@ktyagiapphelix2u ktyagiapphelix2u changed the title Dynamic port for LEARNING MFE in form of ENV variable fix: Dynamic port for LEARNING MFE in form of ENV variable Aug 4, 2025
fixing the dynamic port for leaning mfe as for overiding the 2000 port to 2010 for all the mfe repos
@ktyagiapphelix2u ktyagiapphelix2u marked this pull request as ready for review August 4, 2025 15:04
Copy link
Member

@nsprenkle nsprenkle left a comment

Choose a reason for hiding this comment

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

NIce! I have some open questions that I think should be called out in documentation for clarity, if they aren't already. If they are, could you please point me to them?

  1. Where do I override this port if I want to set it to something other than 2010?
  2. Do I have to manually run the update command to propagate all those port changes, or does this happen automatically every dev.up?

@ktyagiapphelix2u
Copy link
Contributor Author

  1. The source of truth is the LEARNING_MICROFRONTEND_PORT environment variable in devcontainer.json. To change it from 2010 to another value:
"containerEnv": {
    "DEVSTACK_WORKSPACE": "/workspaces/edx-repos",
    "LEARNING_MICROFRONTEND_PORT": "2000"  // Change this value to your desired port
},

You'll also need to update the corresponding entry in the forwardPorts array and portsAttributes section to match your new port.

  1. The updateContentCommand runs automatically in these scenarios:

When the dev container is first created (postCreateCommand)
When you rebuild the container
When the [devcontainer.json] configuration changes

However, if you change the port in an existing running container, you'll need to either:

Rebuild the dev container (recommended - ensures all changes are applied)
Manually run [updateContentCommand.sh] to propagate the port changes to all the .env.development files
The manual approach would be:

./.devcontainer/updateContentCommand.sh

@ktyagiapphelix2u ktyagiapphelix2u merged commit 37825d5 into master Aug 12, 2025
19 checks passed
@ktyagiapphelix2u ktyagiapphelix2u deleted the ktyagi/BOMS-27 branch August 12, 2025 08:29
@ktyagiapphelix2u
Copy link
Contributor Author

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.

3 participants