From 325bd8dda31f5c3944b4e4b934f3b2058cb2f1b5 Mon Sep 17 00:00:00 2001 From: Laptop Date: Sun, 29 Dec 2024 21:11:00 +0200 Subject: [PATCH] embed commit and repo in config codegen --- Dockerfile | 2 +- build | 2 +- lib/cfg/init.go | 3 +++ main.go | 8 ++------ 4 files changed, 7 insertions(+), 8 deletions(-) diff --git a/Dockerfile b/Dockerfile index ded6aa8..8361a33 100644 --- a/Dockerfile +++ b/Dockerfile @@ -21,7 +21,7 @@ RUN soundcloakctl config codegen # this downloads JS modules (currently only hls.js) from jsdelivr and stores them locally for serving 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 && \ echo "soundcloak:x:5000:" > /etc/minimal-group diff --git a/build b/build index b2ad355..3541284 100755 --- a/build +++ b/build @@ -1,3 +1,3 @@ templ generate 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 \ No newline at end of file +go build main.go \ No newline at end of file diff --git a/lib/cfg/init.go b/lib/cfg/init.go index 24f5862..27c1503 100644 --- a/lib/cfg/init.go +++ b/lib/cfg/init.go @@ -539,3 +539,6 @@ func init() { } const Debug = false +const Commit = "unknown" +const Repo = "unknown" +const CommitURL = "unknown" diff --git a/main.go b/main.go index 3d328cd..902a0a4 100644 --- a/main.go +++ b/main.go @@ -25,10 +25,6 @@ import ( "git.maid.zone/stuff/soundcloak/templates" ) -// see build script/dockerfile -var commit = "unknown" -var repo = "unknown" - func main() { app := fiber.New(fiber.Config{ Prefork: cfg.Prefork, @@ -346,8 +342,8 @@ func main() { app.Get("/_/info", func(c *fiber.Ctx) error { return c.JSON(info{ - Commit: commit, - Repo: repo, + Commit: cfg.Commit, + Repo: cfg.Repo, ProxyImages: cfg.ProxyImages, ProxyStreams: cfg.ProxyStreams, Restream: cfg.Restream,