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

build(docker): add web client and control center services to docker compose setup #4197

Merged
merged 17 commits into from
May 6, 2024
Merged

build(docker): add web client and control center services to docker compose setup #4197

merged 17 commits into from
May 6, 2024

Conversation

prasad89
Copy link
Contributor

@prasad89 prasad89 commented Mar 26, 2024

Type of Change

  • Bugfix
  • New feature
  • Enhancement
  • Refactoring
  • Dependency updates
  • Documentation
  • CI/CD

Description

Added web client and control center services to docker-compose.yml
REF : #4110

Additional Changes

  • This PR modifies the API contract
  • This PR modifies the database schema
  • This PR modifies application configuration/environment variables

@prasad89 prasad89 requested review from a team as code owners March 26, 2024 08:35
@SanchithHegde SanchithHegde added A-infra Area: Infrastructure C-feature Category: Feature request or enhancement S-waiting-on-review Status: This PR has been implemented and needs to be reviewed hiring-challenge labels Mar 26, 2024
Copy link
Member

@SanchithHegde SanchithHegde left a comment

Choose a reason for hiding this comment

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

Did you test the changes in this PR? How does the setup process look like?

@prasad89
Copy link
Contributor Author

prasad89 commented Mar 26, 2024

Did you test the changes in this PR? How does the setup process look like?

Yes, I have tested changes locally by following
after doing docker compose up -d I'm able to see UI with Hyperswitch Unified Checkout text on page.

@prasad89 prasad89 requested a review from SanchithHegde March 26, 2024 19:04
@SanchithHegde
Copy link
Member

Yes, I have tested changes locally by following after doing docker compose up -d I'm able to see UI with Hyperswitch Unified Checkout text on page.

If you're seeing only the text on the page, then the setup in incomplete, you should be able to see a demo store on the left, and a form to enter card details on the right as well, if you set it up correctly. Could you open the network tab in the browser developer tools and fix any problems that you notice?

@prasad89
Copy link
Contributor Author

prasad89 commented Mar 26, 2024

@SanchithHegde Thank you for guiding me in the right direction.
I've checked the network tab and fixed errors by adding the following block in the hyperswitch-web section:

- HYPERSWITCH_PUBLISHABLE_KEY=PUBLISHABLE_KEY
- HYPERSWITCH_SECRET_KEY=SECRET_KEY
- HYPERSWITCH_SERVER_URL=http://hyperswitch-server:8080
- HYPERSWITCH_CLIENT_URL=http://hyperswitch-web:9050
- SELF_SERVER_URL=http://hyperswitch-web:5252

For HYPERWITCH_PUBLISHABLE_KEY and HYPERWITCH_SECRET_KEY, I've followed the steps mentioned in the documentation and generated the keys.
After this changes I'm able to see the demo store on the left and a form to enter card details on the right.

@prasad89
Copy link
Contributor Author

Did you test the changes in this PR? How does the setup process look like?

To set up, create a .env file and configure the following keys:

HYPERSWITCH_PUBLISHABLE_KEY=your_publishable_key
HYPERSWITCH_SECRET_KEY=your_secret_key
HYPERSWITCH_SERVER_URL=http://hyperswitch-server:8080
HYPERSWITCH_CLIENT_URL=http://hyperswitch-web:9050
SELF_SERVER_URL=http://hyperswitch-web:5252

Then execute docker-compose up -d.

@SanchithHegde
Copy link
Member

After this changes I'm able to see the demo store on the left and a form to enter card details on the right.

Could you please include screenshots for the same?

@prasad89
Copy link
Contributor Author

After this changes I'm able to see the demo store on the left and a form to enter card details on the right.

Could you please include screenshots for the same?

Screenshot from 2024-03-27 19-11-42

@prasad89
Copy link
Contributor Author

Looks like I need to further investigate and fix environment variables for the web.
HyperLoader is still not functioning, but I have managed to make the control center functional.
Screenshot from 2024-03-27 23-02-25

@prasad89
Copy link
Contributor Author

prasad89 commented Mar 27, 2024

@SanchithHegde I got the card details in right hand side now.
Screenshot from 2024-03-28 00-13-30

@prasad89
Copy link
Contributor Author

prasad89 commented Apr 4, 2024

Hello @SanchithHegde can you review the changes?

Comment on lines 9 to 10
RUN sed -i '/hot: true,/a \ host: "0.0.0.0",' webpack.dev.js
RUN sed -i '/hot: true,/a \ host: "0.0.0.0",' Hyperswitch-React-Demo-App/webpack.dev.js
Copy link
Contributor

Choose a reason for hiding this comment

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

is this still needed after this PR?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No


### Control Center
hyperswitch-control-center:
image: juspaydotin/hyperswitch-control-center
Copy link
Contributor

Choose a reason for hiding this comment

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

can you use the latest tag here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Okay, will make the changes

EXPOSE 5252
EXPOSE 9060

CMD concurrently "npm run re:start" "npm run start" "npm run start:playground"
Copy link
Contributor

Choose a reason for hiding this comment

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

@vsrivatsa-juspay can you check this one?

it seems that npm run re:start does the compilation and needs to be completed before the other 2 commands are executed...

also would prefer npm run re:build instead on npm run re:start since we don't need the hot reloading here...

Comment on lines 134 to 135
networks:
- router_net
Copy link
Contributor

Choose a reason for hiding this comment

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

this might not be needed since there isn't any inter-service communication happening here...
since all communication happens on the host machine and is initiated by browser.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Correct

Comment on lines 153 to 154
networks:
- router_net
Copy link
Contributor

Choose a reason for hiding this comment

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

this might not be needed since there isn't any inter-service communication happening here...
since all communication happens on the host machine and is initiated by browser.

@prasad89 prasad89 requested a review from lsampras April 24, 2024 11:58
Copy link
Contributor

@lsampras lsampras left a comment

Choose a reason for hiding this comment

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

Some minor changes,
also can you share a screenshot of the SDK loading locally (inside the control-center) as shown in the reference screenshot from sandbox

EXPOSE 5252
EXPOSE 9060

CMD concurrently "npm run re:build" "npm run start" "npm run start:playground"
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
CMD concurrently "npm run re:build" "npm run start" "npm run start:playground"
CMD concurrently "npm run re:build && npm run start" "npm run start:playground"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the suggestion.

context: ./docker
dockerfile: web.Dockerfile
env_file:
- ./.env
Copy link
Contributor

Choose a reason for hiding this comment

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

@prasad89 Can you make sure the SDK loads in control-center
sharing a reference screenshot from our sandbox environment (app.hyperswitch.io)

image

@prasad89
Copy link
Contributor Author

@lsampras, I've addressed your review. Could you please review it?
Additionally, I'm encountering a 401 unauthorized status when attempting to load the SDK.
I've created both HYPERSWITCH_PUBLISHABLE_KEY and HYPERSWITCH_SECRET_KEY, and exported them accordingly.
I can confirm that HYPERSWITCH_PUBLISHABLE_KEY is visible at localhost:5252/config.
Could you provide any guidance on how to proceed?
Your assistance would be greatly appreciated.

@prasad89 prasad89 requested a review from lsampras April 29, 2024 15:47
Comment on lines 140 to 143
- SDK_ENV=${SDK_ENV:-local}
- ENV_SDK_URL=${ENV_SDK_URL:-http://localhost:9050/HyperLoader.js}
- ENV_BACKEND_URL=${ENV_BACKEND_URL:-http://localhost:8080}
- ENV_LOGGING_URL=${ENV_LOGGING_URL:-http://localhost:3100}
Copy link
Contributor

Choose a reason for hiding this comment

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

I believe you picked this up from the issue that was mentioned in the fix, but that change hasn't been merged to main branch yet,

either use the older SDK variable keys or pull that branch instead of main in your dockerfile

@@ -4,12 +4,12 @@ RUN npm install concurrently -g

WORKDIR /hyperswitch-web

RUN git clone https://github.com/juspay/hyperswitch-web .
RUN git clone https://github.com/juspay/hyperswitch-web . --depth 1
Copy link
Contributor

Choose a reason for hiding this comment

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

The ordering here seems incorrect

hyperswitch-server:
condition: service_started
- SDK_ENV=${SDK_ENV:-local}
- ENV_SDK_URL=${ENV_SDK_URL:-http://localhost:9050/HyperLoader.js}
Copy link
Contributor

Choose a reason for hiding this comment

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

This won't have the HyperLoader.js at the end this is supposed to be the base url only

Comment on lines 140 to 143
- SDK_ENV=${SDK_ENV:-local}
- ENV_SDK_URL=${ENV_SDK_URL:-http://localhost:9050/HyperLoader.js}
- ENV_BACKEND_URL=${ENV_BACKEND_URL:-http://localhost:8080}
- ENV_LOGGING_URL=${ENV_LOGGING_URL:-http://localhost:3100}
Copy link
Contributor

Choose a reason for hiding this comment

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

can you add these variables back?

Copy link
Contributor Author

@prasad89 prasad89 Apr 30, 2024

Choose a reason for hiding this comment

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

Okay, will add it.

I'm getting this errors since morning on hyperswitch-router:standalone

Unable to deserialize `stripe` as `api_models::enums::PayoutConnectors`: Matching variant not found
thread 'main' panicked at crates/router/src/bin/router.rs:14:10:
Unable to construct application configuration: ConfigurationError(Some errors occurred:
Unable to deserialize `stripe` as `api_models::enums::PayoutConnectors`: Matching variant not found)
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

@lsampras do you have any idea regarding this?

Copy link
Member

Choose a reason for hiding this comment

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

Oh, this seems to be caused by recent changes to the docker_compose.toml file.

I would have suggested checking out to the v1.107.0 tag before running the Docker Compose setup, but since you need to open a PR against the main branch, that isn't an option. You can remove stripe from the payout_connector_list line in the docker_compose.toml file to be able to run the Docker Compose setup, and you need not push the docker_compose.toml change as part of this PR.

Copy link
Contributor Author

@prasad89 prasad89 Apr 30, 2024

Choose a reason for hiding this comment

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

Thanks for the help @SanchithHegde
Also when I'm trying to preview payment from control center UI is authenticating request with beta.hyperswitch.io is that expected?

@prasad89
Copy link
Contributor Author

I'm getting this errors on hyperswitch-router:standalone

Unable to deserialize `stripe` as `api_models::enums::PayoutConnectors`: Matching variant not found
thread 'main' panicked at crates/router/src/bin/router.rs:14:10:
Unable to construct application configuration: ConfigurationError(Some errors occurred:
Unable to deserialize `stripe` as `api_models::enums::PayoutConnectors`: Matching variant not found)
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

@SanchithHegde do you have any idea regarding this?

Copy link
Contributor

@lsampras lsampras left a comment

Choose a reason for hiding this comment

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

Can get this merged for now, seems good for the most part

@prasad89
Copy link
Contributor Author

prasad89 commented May 6, 2024

Thanks @SanchithHegde and @lsampras for your time and approving this PR.
This will keep me motivating to contribute further.

@SanchithHegde SanchithHegde changed the title build(docker) : Added web client and control center services to docker-compose.yml build(docker): add web client and control center services to docker compose setup May 6, 2024
@lsampras lsampras linked an issue May 6, 2024 that may be closed by this pull request
@likhinbopanna likhinbopanna added this pull request to the merge queue May 6, 2024
Merged via the queue into juspay:main with commit b1cfef2 May 6, 2024
12 of 15 checks passed
@SanchithHegde SanchithHegde removed the S-waiting-on-review Status: This PR has been implemented and needs to be reviewed label May 6, 2024
@prasad89 prasad89 deleted the docker-compose branch May 12, 2024 15:34
lsampras pushed a commit that referenced this pull request May 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-infra Area: Infrastructure C-feature Category: Feature request or enhancement hiring-challenge
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Setup Hyperswitch Web & Control center
4 participants