mirror of
https://github.com/RD17/ambar.git
synced 2026-04-26 07:55:51 +03:00
[GH-ISSUE #253] Allow injection of Frontend IP Address via environment variables #245
Labels
No labels
$$ Paid Support
bug
bug
enhancement
help wanted
invalid
pull-request
question
question
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/ambar#245
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @sgarwood on GitHub (Aug 14, 2019).
Original GitHub issue: https://github.com/RD17/ambar/issues/253
I renamed all of the
image:tobuild:and their relevant directoryI then modified the
docker-compose.ymlfile so that the front end runs on port8060by changing the configuration toI have an external .env file as so ${ambarHostIpAddress} should be resolved to 172.18.0.19
and can confirm when I run
docker-compose exec frontend envI see the variableapi=http://172.18.0.19:8080However, when I visit
http://172.18.0.19:8060the page fails to load and simply displays a blank page and console errors.Inspecting the console errors I can see
and
Obviously, being requested from my browser this address will never resolve as this is an internal docker-compose address.
I have the understanding this index page should be serving the scripts produced via
npm run compilevia an NGINx container accessible on the 172.18.0.19 host IP.I grepped the source for where the
172.17.0.2:3000was coming from and could see that it was included in the WebPack build as theindex.htmlcontained the values verbatim.Unfortunately, my knowledge of WebPack builds is not very extensive and would appreciate if someone would be able to point me in the right direction
Steps to reproduce:
docker run -v "$PWD":/usr/src/app -w /usr/src/app node:8 npm installin ./FrontEnddocker run -v "$PWD":/usr/src/app -w /usr/src/app node:8 npm run compilein ./FrontEnddocker-compose builddocker-compose up -dhttp://172.18.0.19:8060in Chromeand
@sgarwood commented on GitHub (Aug 14, 2019):
Update
I managed to get the IP Address to be 172.18.0.19 by installing node on the server and running
npm run compileinstead of running it inside of a docker run container. I believe this is an underlying issue that the machine the build runs on determines the IP Address of the end build.I then set the
PORTenvironment variable to 8060 to match what I needed it to be.Then:
npm run compileto rebuild with correct configurationdocker-compose build --no-cache frontendto rebuild local imagedocker-compose up -d --no-deps --force-recreate frontendto restart running serviceI think it would be more appropriate to allow users to override this by injecting an environment variable that would overwrite the default of getting the current IP address with a provided one.
Looking at
Frontend/config/index.jsI can see thatserver_hostis set toip.address().I think it would make sense to override this using a method similar to server port
server_port : process.env.PORT || 3000