Open source, composable payments platform | PCI compliant | SaaS and Self-host options | Enables connectivity to multiple payment, payout, fraud, vault and tokenization providers | Uplifts authorization with intelligent routing and revenue recovery | Reduce payment processing costs with cost observability | Reduces payment ops with reconciliation
Rust adyenbeginner-friendlyfeaturedfinancefintechhacktoberfesthigh-performanceopen-sourceorchestrationpaymentpayment-gatewaypayment-integrationpayment-processingpaymentspayments-platformrestful-apirustsdkstripeworks-with-react
feat(deploy): Add one-click Docker setup script (#7804)
Dhananjay Mahtha303074dde6e8
diff --git a/README.md b/README.mdindex 21b5d4def2..3033263e57 100644--- a/README.md+++ b/README.md@@ -69,15 +69,27 @@ Read more at [Hyperswitch docs](https://docs.hyperswitch.io/).### 1. Local Setup-You can run Hyperswitch on your system using Docker compose after cloning this repository.-We recommend using Docker Desktop (Or Orbstack) for Windows and Mac OS. On Linux, you can install Docker Engine directly.+#### One-Click Setup (Recommended)++You can run Hyperswitch on your system with a single command using our one-click setup script:+```shellgit clone --depth 1 --branch latest https://github.com/juspay/hyperswitchcd hyperswitch-docker compose up -d-# This script verifies the setup and provides links to the individual components.-scripts/docker_output.sh+scripts/setup.sh```++The above script will:+- Check for prerequisites (Docker Compose/Podman)+- Set up necessary configurations+- Let you select a deployment profile:+ - **Standard**: Recommended - App server + Control Center + Web SDK.+ - **Full**: Standard + Monitoring + Scheduler.+ - **Standalone App Server**: Core services only (Hyperswitch server, PostgreSQL, Redis)+- Start the selected services+- Check service health+- Provide access information+The next step is to [configure a connector][configure-a-connector] with the Hyperswitch Control Center and [try a payment][try-a-payment].Check out the [local setup guide][local-setup-guide] for more details on setting up the entire stack or component wise.diff --git a/docs/one_click_setup.md b/docs/one_click_setup.mdnew file mode 100644index 0000000000..4eee500936--- /dev/null+++ b/docs/one_click_setup.md@@ -0,0 +1,97 @@+# One-Click Docker Setup Guide++This document provides detailed information about the one-click setup script for Hyperswitch.++## Overview++The `setup.sh` script simplifies the process of setting up Hyperswitch in a local development or testing environment. It provides an interactive setup experience that handles checking prerequisites, configuring the environment, and starting the necessary services.++## Features++- **Prerequisite Checking**: Verifies Docker/Podman and Docker/Podman Compose installation.+- **Port Availability Check**: Ensures required ports are available to avoid conflicts.+- **Configuration Management**: Automatically sets up necessary configuration files.+- **Multiple Deployment Profiles**: Choose the right setup for your needs.+- **Health Checking**: Verifies services are running and healthy.+- **Detailed Feedback**: Provides clear output and helpful error messages.++## Deployment Profiles++The script offers four deployment profiles to match your needs:++### 1. Standard (Recommended)+- **Services**: App server + Control Center + Web SDK (includes PostgreSQL, Redis)+- **Best for**: General development and testing+- **Resources required**: Medium++### 2. Full+- **Services**: Standard + Monitoring (Grafana, Prometheus) + Scheduler+- **Best for**: Complete system testing+- **Resources required**: Higher++### 3. Standalone App Server+- **Services**: Hyperswitch server, PostgreSQL, Redis+- **Best for**: Testing basic API functionality+- **Resources required**: Lower+++## Troubleshooting++### Common Issues++1. **Docker not running**+ - **Error**: "Cannot connect to the Docker/Podman daemon"+ - **Solution**: Start the Docker daemon/Docker Desktop or Use Orbstack.++2. **Port conflicts**+ - **Error**: "The following ports are already in use: [port list]"+ - **Solution**: Stop services using those ports or choose different ports.++3. **Server not becoming healthy**+ - **Error**: "Hyperswitch server did not become healthy in the expected time."+ - **Solution**: Check logs with `docker compose logs hyperswitch-server` or `podman compose logs hyperswitch-server`.++### Viewing Logs++To view logs for any service:+```+docker compose logs -f [service-name]+```++Common service names:+- `hyperswitch-server`+- `pg` (PostgreSQL)+- `redis-standalone`+- `hyperswitch-control-center`++## Advanced Usage++### Environment Variables++You can set these environment variables before running the script:++- `DRAINER_INSTANCE_COUNT`: Number of drainer instances (default: 1)+- `REDIS_CLUSTER_COUNT`: Number of Redis cluster nodes (default: 3)++Example:+```+export DRAINER_INSTANCE_COUNT=2+./setup.sh+```++### Manual Service Control++After setup, you can manually control services:++- Stop all services: `docker/podman compose down`+- Start specific services: `docker/podman compose up -d [service-name]`+- Restart a service: `docker/podman compose restart [service-name]`++## Next Steps++After running the setup script:++1. Verify the server is running: `curl --head --request GET 'http://localhost:8080/health'`.+2. Access the Control Center at `http://localhost:9000`.+3. Configure payment connectors in the Control Center.+4. Try a test payment using the demo store.diff --git a/docs/try_local_system.md b/docs/try_local_system.mdindex 586e62acc7..24ea5b9da6 100644--- a/docs/try_local_system.md+++ b/docs/try_local_system.md@@ -36,7 +36,7 @@ Check the Table Of Contents to jump to the relevant section.## Run hyperswitch using Docker Compose-1. Install [Docker Compose][docker-compose-install].+1. Install [Docker Compose][docker-compose-install] or [Podman Compose][podman-compose-install].2. Clone the repository and switch to the project directory:```shell@@ -49,84 +49,15 @@ Check the Table Of Contents to jump to the relevant section.The provided configuration should work as is.If you do update the `docker_compose.toml` file, ensure to also update thecorresponding values in the [`docker-compose.yml`][docker-compose-yml] file.-4. Start all the services using Docker Compose:+4. Start all the services using below script:```shell- docker compose up -d- # This script verifies the setup and provides links to the individual components.- scripts/docker_output.sh- ```- This should run the hyperswitch app server, web client and control center.- Wait for the `migration_runner` container to finish installing `diesel_cli`- and running migrations (approximately 2 minutes), and for the- `hyperswitch-web` container to finish compiling before proceeding further.- You can also choose to- [run the scheduler and monitoring services](#running-additional-services)- in addition to the app server, web client and control center.--5. Verify that the server is up and running by hitting the health endpoint:-- ```shell- curl --head --request GET 'http://localhost:8080/health'+ scripts/setup.sh```-- If the command returned a `200 OK` status code, proceed with- [trying out our APIs](#try-out-our-apis).--### Running additional services--The default behaviour for docker compose only runs the following services:--1. postgres-2. redis (standalone)-3. hyperswitch server-4. hyperswitch control center-5. hyperswitch web sdk--You can run the scheduler, data 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.--- To run the data services (Clickhouse, Kafka and Opensearch) you can specify the `olap` profile-- ```shell- docker compose --profile olap up -d- ```-- You can read more about using the data services [here][data-docs]--- 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)+ You will get prompts to select your preferred setup option.[docker-compose-install]: https://docs.docker.com/compose/install/+[podman-compose-install]: https://podman.io/docs/installation[docker-compose-config]: /config/docker_compose.toml[docker-compose-yml]: /docker-compose.yml[architecture]: /docs/architecture.mddiff --git a/scripts/setup.sh b/scripts/setup.shnew file mode 100755index 0000000000..c40c5365c9--- /dev/null+++ b/scripts/setup.sh@@ -0,0 +1,241 @@+#! /usr/bin/env bash+set -euo pipefail++# ANSI color codes for pretty output+RED='\033[0;31m'+GREEN='\033[0;32m'+YELLOW='\033[0;33m'+BLUE='\033[0;34m'+BOLD='\033[1m'+NC='\033[0m' # No Color++# Alias for docker to use podman+alias docker=podman++# Function to print colorful messages+echo_info() {+ echo -e "${BLUE}[INFO]${NC} $1"+}++echo_success() {+ echo -e "${GREEN}[SUCCESS]${NC} $1"+}++echo_warning() {+ echo -e "${YELLOW}[WARNING]${NC} $1"+}++echo_error() {+ echo -e "${RED}[ERROR]${NC} $1"+}++show_banner() {+ echo -e "${BLUE}${BOLD}"+ echo ""+ echo " # "+ echo " # # # #### ##### ## # # "+ echo " # # # # # # # # # # "+ echo " # # # #### # # # # # "+ echo " # # # # # ##### ###### # "+ echo " # # # # # # # # # # "+ echo " ##### #### #### # # # # "+ echo ""+ echo ""+ echo " # # # # ##### ###### ##### #### # # # ##### #### # # "+ echo " # # # # # # # # # # # # # # # # # # "+ echo " # # # # # ##### # # #### # # # # # ###### "+ echo " ####### # ##### # ##### # # ## # # # # # # "+ echo " # # # # # # # # # ## ## # # # # # # "+ echo " # # # # ###### # # #### # # # # #### # # "+ echo ""+ sleep 1+ echo -e "${NC}"+ echo -e "🚀 ${BLUE}One-Click Docker Setup${NC} 🚀"+ echo+}++# Detect Docker Compose version+detect_docker_compose() {+ # Check Docker or Podman+ if command -v docker &> /dev/null; then+ CONTAINER_ENGINE="docker"+ echo_success "Docker is installed."+ elif command -v podman &> /dev/null; then+ CONTAINER_ENGINE="podman"+ echo_success "Podman is installed."+ else+ echo_error "Neither Docker nor Podman is installed. Please install one of them to proceed."+ echo_info "Visit https://docs.docker.com/get-docker/ or https://podman.io/docs/installation for installation instructions."+ echo_info "After installation, re-run this script: scripts/setup.sh"+ exit 1+ fi++ # Check Docker Compose or Podman Compose+ if $CONTAINER_ENGINE compose version &> /dev/null; then+ DOCKER_COMPOSE="$CONTAINER_ENGINE compose"+ echo_success "Compose is installed for $CONTAINER_ENGINE."+ else+ echo_error "Compose is not installed for $CONTAINER_ENGINE. Please install $CONTAINER_ENGINE compose to proceed."+ if [ "$CONTAINER_ENGINE" = "docker" ]; then+ echo_info "Visit https://docs.docker.com/compose/install/ for installation instructions."+ elif [ "$CONTAINER_ENGINE" = "podman" ]; then+ echo_info "Visit https://podman-desktop.io/docs/compose/setting-up-compose for installation instructions."+ fi+ echo_info "After installation, re-run this script: scripts/setup.sh"+ exit 1+ fi+}++check_prerequisites() {+ # Check curl+ if ! command -v curl &> /dev/null; then+ echo_error "curl is not installed. Please install curl to proceed."+ exit 1+ fi+ echo_success "curl is installed."++ # Check ports+ required_ports=(8080 9000 9050 5432 6379 9060)+ unavailable_ports=()++ for port in "${required_ports[@]}"; do+ if command -v nc &> /dev/null; then+ if nc -z localhost "$port" 2>/dev/null; then+ unavailable_ports+=("$port")+ fi+ elif command -v lsof &> /dev/null; then+ if lsof -i :"$port" &> /dev/null; then+ unavailable_ports+=("$port")+ fi+ else+ echo_warning "Neither nc nor lsof available to check ports. Skipping port check."+ break+ fi+ done++ if [ ${#unavailable_ports[@]} -ne 0 ]; then+ echo_warning "The following ports are already in use: ${unavailable_ports[*]}"+ echo_warning "This might cause conflicts with Hyperswitch services."+ read -p "Do you want to continue anyway? (y/n): " -n 1 -r+ echo+ if [[ ! $REPLY =~ ^[Yy]$ ]]; then+ exit 1+ fi+ else+ echo_success "All required ports are available."+ fi+}++setup_config() {+ if [ ! -f "config/docker_compose.toml" ]; then+ echo_error "Configuration file 'config/docker_compose.toml' not found. Please ensure the file exists and is correctly configured."+ exit 1+ fi+}++select_profile() {+ echo ""+ echo "Select a setup option:"+ echo -e "1) Standard Setup: ${BLUE}[Recommended]${NC} Ideal for quick trial. Services included: ${BLUE}App Server, Control Center, Unified Checkout, PostgreSQL and Redis${NC}"+ echo -e "2) Full Stack Setup: Ideal for comprehensive end-to-end payment testing. Services included: ${BLUE}Everything in Standard, Monitoring and Scheduler${NC}"+ echo -e "3) Standalone App Server: Ideal for API-first integration testing. Services included: ${BLUE}App server, PostgreSQL and Redis)${NC}"+ echo ""+ local profile_selected=false+ while [ "$profile_selected" = false ]; do+ read -p "Enter your choice (1-3): " profile_choice+ profile_choice=${profile_choice:-1}++ case $profile_choice in+ 1)+ PROFILE="standard"+ profile_selected=true+ ;;+ 2)+ PROFILE="full"+ profile_selected=true+ ;;+ 3)+ PROFILE="standalone"+ profile_selected=true+ ;;+ *)+ echo_error "Invalid choice. Please enter 1, 2, or 3."+ ;;+ esac+ done++ echo "Selected setup: $PROFILE"+}++start_services() {++ case $PROFILE in+ standalone)+ $DOCKER_COMPOSE up -d pg redis-standalone migration_runner hyperswitch-server+ ;;+ standard)+ $DOCKER_COMPOSE up -d+ ;;+ full)+ $DOCKER_COMPOSE --profile scheduler --profile monitoring --profile olap up -d+ ;;+ esac+}++check_services_health() {+ # Wait for the hyperswitch-server to be healthy+ MAX_RETRIES=30+ RETRY_INTERVAL=5+ RETRIES=0++ while [ $RETRIES -lt $MAX_RETRIES ]; do+ if curl --silent --head --request GET 'http://localhost:8080/health' | grep "200 OK" > /dev/null; then+ echo_success "Hyperswitch server is healthy!"+ print_access_info # Call print_access_info only when the server is healthy+ return+ fi++ RETRIES=$((RETRIES+1))+ if [ $RETRIES -eq $MAX_RETRIES ]; then+ echo ""+ echo_error "${RED}${BOLD}Hyperswitch server did not become healthy in the expected time."+ echo -e "Check logs with: $DOCKER_COMPOSE logs hyperswitch-server, Or reach out to us on slack(https://hyperswitch-io.slack.com/) for help."+ echo -e "The setup process will continue, but some services might not work correctly.${NC}"+ echo ""+ else+ echo "Waiting for server to become healthy... ($RETRIES/$MAX_RETRIES)"+ sleep $RETRY_INTERVAL+ fi+ done+}++print_access_info() {+ echo ""+ echo -e "${GREEN}${BOLD}Setup complete! You can access Hyperswitch services at:${NC}"+ echo ""++ if [ "$PROFILE" != "standalone" ]; then+ echo -e " • ${GREEN}${BOLD}Control Center${NC}: ${BLUE}${BOLD}http://localhost:9000${NC}"+ fi++ echo -e " • ${GREEN}${BOLD}App Server${NC}: ${BLUE}${BOLD}http://localhost:8080${NC}"++ if [ "$PROFILE" != "standalone" ]; then+ echo -e " • ${GREEN}${BOLD}Unified Checkout${NC}: ${BLUE}${BOLD}http://localhost:9060${NC}"+ fi++ if [ "$PROFILE" = "full" ]; then+ echo -e " • ${GREEN}${BOLD}Monitoring (Grafana)${NC}: ${BLUE}${BOLD}http://localhost:3000${NC}"+ fi+ echo ""+ echo_info "To stop all services, run: $DOCKER_COMPOSE down"+}++# Main execution flow+show_banner+detect_docker_compose+check_prerequisites+setup_config+select_profile+start_services+check_services_health # This will call print_access_info if the server is healthy