Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions .gemini/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,6 @@
"runtime": "Go ≥1.18"
},

"model": {
"name": "gemini-3-pro",
"temperature": 0.2,
"maxTokens": 8192
},

"context": {
"fileName": ["GEMINI.md"],
"hierarchical": true
Expand Down
4 changes: 2 additions & 2 deletions INSTALLATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ This is the simplest method for Debian-based systems like Ubuntu, Debian, Linux

```bash
# Download the latest .deb release
wget https://github.com/nexoral/ContainDB/releases/download/v7.19.43-stable/containDB_7.19.43-stable_amd64.deb
wget https://github.com/nexoral/ContainDB/releases/download/v8.19.43-stable/containDB_8.19.43-stable_amd64.deb

# Install the package
sudo dpkg -i containDB_7.19.43-stable_amd64.deb
sudo dpkg -i containDB_8.19.43-stable_amd64.deb

# If you see dependency errors, run:
sudo apt-get install -f
Expand Down
2 changes: 1 addition & 1 deletion Scripts/installer.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ ARCH=$(dpkg --print-architecture)

echo "Detected architecture: $ARCH"

VERSION="7.19.43-stable"
VERSION="8.19.43-stable"

if [[ "$ARCH" == "amd64" ]]; then
PKG="containdb_${VERSION}_amd64.deb"
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
7.19.43-stable
8.19.43-stable
2 changes: 1 addition & 1 deletion npm/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "containdb",
"version": "7.19.43",
"version": "8.19.43",
"description": "The Ultimate Docker Database Manager. Automate the creation, management, and monitoring of containerized databases (MongoDB, MySQL, PostgreSQL, Redis) and their GUI tools (Compass, phpMyAdmin, PgAdmin, RedisInsight) with a simple CLI. No complex Docker commands—just productivity.",
"bin": {
"containdb": "./InstallController.js"
Expand Down
2 changes: 1 addition & 1 deletion src/Core/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
)

func main() {
VERSION := "7.19.43-stable"
VERSION := "8.19.43-stable"

// handle version flag without requiring sudo
if len(os.Args) > 1 && os.Args[1] == "--version" {
Expand Down
7 changes: 6 additions & 1 deletion src/Docker/DockerComposeMaker.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,12 @@ func getContainerInfo(containerName string) (ContainerInfo, error) {
for _, env := range envVars {
if strings.HasPrefix(env, "PMA_HOST=") ||
strings.HasPrefix(env, "PMA_PORT=") ||
strings.HasPrefix(env, "PMA_USER=") {
strings.HasPrefix(env, "PMA_USER=") ||
strings.HasPrefix(env, "PMA_PASSWORD=") ||
strings.HasPrefix(env, "PMA_DATABASE=") ||
strings.HasPrefix(env, "PMA_ARBITRARY=") ||
strings.HasPrefix(env, "PMA_SSL=") ||
strings.HasPrefix(env, "PMA_SSL_VERIFY=") {
filteredEnvVars = append(filteredEnvVars, env)
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/base/Banner.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"github.com/fatih/color"
)

const Version = "7.19.43-stable"
const Version = "8.19.43-stable"

func ShowBanner() {
// Define styles
Expand Down
150 changes: 148 additions & 2 deletions src/tools/PhpMyAdmin.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,16 @@ import (
"github.com/manifoldco/promptui"
)

// CloudDBConfig holds cloud database connection parameters
type CloudDBConfig struct {
Host string
Port string
Username string
Password string
Database string // Optional
EnableSSL bool
}

func StartPHPMyAdmin() {
// Check if phpMyAdmin is already running
if Docker.IsContainerRunning("phpmyadmin", true) {
Expand All @@ -30,12 +40,55 @@ func StartPHPMyAdmin() {
}
}

// Detect local MySQL/MariaDB containers
sqlContainers := Docker.ListOfContainers([]string{"mysql", "mariadb"})
if len(sqlContainers) == 0 {
fmt.Println("No running MySQL/MariaDB containers found.")

// Present connection type selection
connectionType := selectConnectionType(len(sqlContainers) > 0)
if connectionType == "exit" {
fmt.Println("Exiting phpMyAdmin setup.")
return
}

// Branch to appropriate handler
if connectionType == "local" {
startPHPMyAdminLocal(sqlContainers)
} else {
startPHPMyAdminCloud()
}
}

// selectConnectionType prompts user to choose between local container or cloud database
func selectConnectionType(hasLocalContainers bool) string {
items := []string{}

if hasLocalContainers {
items = append(items, "Local Container")
}
items = append(items, "Cloud Database", "Exit")

prompt := promptui.Select{
Label: "Select phpMyAdmin connection type",
Items: items,
}
_, selected, err := prompt.Run()
if err != nil {
fmt.Println("\n⚠️ Interrupt received, rolling back...")
Cleanup()
return "exit"
}

if selected == "Exit" {
return "exit"
} else if selected == "Local Container" {
return "local"
} else {
return "cloud"
}
}

// startPHPMyAdminLocal handles local container connection (existing logic)
func startPHPMyAdminLocal(sqlContainers []string) {
items := append(sqlContainers, "Exit")
prompt := promptui.Select{
Label: "Select a SQL container to link with phpMyAdmin",
Expand All @@ -45,6 +98,7 @@ func StartPHPMyAdmin() {
if err != nil {
fmt.Println("\n⚠️ Interrupt received, rolling back...")
Cleanup()
return
}
if selectedContainer == "Exit" {
fmt.Println("Exiting phpMyAdmin setup.")
Expand Down Expand Up @@ -80,3 +134,95 @@ func StartPHPMyAdmin() {
fmt.Printf("phpMyAdmin started. Access it at http://localhost:%s\n", port)
}
}

// startPHPMyAdminCloud handles cloud database connection (new logic)
func startPHPMyAdminCloud() {
config := getCloudConnectionConfig()
port := AskForInput("Enter host port to expose phpMyAdmin", "8080")

// Validate inputs
if config.Host == "" {
fmt.Println("Error: Database host cannot be empty")
return
}
if config.Username == "" {
fmt.Println("Error: Username cannot be empty")
return
}
if config.Password == "" {
fmt.Println("Error: Password cannot be empty")
return
}

// Pull image
fmt.Printf("Pulling phpMyAdmin image...\n")
cmd := exec.Command("docker", "pull", "phpmyadmin/phpmyadmin")
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
_ = cmd.Run()

// Build docker run args
args := []string{
"run", "-d",
"--restart", "unless-stopped",
"--network", "bridge",
"--name", "phpmyadmin",
"-e", "PMA_ARBITRARY=1",
"-e", fmt.Sprintf("PMA_HOST=%s", config.Host),
"-e", fmt.Sprintf("PMA_PORT=%s", config.Port),
"-e", fmt.Sprintf("PMA_USER=%s", config.Username),
"-e", fmt.Sprintf("PMA_PASSWORD=%s", config.Password),
}

if config.Database != "" {
args = append(args, "-e", fmt.Sprintf("PMA_DATABASE=%s", config.Database))
}

if config.EnableSSL {
args = append(args, "-e", "PMA_SSL=1")
} else {
args = append(args, "-e", "PMA_SSL=0")
}

// Always disable SSL verification by default
args = append(args, "-e", "PMA_SSL_VERIFY=0")

args = append(args, "-p", fmt.Sprintf("%s:80", port))
args = append(args, "phpmyadmin/phpmyadmin")

fmt.Println("Running: docker", strings.Join(args, " "))
cmd = exec.Command("docker", args...)
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
if err := cmd.Run(); err != nil {
fmt.Println("Error starting phpMyAdmin:", err)
} else {
fmt.Printf("\n✅ phpMyAdmin started! Access it at http://localhost:%s\n", port)
fmt.Printf("📋 Cloud database connection:\n")
fmt.Printf(" Host: %s:%s\n", config.Host, config.Port)
fmt.Printf(" User: %s\n", config.Username)
fmt.Printf(" SSL: %v\n", config.EnableSSL)
}
}

// getCloudConnectionConfig collects cloud database connection parameters from user
func getCloudConnectionConfig() CloudDBConfig {
fmt.Println("\n🌐 Cloud Database Configuration")

host := AskForInput("Enter database host (e.g., learn-mysql-db.mysql.database.azure.com)", "")
port := AskForInput("Enter database port", "3306")
username := AskForInput("Enter database username", "")
password := AskForInput("Enter database password", "")
database := AskForInput("Enter database name (optional, leave empty for none)", "")

enableSSL := Docker.AskYesNo("Enable SSL connection?")

return CloudDBConfig{
Host: strings.TrimSpace(host),
Port: strings.TrimSpace(port),
Username: strings.TrimSpace(username),
Password: strings.TrimSpace(password),
Database: strings.TrimSpace(database),
EnableSSL: enableSSL,
}
}
Loading