Skip to content

Commit

Permalink
Merge pull request #20 from sakan811/feat/build-exe
Browse files Browse the repository at this point in the history
feat: build executable files with GO
  • Loading branch information
sakan811 authored Sep 29, 2024
2 parents 6fba0c4 + c40b8d4 commit 7bfa1de
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 0 deletions.
Binary file added app-linux
Binary file not shown.
Binary file added app-mac
Binary file not shown.
Binary file added app-windows.exe
Binary file not shown.
46 changes: 46 additions & 0 deletions exe.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package main

import (
"fmt"
"os"
"os/exec"
)

// checkDockerRunning checks if Docker is running
func checkDockerRunning() bool {
cmd := exec.Command("docker", "info")
err := cmd.Run()
return err == nil // Return true if no error, meaning Docker is running
}

func waitForUser() {
fmt.Println("Press 'Enter' to exit...")
fmt.Scanln() // Wait for user input
}

func main() {
// Check if Docker is running
if !checkDockerRunning() {
fmt.Println("Error: Docker is not running. Please start Docker Desktop.")
waitForUser() // Keeps the terminal open
os.Exit(1)
}

// Run docker-compose in detached mode (-d flag)
cmd := exec.Command("docker-compose", "up", "-d")
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
cmd.Dir = "./"

err := cmd.Run()
if err != nil {
fmt.Printf("Error: %v\n", err)
waitForUser() // Keeps the terminal open
os.Exit(1)
}

fmt.Println("Please navigate to \033[34mhttp://localhost:5000/\033[0m to access the web-app.")

fmt.Println("Docker containers are running in detached mode.")
waitForUser() // Wait for the user before closing the terminal
}
3 changes: 3 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module find-place-web-app

go 1.23.1

0 comments on commit 7bfa1de

Please sign in to comment.