cache /_/info marshaled data; restructure dockerfile

This commit is contained in:
Laptop
2024-12-29 21:25:21 +02:00
parent 325bd8dda3
commit ac0572294b
2 changed files with 21 additions and 15 deletions

View File

@@ -5,21 +5,21 @@ ARG TARGETOS
ARG TARGETARCH ARG TARGETARCH
WORKDIR /build WORKDIR /build
COPY . .
# fuck google # fuck google
RUN go env -w GOPROXY=direct RUN go env -w GOPROXY=direct
RUN go install github.com/a-h/templ/cmd/templ@latest RUN go install github.com/a-h/templ/cmd/templ@latest
RUN templ generate
RUN go install github.com/dlclark/regexp2cg@main RUN go install github.com/dlclark/regexp2cg@main
RUN go generate ./lib/*
COPY . .
# usually soundcloakctl updates together with soundcloak, so we should redownload it
RUN go install git.maid.zone/stuff/soundcloakctl@master RUN go install git.maid.zone/stuff/soundcloakctl@master
RUN soundcloakctl js download
RUN templ generate
RUN go generate ./lib/*
RUN soundcloakctl config codegen 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'" -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 && \

24
main.go
View File

@@ -340,16 +340,22 @@ func main() {
DefaultPreferences cfg.Preferences DefaultPreferences cfg.Preferences
} }
inf, err := json.Marshal(info{
Commit: cfg.Commit,
Repo: cfg.Repo,
ProxyImages: cfg.ProxyImages,
ProxyStreams: cfg.ProxyStreams,
Restream: cfg.Restream,
GetWebProfiles: cfg.GetWebProfiles,
DefaultPreferences: cfg.DefaultPreferences,
})
if err != nil {
log.Fatalln("failed to marshal info: ", err)
}
app.Get("/_/info", func(c *fiber.Ctx) error { app.Get("/_/info", func(c *fiber.Ctx) error {
return c.JSON(info{ c.Set("Content-Type", "application/json")
Commit: cfg.Commit, return c.Send(inf)
Repo: cfg.Repo,
ProxyImages: cfg.ProxyImages,
ProxyStreams: cfg.ProxyStreams,
Restream: cfg.Restream,
GetWebProfiles: cfg.GetWebProfiles,
DefaultPreferences: cfg.DefaultPreferences,
})
}) })
} }