Skip to content

Commit

Permalink
docs(try_local_system): add section to run using Docker Compose and p…
Browse files Browse the repository at this point in the history
…ulling standalone images
  • Loading branch information
SanchithHegde committed Nov 25, 2023
1 parent a8bdf45 commit efc49a6
Show file tree
Hide file tree
Showing 2 changed files with 117 additions and 29 deletions.
20 changes: 18 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,9 @@ Using Hyperswitch, you can:
<h2 id="Quick Start Guide">⚡️ Quick Start Guide</h2>
</a>

<h3> One-click deployment on AWS cloud </h3>
### One-click deployment on AWS cloud

The fastest and easiest way to try hyperswitch is via our CDK scripts
The fastest and easiest way to try Hyperswitch is via our CDK scripts

1. Click on the following button for a quick standalone deployment on AWS, suitable for prototyping.
No code or setup is required in your system and the deployment is covered within the AWS free-tier setup.
Expand All @@ -70,6 +70,22 @@ The fastest and easiest way to try hyperswitch is via our CDK scripts

For an early access to the production-ready setup fill this <a href="https://forms.gle/v6ru55XDZFufVPnu9">Early Access Form</a>

### Run it on your system

You can run Hyperswitch on your system using Docker Compose after cloning this repository:

```shell
docker compose up -d
```

This will start the payments router, the primary component within Hyperswitch.

Check out the [local setup guide][local-setup-guide] for a more comprehensive
setup, which includes the [scheduler and monitoring services][docker-compose-scheduler-monitoring].

[local-setup-guide]: /docs/try_local_system.md
[docker-compose-scheduler-monitoring]: /docs/try_local_system.md#run-the-scheduler-and-monitoring-services

<a href="#Fast-Integration-for-Stripe-Users">
<h2 id="Fast Integration for Stripe Users">🔌 Fast Integration for Stripe Users</h2>
</a>
Expand Down
126 changes: 99 additions & 27 deletions docs/try_local_system.md
Original file line number Diff line number Diff line change
@@ -1,23 +1,20 @@
# Try out hyperswitch on your system

**NOTE:**
This guide is aimed at users and developers who wish to set up hyperswitch on
their local systems and requires quite some time and effort.
If you'd prefer trying out hyperswitch quickly without the hassle of setting up
all dependencies, you can [try out hyperswitch sandbox environment][try-sandbox].

There are two options to set up hyperswitch on your system:

1. Use Docker Compose
2. Set up a Rust environment and other dependencies on your system
The simplest way to run hyperswitch locally is
[with Docker Compose](#run-hyperswitch-using-docker-compose) by pulling the
latest images from Docker Hub.
However, if you're willing to modify the code and run it, or are a developer
contributing to hyperswitch, then you can either
[set up a development environment using Docker Compose](#set-up-a-development-environment-using-docker-compose),
or [set up a Rust environment on your system](#set-up-a-rust-environment-and-other-dependencies).

Check the Table Of Contents to jump to the relevant section.

[try-sandbox]: ./try_sandbox.md

**Table Of Contents:**

- [Set up hyperswitch using Docker Compose](#set-up-hyperswitch-using-docker-compose)
- [Run hyperswitch using Docker Compose](#run-hyperswitch-using-docker-compose)
- [Run the scheduler and monitoring services](#run-the-scheduler-and-monitoring-services)
- [Set up a development environment using Docker Compose](#set-up-a-development-environment-using-docker-compose)
- [Set up a Rust environment and other dependencies](#set-up-a-rust-environment-and-other-dependencies)
- [Set up dependencies on Ubuntu-based systems](#set-up-dependencies-on-ubuntu-based-systems)
- [Set up dependencies on Windows (Ubuntu on WSL2)](#set-up-dependencies-on-windows-ubuntu-on-wsl2)
Expand All @@ -33,7 +30,7 @@ Check the Table Of Contents to jump to the relevant section.
- [Create a Payment](#create-a-payment)
- [Create a Refund](#create-a-refund)

## Set up hyperswitch using Docker Compose
## Run hyperswitch using Docker Compose

1. Install [Docker Compose][docker-compose-install].
2. Clone the repository and switch to the project directory:
Expand All @@ -54,15 +51,13 @@ Check the Table Of Contents to jump to the relevant section.
docker compose up -d
```

5. Run database migrations:

```shell
docker compose run hyperswitch-server bash -c \
"cargo install diesel_cli && \
diesel migration --database-url postgres://db_user:db_pass@pg:5432/hyperswitch_db run"
```
This should run the hyperswitch payments router, the primary component within
hyperswitch.
You can also choose to
[run the scheduler and monitoring services](#run-the-scheduler-and-monitoring-services)
in addition to the payments router.

6. Verify that the server is up and running by hitting the health endpoint:
5. Verify that the server is up and running by hitting the health endpoint:

```shell
curl --head --request GET 'http://localhost:8080/health'
Expand All @@ -71,9 +66,86 @@ Check the Table Of Contents to jump to the relevant section.
If the command returned a `200 OK` status code, proceed with
[trying out our APIs](#try-out-our-apis).

### Run the scheduler and monitoring services

You can run the scheduler and monitoring services by specifying suitable profile
names to the above Docker Compose command.
To understand more about the hyperswitch architecture and the components
involved, check out the [architecture document][architecture].

- To run the scheduler components (consumer and producer), you can specify
`--profile scheduler`:

```shell
docker compose --profile scheduler up -d
```

- To run the monitoring services (Grafana, Promtail, Loki, Prometheus and Tempo),
you can specify `--profile monitoring`:

```shell
docker compose --profile monitoring up -d
```

You can then access Grafana at `http://localhost:3000` and view application
logs using the "Explore" tab, select Loki as the data source, and select the
container to query logs from.

- You can also specify multiple profile names by specifying the `--profile` flag
multiple times.
To run both the scheduler components and monitoring services, the Docker
Compose command would be:

```shell
docker compose --profile scheduler --profile monitoring up -d
```

Once the services have been confirmed to be up and running, you can proceed with
[trying out our APIs](#try-out-our-apis)

[docker-compose-install]: https://docs.docker.com/compose/install/
[docker-compose-config]: /config/docker_compose.toml
[docker-compose-yml]: /docker-compose.yml
[architecture]: /docs/architecture.md

## Set up a development environment using Docker Compose

1. Install [Docker Compose][docker-compose-install].
2. Clone the repository and switch to the project directory:

```shell
git clone https://github.com/juspay/hyperswitch
cd hyperswitch
```

3. (Optional) Configure the application using the
[`config/docker_compose.toml`][docker-compose-config] file.
The provided configuration should work as is.
If you do update the `docker_compose.toml` file, ensure to also update the
corresponding values in the [`docker-compose.yml`][docker-compose-yml] file.
4. Start all the services using Docker Compose:

```shell
docker compose --file docker-compose-development.yml up -d
```

This will compile the payments router, the primary component within
hyperswitch and then start it.
Depending on the specifications of your machine, compilation can take
around 15 minutes.

5. (Optional) You can also choose to
[start the scheduler and/or monitoring services](#run-the-scheduler-and-monitoring-services)
in addition to the payments router.

6. Verify that the server is up and running by hitting the health endpoint:

```shell
curl --head --request GET 'http://localhost:8080/health'
```

If the command returned a `200 OK` status code, proceed with
[trying out our APIs](#try-out-our-apis).

## Set up a Rust environment and other dependencies

Expand Down Expand Up @@ -134,7 +206,7 @@ for your distribution and follow along.
4. Install `diesel_cli` using `cargo`:

```shell
cargo install diesel_cli --no-default-features --features "postgres"
cargo install diesel_cli --no-default-features --features postgres
```

5. Make sure your system has the `pkg-config` package and OpenSSL installed:
Expand Down Expand Up @@ -224,7 +296,7 @@ packages for your distribution and follow along.
6. Install `diesel_cli` using `cargo`:

```shell
cargo install diesel_cli --no-default-features --features "postgres"
cargo install diesel_cli --no-default-features --features postgres
```

7. Make sure your system has the `pkg-config` package and OpenSSL installed:
Expand Down Expand Up @@ -260,7 +332,7 @@ You can opt to use your favorite package manager instead.
4. Install `diesel_cli` using `cargo`:

```shell
cargo install diesel_cli --no-default-features --features "postgres"
cargo install diesel_cli --no-default-features --features postgres
```

5. Install OpenSSL with `winget`:
Expand Down Expand Up @@ -322,7 +394,7 @@ You can opt to use your favorite package manager instead.
4. Install `diesel_cli` using `cargo`:

```shell
cargo install diesel_cli --no-default-features --features "postgres"
cargo install diesel_cli --no-default-features --features postgres
```

If linking `diesel_cli` fails due to missing `libpq` (if the error message is
Expand All @@ -333,7 +405,7 @@ You can opt to use your favorite package manager instead.
brew install libpq
export PQ_LIB_DIR="$(brew --prefix libpq)/lib"

cargo install diesel_cli --no-default-features --features "postgres"
cargo install diesel_cli --no-default-features --features postgres
```

You may also choose to persist the value of `PQ_LIB_DIR` in your shell
Expand Down

0 comments on commit efc49a6

Please sign in to comment.