-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
15 changed files
with
438 additions
and
0 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 @@ | ||
ARG NODE_VERSION=23.6 | ||
ARG ALPINE_VERSION=3.21 | ||
ARG GOLANG_VERSION=1.23 | ||
ARG JAEGERUI_VERSION=v1.65.0 | ||
|
||
FROM scratch AS jaegerui-src | ||
ARG JAEGERUI_REPO=https://github.com/jaegertracing/jaeger-ui.git | ||
ARG JAEGERUI_VERSION | ||
ADD ${JAEGERUI_REPO}#${JAEGERUI_VERSION} / | ||
|
||
FROM --platform=$BUILDPLATFORM node:${NODE_VERSION}-alpine${ALPINE_VERSION} AS builder | ||
WORKDIR /work/jaeger-ui | ||
COPY --from=jaegerui-src / . | ||
RUN npm install | ||
WORKDIR /work/jaeger-ui/packages/jaeger-ui | ||
RUN NODE_ENVIRONMENT=production npm run build | ||
# failed to find a way to avoid legacy build | ||
RUN rm build/static/*-legacy* && rm build/static/*.png | ||
|
||
FROM scratch AS jaegerui | ||
COPY --from=builder /work/jaeger-ui/packages/jaeger-ui/build / | ||
|
||
FROM alpine AS compressor | ||
RUN --mount=target=/in,from=jaegerui <<EOT | ||
set -ex | ||
mkdir -p /out | ||
cp -a /in/. /out | ||
cd /out | ||
find . -type f -exec sh -c 'gzip -9 -c "$1" > "$1.tmp" && mv "$1.tmp" "$1"' _ {} \; | ||
# stop | ||
EOT | ||
|
||
FROM scratch AS jaegerui-compressed | ||
COPY --from=compressor /out / |
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,43 @@ | ||
package main | ||
|
||
import ( | ||
"flag" | ||
"log" | ||
"net" | ||
"os" | ||
|
||
"github.com/pkg/errors" | ||
jaegerui "github.com/tonistiigi/jaeger-ui-rest" | ||
) | ||
|
||
func main() { | ||
if err := run(); err != nil { | ||
log.Printf("Error: %+v", err) | ||
os.Exit(1) | ||
} | ||
} | ||
|
||
func run() error { | ||
var opt struct { | ||
addr string | ||
} | ||
|
||
flag.StringVar(&opt.addr, "addr", "127.0.0.1:0", "address to listen on") | ||
flag.Parse() | ||
|
||
args := flag.Args() | ||
if len(args) > 0 { | ||
return errors.Errorf("unknown arguments: %v", args) | ||
} | ||
|
||
s := jaegerui.NewServer(jaegerui.Config{}) | ||
|
||
ln, err := net.Listen("tcp", opt.addr) | ||
if err != nil { | ||
return errors.Wrapf(err, "failed to listen on %s", opt.addr) | ||
} | ||
|
||
log.Printf("Listening on %s", ln.Addr().String()) | ||
|
||
return s.Serve(ln) | ||
} |
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,42 @@ | ||
package jaegerui | ||
|
||
import ( | ||
"bytes" | ||
"encoding/json" | ||
"slices" | ||
) | ||
|
||
type Menu struct { | ||
Label string `json:"label"` | ||
Items []MenuItem `json:"items"` | ||
} | ||
|
||
type MenuItem struct { | ||
Label string `json:"label"` | ||
URL string `json:"url"` | ||
} | ||
|
||
type Config struct { | ||
Dependencies struct { | ||
MenuEnabled bool `json:"menuEnabled"` | ||
} `json:"dependencies"` | ||
Monitor struct { | ||
MenuEnabled bool `json:"menuEnabled"` | ||
} `json:"monitor"` | ||
ArchiveEnabled bool `json:"archiveEnabled"` | ||
Menu []Menu `json:"menu"` | ||
} | ||
|
||
func (cfg Config) Inject(name string, dt []byte) ([]byte, bool) { | ||
if name != "index.html" { | ||
return dt, false | ||
} | ||
|
||
cfgData, err := json.Marshal(cfg) | ||
if err != nil { | ||
return dt, false | ||
} | ||
|
||
dt = bytes.Replace(dt, []byte("const JAEGER_CONFIG = DEFAULT_CONFIG;"), slices.Concat([]byte(`const JAEGER_CONFIG = `), cfgData, []byte(`;`)), 1) | ||
return dt, true | ||
} |
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,117 @@ | ||
package decompress | ||
|
||
import ( | ||
"bytes" | ||
"compress/gzip" | ||
"io" | ||
"io/fs" | ||
"path/filepath" | ||
"sync" | ||
) | ||
|
||
type decompressFS struct { | ||
fs.FS | ||
mu sync.Mutex | ||
data map[string][]byte | ||
inject Injector | ||
} | ||
|
||
type Injector interface { | ||
Inject(name string, dt []byte) ([]byte, bool) | ||
} | ||
|
||
func NewFS(fsys fs.FS, injector Injector) fs.FS { | ||
return &decompressFS{ | ||
FS: fsys, | ||
data: make(map[string][]byte), | ||
inject: injector, | ||
} | ||
} | ||
|
||
func (d *decompressFS) Open(name string) (fs.File, error) { | ||
name = filepath.Clean(name) | ||
|
||
f, err := d.FS.Open(name) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
d.mu.Lock() | ||
defer d.mu.Unlock() | ||
|
||
dt, ok := d.data[name] | ||
if ok { | ||
return &staticFile{ | ||
Reader: bytes.NewReader(dt), | ||
f: f, | ||
}, nil | ||
} | ||
|
||
fi, err := f.Stat() | ||
if err != nil { | ||
f.Close() | ||
return nil, err | ||
} | ||
|
||
if fi.IsDir() { | ||
return f, nil | ||
} | ||
|
||
gzReader, err := gzip.NewReader(f) | ||
if err != nil { | ||
f.Close() | ||
return nil, err | ||
} | ||
|
||
buf := &bytes.Buffer{} | ||
if _, err := io.Copy(buf, gzReader); err != nil { | ||
f.Close() | ||
return nil, err | ||
} | ||
|
||
dt = buf.Bytes() | ||
if d.inject != nil { | ||
newdt, ok := d.inject.Inject(name, dt) | ||
if ok { | ||
dt = newdt | ||
} | ||
} | ||
|
||
d.data[name] = dt | ||
|
||
return &staticFile{ | ||
Reader: bytes.NewReader(dt), | ||
f: f, | ||
}, nil | ||
} | ||
|
||
type staticFile struct { | ||
*bytes.Reader | ||
f fs.File | ||
} | ||
|
||
func (s *staticFile) Stat() (fs.FileInfo, error) { | ||
fi, err := s.f.Stat() | ||
if err != nil { | ||
return nil, err | ||
} | ||
return &fileInfo{ | ||
FileInfo: fi, | ||
size: int64(s.Len()), | ||
}, nil | ||
} | ||
|
||
func (s *staticFile) Close() error { | ||
return s.f.Close() | ||
} | ||
|
||
type fileInfo struct { | ||
fs.FileInfo | ||
size int64 | ||
} | ||
|
||
func (f *fileInfo) Size() int64 { | ||
return f.size | ||
} | ||
|
||
var _ fs.File = &staticFile{} |
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,3 @@ | ||
target "public" { | ||
output = ["./public"] | ||
} |
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,17 @@ | ||
package jaegerui | ||
|
||
import ( | ||
"embed" | ||
"io/fs" | ||
"net/http" | ||
|
||
"github.com/tonistiigi/jaeger-ui-rest/decompress" | ||
) | ||
|
||
//go:embed public | ||
var staticFiles embed.FS | ||
|
||
func FS(cfg Config) http.FileSystem { | ||
files, _ := fs.Sub(staticFiles, "public") | ||
return http.FS(decompress.NewFS(files, cfg)) | ||
} |
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,5 @@ | ||
module github.com/tonistiigi/jaeger-ui-rest | ||
|
||
go 1.23.1 | ||
|
||
require github.com/pkg/errors v0.9.1 |
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,2 @@ | ||
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= | ||
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,3 @@ | ||
### jaeger-ui-rest | ||
|
||
[Jaeger UI](https://github.com/jaegertracing/jaeger-ui) server with only the UI component and simple REST API for loading pregenerated JSON traces. |
Oops, something went wrong.