Show deployment version
This commit is contained in:
parent
c04fa78525
commit
93c8179dae
6 changed files with 35 additions and 3 deletions
|
|
@ -1,10 +1,11 @@
|
|||
FROM golang:1.25-alpine AS builder
|
||||
ARG GIT_COMMIT=unknown
|
||||
WORKDIR /build
|
||||
COPY go.mod go.sum ./
|
||||
RUN go mod download
|
||||
COPY *.go ./
|
||||
COPY migrations/ ./migrations/
|
||||
RUN CGO_ENABLED=0 go build -o dmrmap .
|
||||
RUN CGO_ENABLED=0 go build -ldflags "-X main.version=${GIT_COMMIT}" -o dmrmap .
|
||||
|
||||
FROM alpine:3.19
|
||||
WORKDIR /app
|
||||
|
|
|
|||
|
|
@ -10,7 +10,10 @@ services:
|
|||
restart: unless-stopped
|
||||
|
||||
dmrmap:
|
||||
build: .
|
||||
build:
|
||||
context: .
|
||||
args:
|
||||
GIT_COMMIT: ${GIT_COMMIT:-unknown}
|
||||
depends_on:
|
||||
- postgres
|
||||
environment:
|
||||
|
|
|
|||
10
main.go
10
main.go
|
|
@ -6,6 +6,8 @@ import (
|
|||
"os"
|
||||
)
|
||||
|
||||
var version = "dev"
|
||||
|
||||
func main() {
|
||||
dsn := envOr("DATABASE_URL", "postgres://dmrmap:dmrmap@localhost:5432/dmrmap?sslmode=disable")
|
||||
jsonPath := envOr("JSON_PATH", "rptrs.json")
|
||||
|
|
@ -38,6 +40,7 @@ func main() {
|
|||
mux.HandleFunc("/api/repeaters/route", handleRouteRepeaters(db))
|
||||
mux.HandleFunc("/api/repeater", handleRepeaterByID(db))
|
||||
mux.HandleFunc("/api/repeaters/search", handleSearchRepeaters(db))
|
||||
mux.HandleFunc("/api/version", handleVersion())
|
||||
|
||||
if adminToken := os.Getenv("ADMIN_TOKEN"); adminToken != "" {
|
||||
mux.HandleFunc("/admin/", handleAdminPage())
|
||||
|
|
@ -58,6 +61,13 @@ func main() {
|
|||
log.Fatal(http.ListenAndServe(addr, mux))
|
||||
}
|
||||
|
||||
func handleVersion() http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
w.Write([]byte(`{"version":"` + version + `"}`))
|
||||
}
|
||||
}
|
||||
|
||||
func envOr(key, fallback string) string {
|
||||
if v := os.Getenv(key); v != "" {
|
||||
return v
|
||||
|
|
|
|||
|
|
@ -1515,6 +1515,20 @@
|
|||
|
||||
window.addEventListener("hashchange", checkHash);
|
||||
|
||||
// === Version ===
|
||||
fetch("/api/version")
|
||||
.then(function (resp) { return resp.json(); })
|
||||
.then(function (data) {
|
||||
if (data.version && data.version !== "dev" && data.version !== "unknown") {
|
||||
var el = document.getElementById("app-version");
|
||||
if (el) {
|
||||
el.textContent = data.version;
|
||||
el.parentElement.style.display = "";
|
||||
}
|
||||
}
|
||||
})
|
||||
.catch(function () {});
|
||||
|
||||
// === Init ===
|
||||
fetchTgRegistry();
|
||||
|
||||
|
|
|
|||
|
|
@ -73,7 +73,7 @@
|
|||
Routing by <a href="https://project-osrm.org" target="_blank" rel="noopener">OSRM</a>.
|
||||
Map by <a href="https://www.openstreetmap.org/copyright" target="_blank" rel="noopener">OpenStreetMap</a>.
|
||||
Built by <a rel="me" href="https://social.darc.de/@DA6KM" target="_blank" rel="noopener">DA6KM</a>.<br>
|
||||
<a href="/impressum.html" id="link-impressum" data-i18n="impressum">Impressum</a> · <a href="/datenschutz.html" id="link-datenschutz" data-i18n="datenschutz">Datenschutz</a> · <a href="https://git.kida.io/marcus/DMRmap" target="_blank" rel="noopener" data-i18n="source">Source</a><br>
|
||||
<a href="/impressum.html" id="link-impressum" data-i18n="impressum">Impressum</a> · <a href="/datenschutz.html" id="link-datenschutz" data-i18n="datenschutz">Datenschutz</a> · <a href="https://git.kida.io/marcus/DMRmap" target="_blank" rel="noopener" data-i18n="source">Source</a> <span class="app-version" style="display:none">(<code id="app-version"></code>)</span><br>
|
||||
</div>
|
||||
</div>
|
||||
<div id="cps-modal" class="cps-modal" style="display:none">
|
||||
|
|
|
|||
|
|
@ -593,6 +593,10 @@ html, body {
|
|||
color: var(--text-faint);
|
||||
}
|
||||
|
||||
.app-version code {
|
||||
font-size: 10px;
|
||||
}
|
||||
|
||||
/* Popups */
|
||||
|
||||
.rptr-popup h3 {
|
||||
|
|
|
|||
Loading…
Reference in a new issue