mirror of
https://github.com/SecurityBrewery/catalyst.git
synced 2025-12-07 15:52:47 +01:00
Compare commits
6 Commits
v0.13.8-rc
...
v0.13.8-rc
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
86f4aa1d28 | ||
|
|
7b92d59dff | ||
|
|
6a8c92f1f6 | ||
|
|
9285aec468 | ||
|
|
97d0cd3428 | ||
|
|
baba5b7a45 |
@@ -18,6 +18,8 @@ dockers:
|
|||||||
- "ghcr.io/securitybrewery/catalyst:main"
|
- "ghcr.io/securitybrewery/catalyst:main"
|
||||||
- "{{if not .Prerelease}}ghcr.io/securitybrewery/catalyst:latest{{end}}"
|
- "{{if not .Prerelease}}ghcr.io/securitybrewery/catalyst:latest{{end}}"
|
||||||
- "ghcr.io/securitybrewery/catalyst:{{.Tag}}"
|
- "ghcr.io/securitybrewery/catalyst:{{.Tag}}"
|
||||||
|
extra_files:
|
||||||
|
- docker/entrypoint.sh
|
||||||
|
|
||||||
archives:
|
archives:
|
||||||
- format: tar.gz
|
- format: tar.gz
|
||||||
|
|||||||
38
app/app.go
38
app/app.go
@@ -1,7 +1,6 @@
|
|||||||
package app
|
package app
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
|
||||||
"os"
|
"os"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
@@ -39,47 +38,14 @@ func App(dir string, test bool) (*pocketbase.PocketBase, error) {
|
|||||||
reaction.BindHooks(app, test)
|
reaction.BindHooks(app, test)
|
||||||
|
|
||||||
app.OnAfterBootstrap().Add(func(e *core.BootstrapEvent) error {
|
app.OnAfterBootstrap().Add(func(e *core.BootstrapEvent) error {
|
||||||
if err := MigrateDBs(e.App); err != nil {
|
return MigrateDBs(e.App)
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
if err := SetFlags(e.App, flags); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
if HasFlag(e.App, "demo") {
|
|
||||||
bindDemoHooks(e.App)
|
|
||||||
}
|
|
||||||
|
|
||||||
if appURL != "" {
|
|
||||||
s := e.App.Settings()
|
|
||||||
s.Meta.AppUrl = appURL
|
|
||||||
|
|
||||||
if err := e.App.Dao().SaveSettings(s); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return e.App.RefreshSettings()
|
|
||||||
})
|
})
|
||||||
|
|
||||||
app.OnBeforeServe().Add(addRoutes())
|
app.OnBeforeServe().Add(setupServer(appURL, flags))
|
||||||
|
|
||||||
return app, nil
|
return app, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func bindDemoHooks(app core.App) {
|
|
||||||
app.OnRecordBeforeCreateRequest("files", "reactions").Add(func(e *core.RecordCreateEvent) error {
|
|
||||||
return fmt.Errorf("cannot create %s in demo mode", e.Record.Collection().Name)
|
|
||||||
})
|
|
||||||
app.OnRecordBeforeUpdateRequest("files", "reactions").Add(func(e *core.RecordUpdateEvent) error {
|
|
||||||
return fmt.Errorf("cannot update %s in demo mode", e.Record.Collection().Name)
|
|
||||||
})
|
|
||||||
app.OnRecordBeforeDeleteRequest("files", "reactions").Add(func(e *core.RecordDeleteEvent) error {
|
|
||||||
return fmt.Errorf("cannot delete %s in demo mode", e.Record.Collection().Name)
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
func dev() bool {
|
func dev() bool {
|
||||||
return strings.HasPrefix(os.Args[0], os.TempDir())
|
return strings.HasPrefix(os.Args[0], os.TempDir())
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package app
|
package app
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/http/httputil"
|
"net/http/httputil"
|
||||||
"net/url"
|
"net/url"
|
||||||
@@ -12,8 +13,25 @@ import (
|
|||||||
"github.com/SecurityBrewery/catalyst/ui"
|
"github.com/SecurityBrewery/catalyst/ui"
|
||||||
)
|
)
|
||||||
|
|
||||||
func addRoutes() func(*core.ServeEvent) error {
|
func setupServer(appURL string, flags []string) func(e *core.ServeEvent) error {
|
||||||
return func(e *core.ServeEvent) error {
|
return func(e *core.ServeEvent) error {
|
||||||
|
if err := SetFlags(e.App, flags); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
if HasFlag(e.App, "demo") {
|
||||||
|
bindDemoHooks(e.App)
|
||||||
|
}
|
||||||
|
|
||||||
|
if appURL != "" {
|
||||||
|
s := e.App.Settings()
|
||||||
|
s.Meta.AppUrl = appURL
|
||||||
|
|
||||||
|
if err := e.App.Dao().SaveSettings(s); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
e.Router.GET("/", func(c echo.Context) error {
|
e.Router.GET("/", func(c echo.Context) error {
|
||||||
return c.Redirect(http.StatusFound, "/ui/")
|
return c.Redirect(http.StatusFound, "/ui/")
|
||||||
})
|
})
|
||||||
@@ -37,10 +55,22 @@ func addRoutes() func(*core.ServeEvent) error {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
return nil
|
return e.App.RefreshSettings()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func bindDemoHooks(app core.App) {
|
||||||
|
app.OnRecordBeforeCreateRequest("files", "reactions").Add(func(e *core.RecordCreateEvent) error {
|
||||||
|
return fmt.Errorf("cannot create %s in demo mode", e.Record.Collection().Name)
|
||||||
|
})
|
||||||
|
app.OnRecordBeforeUpdateRequest("files", "reactions").Add(func(e *core.RecordUpdateEvent) error {
|
||||||
|
return fmt.Errorf("cannot update %s in demo mode", e.Record.Collection().Name)
|
||||||
|
})
|
||||||
|
app.OnRecordBeforeDeleteRequest("files", "reactions").Add(func(e *core.RecordDeleteEvent) error {
|
||||||
|
return fmt.Errorf("cannot delete %s in demo mode", e.Record.Collection().Name)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
func staticFiles() func(echo.Context) error {
|
func staticFiles() func(echo.Context) error {
|
||||||
return func(c echo.Context) error {
|
return func(c echo.Context) error {
|
||||||
if dev() {
|
if dev() {
|
||||||
|
|||||||
@@ -11,4 +11,8 @@ VOLUME /usr/local/bin/catalyst_data
|
|||||||
HEALTHCHECK --interval=5s --timeout=3s --retries=3 \
|
HEALTHCHECK --interval=5s --timeout=3s --retries=3 \
|
||||||
CMD curl -f http://localhost:8080/health || exit 1
|
CMD curl -f http://localhost:8080/health || exit 1
|
||||||
|
|
||||||
CMD ["/usr/local/bin/catalyst", "serve", "--http", "0.0.0.0:8080"]
|
COPY docker/entrypoint.sh /entrypoint.sh
|
||||||
|
|
||||||
|
RUN chmod +x /entrypoint.sh
|
||||||
|
|
||||||
|
CMD ["/entrypoint.sh"]
|
||||||
15
docker/entrypoint.sh
Normal file
15
docker/entrypoint.sh
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Set the flags
|
||||||
|
FLAGS=""
|
||||||
|
if [ -n "$CATALYST_FLAGS" ]; then
|
||||||
|
FLAGS="$CATALYST_FLAGS"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Set the app url
|
||||||
|
APP_URL=""
|
||||||
|
if [ -n "$CATALYST_APP_URL" ]; then
|
||||||
|
APP_URL="$CATALYST_APP_URL"
|
||||||
|
fi
|
||||||
|
|
||||||
|
/usr/local/bin/catalyst serve --http 0.0.0.0:8080 --flags "$FLAGS" --app-url "$APP_URL"
|
||||||
@@ -30,8 +30,14 @@ const {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
const age = (ticket: Ticket) =>
|
const age = (ticket: Ticket) => {
|
||||||
intervalToDuration({ start: new Date(ticket.created), end: new Date() }).days
|
const days = intervalToDuration({ start: new Date(ticket.created), end: new Date() }).days
|
||||||
|
|
||||||
|
if (!days) return 'today'
|
||||||
|
if (days === 1) return 'yesterday'
|
||||||
|
|
||||||
|
return `${days} days`
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
@@ -45,7 +51,7 @@ const age = (ticket: Ticket) =>
|
|||||||
<Separator orientation="vertical" class="hidden h-4 sm:block" />
|
<Separator orientation="vertical" class="hidden h-4 sm:block" />
|
||||||
<span class="text-sm text-muted-foreground">{{ ticket.expand.type.singular }}</span>
|
<span class="text-sm text-muted-foreground">{{ ticket.expand.type.singular }}</span>
|
||||||
<Separator orientation="vertical" class="hidden h-4 sm:block" />
|
<Separator orientation="vertical" class="hidden h-4 sm:block" />
|
||||||
<span class="text-sm text-muted-foreground">Open since {{ age(ticket) }} days</span>
|
<span class="text-sm text-muted-foreground">Open since {{ age(ticket) }}</span>
|
||||||
<RouterLink
|
<RouterLink
|
||||||
:to="{
|
:to="{
|
||||||
name: 'tickets',
|
name: 'tickets',
|
||||||
|
|||||||
Reference in New Issue
Block a user