embed commit and repo in config codegen

This commit is contained in:
Laptop
2024-12-29 21:11:00 +02:00
parent 26dd353985
commit 325bd8dda3
4 changed files with 7 additions and 8 deletions

View File

@@ -21,7 +21,7 @@ RUN soundcloakctl config codegen
# this downloads JS modules (currently only hls.js) from jsdelivr and stores them locally for serving # this downloads JS modules (currently only hls.js) from jsdelivr and stores them locally for serving
RUN soundcloakctl js download RUN soundcloakctl js download
RUN CGO_ENABLED=0 GOARCH=${TARGETARCH} GOOS=${TARGETOS} go build -ldflags "-s -w -extldflags '-static' -X main.commit=`git rev-parse HEAD | head -c 7` -X main.repo=`git remote get-url origin`" -o ./app RUN CGO_ENABLED=0 GOARCH=${TARGETARCH} GOOS=${TARGETOS} go build -ldflags "-s -w -extldflags '-static'" -o ./app
RUN echo "soundcloak:x:5000:5000:Soundcloak user:/:/sbin/nologin" > /etc/minimal-passwd && \ RUN echo "soundcloak:x:5000:5000:Soundcloak user:/:/sbin/nologin" > /etc/minimal-passwd && \
echo "soundcloak:x:5000:" > /etc/minimal-group echo "soundcloak:x:5000:" > /etc/minimal-group

2
build
View File

@@ -1,3 +1,3 @@
templ generate templ generate
go generate ./lib/* go generate ./lib/*
go build -ldflags "-X main.commit=`git rev-parse HEAD | head -c 7` -X main.repo=`git remote get-url origin`" main.go go build main.go

View File

@@ -539,3 +539,6 @@ func init() {
} }
const Debug = false const Debug = false
const Commit = "unknown"
const Repo = "unknown"
const CommitURL = "unknown"

View File

@@ -25,10 +25,6 @@ import (
"git.maid.zone/stuff/soundcloak/templates" "git.maid.zone/stuff/soundcloak/templates"
) )
// see build script/dockerfile
var commit = "unknown"
var repo = "unknown"
func main() { func main() {
app := fiber.New(fiber.Config{ app := fiber.New(fiber.Config{
Prefork: cfg.Prefork, Prefork: cfg.Prefork,
@@ -346,8 +342,8 @@ func main() {
app.Get("/_/info", func(c *fiber.Ctx) error { app.Get("/_/info", func(c *fiber.Ctx) error {
return c.JSON(info{ return c.JSON(info{
Commit: commit, Commit: cfg.Commit,
Repo: repo, Repo: cfg.Repo,
ProxyImages: cfg.ProxyImages, ProxyImages: cfg.ProxyImages,
ProxyStreams: cfg.ProxyStreams, ProxyStreams: cfg.ProxyStreams,
Restream: cfg.Restream, Restream: cfg.Restream,