-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add web UI for the `.gebug/config.yaml` configuration
- Loading branch information
Showing
32 changed files
with
10,128 additions
and
11 deletions.
There are no files selected for viewing
This file contains 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,34 @@ | ||
name: webui | ||
on: | ||
- push | ||
paths: | ||
- "webui/*" | ||
branches: | ||
- master | ||
- main | ||
|
||
env: | ||
IMAGE_NAME: gebug-webui | ||
|
||
jobs: | ||
dockerhub: | ||
name: Push Web UI Docker image to Docker Hub | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Check out the repo | ||
uses: actions/checkout@v2 | ||
- | ||
name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v1 | ||
- uses: docker/login-action@v1 | ||
with: | ||
username: gebug | ||
password: ${{ secrets.DOCKERHUB_PASS }} | ||
- name: Build & Push to Docker Hub | ||
id: docker_build | ||
uses: docker/build-push-action@v2 | ||
with: | ||
context: . | ||
file: webui/Dockerfile | ||
push: true | ||
tags: gebug/webui:latest |
This file contains 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,94 @@ | ||
package cmd | ||
|
||
import ( | ||
"fmt" | ||
"github.com/moshebe/gebug/pkg/osutil" | ||
"github.com/moshebe/gebug/pkg/web" | ||
"github.com/pkg/browser" | ||
"github.com/spf13/cobra" | ||
"go.uber.org/zap" | ||
"io/ioutil" | ||
"os" | ||
"sync" | ||
) | ||
|
||
var projectPath string | ||
var uiPort int | ||
|
||
const ( | ||
imageName = "gebug/webui" | ||
defaultUIPort = 3030 | ||
) | ||
|
||
func init() { | ||
uiCmd.PersistentFlags().StringVar(&projectPath, "path", ".", "project directory path") | ||
uiCmd.PersistentFlags().IntVar(&uiPort, "port", defaultUIPort, "web UI port") | ||
|
||
rootCmd.AddCommand(uiCmd) | ||
} | ||
|
||
var uiCmd = &cobra.Command{ | ||
Use: "ui", | ||
Short: "Start Gebug web UI", | ||
Long: "Start web UI that manages the Gebug configurations", | ||
Run: func(cmd *cobra.Command, args []string) { | ||
zap.L().Info("🚀 Launching Gebug web UI...") | ||
|
||
if projectPath == "." || projectPath == "" { | ||
zap.L().Debug("Resolving current project path", zap.String("projectPath", projectPath)) | ||
cwd, err := os.Getwd() | ||
if err != nil { | ||
zap.L().Fatal("Failed to get current working directory", zap.Error(err)) | ||
} | ||
projectPath = cwd | ||
} | ||
|
||
file, err := ioutil.TempFile("", "gebug-webui-docker-compose.*.yml") | ||
if err != nil { | ||
zap.L().Fatal("Failed to create temporary file for generating docker-compose", zap.Error(err)) | ||
} | ||
|
||
zap.L().Debug("Generating docker-compose configuration", zap.String("path", file.Name())) | ||
|
||
err = web.RenderDockerCompose(&web.Opts{ | ||
ImageName: imageName, | ||
Port: uiPort, | ||
Location: projectPath, | ||
}, file) | ||
|
||
if err != nil { | ||
zap.L().Fatal("Failed to generate configuration for docker-compose", zap.Error(err)) | ||
} | ||
|
||
prerequisites := []string{"docker", "docker-compose"} | ||
for _, bin := range prerequisites { | ||
if !osutil.CommandExists(bin) { | ||
zap.S().Fatalf("'%s' was not found, please make sure it is installed correctly...", bin) | ||
} | ||
} | ||
|
||
var wg sync.WaitGroup | ||
wg.Add(1) | ||
go func() { | ||
defer func() { | ||
wg.Done() | ||
}() | ||
if err := osutil.RunCommand(fmt.Sprintf("docker-compose -f %s up", file.Name())); err != nil { | ||
zap.L().Fatal("Failed to start web ui", zap.Error(err)) | ||
} | ||
}() | ||
|
||
url := fmt.Sprintf("http://localhost:%d", uiPort) | ||
err = web.ReadinessProbe(url, verbose) | ||
if err != nil { | ||
zap.L().Fatal("Failed to start web ui server", zap.String("url", url), zap.Error(err)) | ||
} | ||
zap.S().Infof("🔗 Ready on %s", url) | ||
err = browser.OpenURL(url) | ||
if err != nil { | ||
zap.L().Error("Failed to launch browser with url", zap.String("url", url), zap.Error(err)) | ||
} | ||
wg.Wait() | ||
zap.L().Info("Finished") | ||
}, | ||
} |
This file contains 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 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 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 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 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,11 @@ | ||
version: '3' | ||
services: | ||
gebug-webui: | ||
image: gebug/webui | ||
environment: | ||
- PORT=3030 | ||
- VUE_APP_GEBUG_PROJECT_LOCATION=/Users/me/Dev/awesome-app | ||
ports: | ||
- 3030:3030 | ||
volumes: | ||
- /Users/me/Dev/awesome-app:/Users/me/Dev/awesome-app |
Oops, something went wrong.