-
Notifications
You must be signed in to change notification settings - Fork 4.2k
feat(deploy): Add one-click Docker setup script #7804
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
Merged
likhinbopanna
merged 15 commits into
juspay:main
from
djcrafts:feature/one-click-docker-setup
May 2, 2025
Merged
Changes from 4 commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
f47859f
feat(deploy): Add one-click Docker setup script
djcrafts 081110e
updated the setup script
gorakhnathy7 e2d10be
updated the setup script
gorakhnathy7 ca34903
Merge branch 'main' into feature/one-click-docker-setup
gorakhnathy7 e996d0a
Update scripts/setup.sh
gorakhnathy7 1649464
updated the setup script
gorakhnathy7 925623d
updated the setup script
gorakhnathy7 9fefe34
updated the setup script
gorakhnathy7 36face6
updated the setup script
gorakhnathy7 25e54a1
updated the setup script
gorakhnathy7 ca98e57
updated the setup script
gorakhnathy7 a1e1a4e
Update docs/one_click_setup.md
gorakhnathy7 ea4812f
Merge branch 'main' into feature/one-click-docker-setup
gorakhnathy7 865c397
Merge branch 'main' into feature/one-click-docker-setup
gorakhnathy7 72764d7
Merge branch 'main' into feature/one-click-docker-setup
gorakhnathy7 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
# One-Click Docker Setup Guide | ||
|
||
This document provides detailed information about the updated 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 and Docker 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. Development | ||
- **Services**: Complete environment built from source | ||
- **Best for**: Active development on Hyperswitch | ||
- **Resources required**: Highest | ||
|
||
### 4. 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 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. | ||
|
||
4. **Server not becoming healthy** | ||
gorakhnathy7 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
- **Error**: "Hyperswitch server did not become healthy in the expected time." | ||
- **Solution**: Check logs with `docker 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 compose down` | ||
- Start specific services: `docker compose up -d [service-name]` | ||
- Restart a service: `docker 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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,232 @@ | ||
#!/bin/bash | ||
gorakhnathy7 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
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' | ||
NC='\033[0m' # No Color | ||
|
||
# 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}" | ||
echo "" | ||
echo " # " | ||
echo " # # # #### ##### ## # # # # # # ##### ###### ##### #### # # # ##### #### # # " | ||
echo " # # # # # # # # # # # # # # # # # # # # # # # # # # # # " | ||
echo " # # # #### # # # # # # # # # # ##### # # #### # # # # # ###### " | ||
echo " # # # # # ##### ###### # ####### # ##### # ##### # # ## # # # # # # " | ||
echo " # # # # # # # # # # # # # # # # # # # ## ## # # # # # # " | ||
echo " ##### #### #### # # # # # # # # ###### # # #### # # # # #### # # " | ||
echo "" | ||
sleep 1 | ||
gorakhnathy7 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
echo -e "${NC}" | ||
echo -e "🚀 ${BLUE}One-Click Docker Setup${NC} 🚀" | ||
echo | ||
} | ||
|
||
# Detect Docker Compose version | ||
detect_docker_compose() { | ||
# Check Docker | ||
if ! command -v docker &> /dev/null; then | ||
echo_error "Docker is not installed. Please install Docker first." | ||
echo_info "Visit https://docs.docker.com/get-docker/ for installation instructions." | ||
exit 1 | ||
fi | ||
echo_success "Docker is installed." | ||
|
||
# Check Docker Compose | ||
if docker compose version &> /dev/null; then | ||
DOCKER_COMPOSE="docker compose" | ||
echo_success "Docker Compose is installed." | ||
else | ||
echo_error "Docker Compose is not installed. Please install Docker Compose(Alternatively use Orbstack) first." | ||
gorakhnathy7 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
echo_info "Visit https://docs.docker.com/compose/install/ for installation instructions." | ||
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) | ||
SanchithHegde marked this conversation as resolved.
Show resolved
Hide resolved
|
||
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 | ||
if [ -f "config/config.example.toml" ]; then | ||
echo "Creating docker_compose.toml from example config..." | ||
cp config/config.example.toml config/docker_compose.toml | ||
echo_success "Configuration file created." | ||
gorakhnathy7 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
else | ||
echo_error "Example configuration file not found." | ||
exit 1 | ||
fi | ||
else | ||
echo_success "Configuration file already exists." | ||
fi | ||
} | ||
|
||
select_profile() { | ||
echo "Select a deployment profile:" | ||
echo -e "1) Standard Setup: ${BLUE}[Recommended]${NC} For quick local testing - (App Server + Control Center + Unified Checkout + Essential Services)" | ||
echo "2) Full Stack Setup: For evaluating the complete product - (Standard + Monitoring + Scheduler)" | ||
echo "3) Development Setup: For contributors, Builds from source - (Standard + Monitoring + Scheduler) : may take up to 30 minutes" | ||
echo "4) Standalone App Server: For API-first integration testing (Core services only - Hyperswitch server, PostgreSQL, Redis)" | ||
|
||
local profile_selected=false | ||
while [ "$profile_selected" = false ]; do | ||
read -p "Enter your choice (1-4): " 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="development" | ||
profile_selected=true | ||
;; | ||
4) | ||
PROFILE="standalone" | ||
profile_selected=true | ||
;; | ||
*) | ||
echo_error "Invalid choice. Please enter 1, 2, 3, or 4." | ||
;; | ||
esac | ||
done | ||
|
||
echo "Selected profile: $PROFILE" | ||
} | ||
|
||
start_services() { | ||
echo "Starting Hyperswitch services with profile: $PROFILE" | ||
|
||
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 | ||
;; | ||
development) | ||
$DOCKER_COMPOSE -f docker-compose-development.yml 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 | ||
break | ||
fi | ||
|
||
RETRIES=$((RETRIES+1)) | ||
if [ $RETRIES -eq $MAX_RETRIES ]; then | ||
echo_error "Hyperswitch server did not become healthy in the expected time." | ||
echo_info "Check logs with: $DOCKER_COMPOSE logs hyperswitch-server" | ||
echo_warning "The setup process will continue, but some services might not work correctly." | ||
else | ||
echo "Waiting for server to become healthy... ($RETRIES/$MAX_RETRIES)" | ||
sleep $RETRY_INTERVAL | ||
fi | ||
done | ||
} | ||
|
||
print_access_info() { | ||
|
||
echo "Setup complete! You can access Hyperswitch services at:" | ||
|
||
if [ "$PROFILE" != "minimal" ]; then | ||
echo -e " • ${GREEN}Control Center${NC}: ${BLUE}http://localhost:9000${NC}" | ||
fi | ||
|
||
echo -e " • ${GREEN}API Server${NC}: ${BLUE}http://localhost:8080${NC}" | ||
|
||
if [ "$PROFILE" != "minimal" ]; then | ||
echo -e " • ${GREEN}Web SDK Demo${NC}: ${BLUE}http://localhost:9050${NC}" | ||
fi | ||
gorakhnathy7 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
if [ "$PROFILE" = "full" ] || [ "$PROFILE" = "development" ]; then | ||
echo -e " • ${GREEN}Monitoring (Grafana)${NC}: ${BLUE}http://localhost:3000${NC}" | ||
fi | ||
echo "Hyperswitch is now ready to use!" | ||
echo_info "To stop all services, run:" | ||
echo " $DOCKER_COMPOSE down" | ||
} | ||
|
||
# Main execution flow | ||
show_banner | ||
detect_docker_compose | ||
check_prerequisites | ||
setup_config | ||
select_profile | ||
start_services | ||
check_services_health | ||
print_access_info |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.