Skip to content

Commit

Permalink
chore: check if docker runs remotely
Browse files Browse the repository at this point in the history
If not, return an error message
  • Loading branch information
bjarneo committed Nov 15, 2024
1 parent 7710215 commit e0074d7
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -251,10 +251,20 @@ func ExecuteCommand(logger *Logger, command string, description string) (*Comman
return result, nil
}

// CheckDocker checks if Docker is installed and running
func CheckDocker(logger *Logger) error {
_, err := ExecuteCommand(logger, "docker info", "Checking Docker installation")
return err
// CheckDocker checks if Docker is installed and running locally and remotely
func CheckDocker(config *Config, logger *Logger) error {
// Check local Docker
if _, err := ExecuteCommand(logger, "docker info", "Checking local Docker installation"); err != nil {
return fmt.Errorf("local Docker check failed: %v", err)
}

// Check remote Docker
remoteCmd := fmt.Sprintf("%s \"docker info\"", getSSHCommand(config))
if _, err := ExecuteCommand(logger, remoteCmd, "Checking remote Docker installation"); err != nil {
return fmt.Errorf("remote Docker check failed - please ensure Docker is installed on %s: %v", config.Host, err)
}

return nil
}

// getSSHKeyFlag returns the SSH key flag if SSHKey is set
Expand Down Expand Up @@ -419,7 +429,7 @@ func Deploy(config *Config, logger *Logger) error {
}

// Preliminary checks
if err := CheckDocker(logger); err != nil {
if err := CheckDocker(config, logger); err != nil {
return err
}

Expand Down

0 comments on commit e0074d7

Please sign in to comment.