Running Multiple Local Apps Simultaneously
You can include multiple custom apps in your docker-compose.yaml and run them simultaneously. For each app, follow the steps outlined in the hot reloading guide.
Note that each app needs to run on a unique port. Make sure the target port specified in the app’s PROXY_CONFIG is different for every app.
For each port that is used by an application, you need to add a corresponding entry in the ./init-data/traefik/traefik-services.yml file within your onecx-local-env. This ensures that Traefik can route requests to the correct application based on the port.
For that, you can add a new local_mfe2 entry to the services and adjust the port to match the port of your application.
For example, if you have two applications running on ports 4200 and 4300, the configuration would look like this:
local_mfe:
loadBalancer:
servers:
- url: "http://host.docker.internal:4200/"
local_mfe2:
loadBalancer:
servers:
- url: "http://host.docker.internal:4300/"
Also the traefik rules in the docker-compose need to be adjusted to the right local_mfe, so for the second app, you would need to change local_mfe to local_mfe2 in the labels section of the traefik configuration in the hello-world-bff service:
- "traefik.http.routers.local_mfe2.entrypoints=web"
- "traefik.http.routers.local_mfe2.rule=Host(`local-proxy`)&&PathPrefix(`/mfe/anotherApp/`)"
- "traefik.http.routers.local_mfe2.service=local_mfe2@file"
Now you can start both applications with npm start in their respective directories and restart your containers with docker compose --profile base up -d. Every change in either application should be reflected immediately under their respective paths, e.g., http://local-proxy/onecx-shell/admin/helloWorld/hello and http://local-proxy/onecx-shell/admin/anotherApp/feature.