Skip to content

Commit

Permalink
more cleanup (#138)
Browse files Browse the repository at this point in the history
* tidy

* ui test

* screenshots

* embed web ui files
  • Loading branch information
joshlarsen authored Nov 5, 2024
1 parent 66b1b88 commit 4a20e90
Show file tree
Hide file tree
Showing 12 changed files with 36 additions and 1,248 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/lint.go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ permissions:
pull-requests: read
jobs:
golangci:
name: golangci-lint
name: Go
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ permissions:
contents: write
jobs:
goreleaser:
name: Go Release
runs-on: ubuntu-latest
steps:
- name: Checkout
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test.go.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Go Tests
name: Go Test
on:
pull_request:
jobs:
Expand Down
20 changes: 10 additions & 10 deletions .github/workflows/docker.ui.yml → .github/workflows/ui.yml
Original file line number Diff line number Diff line change
@@ -1,30 +1,30 @@
name: Docker UI
name: Web UI
on:
pull_request:
jobs:
test:
name: Web UI Test
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Build Docker container
run: docker build -t ui-app .

- name: Start Docker container
- name: Start Server
env:
HOST: 0.0.0.0
PORT: 8000
run: |
docker run -d -e HOST -e PORT -p 8000:8000 --name ui ui-app
sleep 5
make run &
- name: Wait for server to start
run: |
while ! curl -s http://localhost:8000 > /dev/null 2>&1; do
sleep 1
done
- uses: actions/setup-node@v4
with:
node-version: lts/*

- name: Debug
run: curl -v http://localhost:8000

- name: Setup npm
run: npm init -y
Expand Down
26 changes: 17 additions & 9 deletions cmd/reaper/main.go
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
package main

import (
"embed"
"fmt"
"log"
"log/slog"
"net/http"
"os"
"strings"
"time"

"github.com/gofiber/contrib/websocket"
"github.com/gofiber/fiber/v2"
"github.com/gofiber/fiber/v2/middleware/cors"
"github.com/gofiber/fiber/v2/middleware/filesystem"
"github.com/gofiber/fiber/v2/middleware/recover"

"github.com/ghostsecurity/reaper/internal/database"
Expand All @@ -19,6 +22,9 @@ import (
"github.com/ghostsecurity/reaper/internal/middleware"
)

//go:embed dist/*
var static embed.FS

func main() {
// We don't need the time field in the local logs
opts := slog.HandlerOptions{
Expand Down Expand Up @@ -114,15 +120,17 @@ func main() {
// settings

// serve static frontend files
app.Static("/", "./dist")

// if 404, serve index.html
app.Use(func(c *fiber.Ctx) error {
if c.Method() != fiber.MethodGet {
return c.SendStatus(fiber.StatusNotFound)
}
return c.SendFile("./dist/index.html")
})
app.Use("/", filesystem.New(filesystem.Config{
Root: http.FS(static),
PathPrefix: "dist",
Browse: true,
NotFoundFile: "dist/index.html",
}))
app.Use("/assets", filesystem.New(filesystem.Config{
Root: http.FS(static),
PathPrefix: "dist/assets",
Browse: true,
}))

// Start server
host := os.Getenv("HOST")
Expand Down
4 changes: 4 additions & 0 deletions docs/screens/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
![reaper-01.png](reaper-01.png)
![reaper-02.png](reaper-02.png)
![reaper-03.png](reaper-03.png)
![reaper-04.png](reaper-04.png)
Binary file added docs/screens/reaper-01.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/screens/reaper-02.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/screens/reaper-03.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/screens/reaper-04.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 4a20e90

Please sign in to comment.