Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get backend URL from env #927

Open
wants to merge 6 commits into
base: develop
Choose a base branch
from
Open

Conversation

kmehant
Copy link
Collaborator

@kmehant kmehant commented Aug 3, 2020

Signed-off-by: K mehant [email protected]

@kmehant kmehant self-assigned this Aug 3, 2020
@TravisBuddy
Copy link

Hey @kmehant,
Your changes look good to me!

View build log

TravisBuddy Request Identifier: d9885a90-d5aa-11ea-8ca9-c37e1b84d109

@TravisBuddy
Copy link

Travis tests have failed

Hey @kmehant,
Please read the following log in order to understand the failure reason.
It'll be awesome if you fix what's wrong and commit the changes.

1st Build

View build log

docker build -f ui/Dockerfile.dev -t scoreucsc/bassa-ui:dev ui >/dev/null
The command '/bin/sh -c apt-get update &&     npm install &&     npm install --global bower gulp-cli &&     bower --allow-root install' returned a non-zero code: 1
TravisBuddy Request Identifier: f0ac3040-d5fd-11ea-8ca9-c37e1b84d109

@kmehant
Copy link
Collaborator Author

kmehant commented Aug 4, 2020

Use environment variable apiUrl to set Bassa API url

@TravisBuddy
Copy link

Hey @kmehant,
Your changes look good to me!

View build log

TravisBuddy Request Identifier: 0bb5a100-d603-11ea-8ca9-c37e1b84d109

ui/Dockerfile Outdated

# Add environment variable values to env.js
# ENV: apiUrl : backend url
RUN sh env.sh
Copy link
Collaborator

Choose a reason for hiding this comment

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

This won't work, this will run on the build time not on run time. Users who pull the docker image from the Docker hub won't be able to change the values when running.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@agentmilindu Made a workaround, Please look at it.

Signed-off-by: K mehant <[email protected]>
@TravisBuddy
Copy link

Hey @kmehant,
Your changes look good to me!

View build log

TravisBuddy Request Identifier: 53767e70-d625-11ea-8693-3322afd57804

@agentmilindu
Copy link
Collaborator

agentmilindu commented Aug 4, 2020

Screenshot from 2020-08-04 15-39-19

Try this method.

See https://hub.docker.com/_/nginx

COPY the env.js.template to /etc/nginx/templates with placeholder

pattern=' window.__env.apiUrl.*'
replacement=" window.__env.apiUrl = '${apiUrl}';"

sed -i -e 's,'"$pattern"','"$replacement"',' /usr/share/nginx/html/env.js
Copy link
Collaborator

Choose a reason for hiding this comment

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

is it not possible to move this to a .json file and patch that accordingly or change it accordingly? What is the reason for patching a .js file?

Copy link
Collaborator Author

@kmehant kmehant Aug 5, 2020

Choose a reason for hiding this comment

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

@JaDogg Actually I used the javascript file which is imported in static HTML file so that whenever the homepage is loaded, the JS script is run and the variables are as well loaded.

Signed-off-by: K mehant <[email protected]>
@TravisBuddy
Copy link

Hey @kmehant,
Your changes look good to me!

View build log

TravisBuddy Request Identifier: 9b4213c0-d717-11ea-85fc-4b61cecd2c91

@TravisBuddy
Copy link

Hey @kmehant,
Your changes look good to me!

View build log

TravisBuddy Request Identifier: 2beb4f90-d718-11ea-85fc-4b61cecd2c91

@kmehant
Copy link
Collaborator Author

kmehant commented Aug 5, 2020

@agentmilindu I have tested it now, it works well having apiUrl set for server URL is taking up the changes in run time on reloading the container.

But all server routes give out 404 because of this PR #890 which does not seem to work with WSGI and supervisord layers well. Works without WSGI and supervisord though.

@kmehant
Copy link
Collaborator Author

kmehant commented Aug 5, 2020

Screenshot from 2020-08-04 15-39-19

Try this method.

See https://hub.docker.com/_/nginx

COPY the env.js.template to /etc/nginx/templates with placeholder

Are you planning to have bassa server also routed through the same nginx 🤔, then how about mounting the nginx config with an another server block for Bassa server?

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

Successfully merging this pull request may close these issues.

4 participants