fix: bake GIT_COMMIT via buildinfo in cmd and Dockerfile
Made-with: Cursor
This commit is contained in:
parent
650482c189
commit
f5b4bbe27e
|
|
@ -9,9 +9,11 @@ RUN go mod download
|
|||
|
||||
COPY . .
|
||||
|
||||
# Build both binaries as static.
|
||||
RUN CGO_ENABLED=0 go build -ldflags="-s -w" -o /tunnel-server ./cmd/server/
|
||||
RUN CGO_ENABLED=0 go build -ldflags="-s -w" -o /tunnel-client ./cmd/client/
|
||||
ARG GIT_COMMIT=unknown
|
||||
|
||||
# Build both binaries as static; Commit matches ship.sh / local -ldflags.
|
||||
RUN CGO_ENABLED=0 go build -ldflags="-s -w -X github.com/nixc/reverse-ssh-traefik/internal/buildinfo.Commit=${GIT_COMMIT}" -o /tunnel-server ./cmd/server/
|
||||
RUN CGO_ENABLED=0 go build -ldflags="-s -w -X github.com/nixc/reverse-ssh-traefik/internal/buildinfo.Commit=${GIT_COMMIT}" -o /tunnel-client ./cmd/client/
|
||||
|
||||
# --- Server image ---
|
||||
FROM alpine:3.21 AS server
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ import (
|
|||
"strconv"
|
||||
"time"
|
||||
|
||||
"github.com/nixc/reverse-ssh-traefik/internal/buildinfo"
|
||||
"github.com/nixc/reverse-ssh-traefik/internal/client"
|
||||
)
|
||||
|
||||
|
|
@ -26,7 +27,7 @@ func envOr(key, fallback string) string {
|
|||
|
||||
func main() {
|
||||
log.SetFlags(log.LstdFlags | log.Lshortfile)
|
||||
log.Println("tunnel-client starting")
|
||||
log.Printf("tunnel-client starting commit=%s", buildinfo.Commit)
|
||||
|
||||
serverAddr := envRequired("TUNNEL_SERVER")
|
||||
domain := envRequired("TUNNEL_DOMAIN")
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ import (
|
|||
"strconv"
|
||||
"syscall"
|
||||
|
||||
"github.com/nixc/reverse-ssh-traefik/internal/buildinfo"
|
||||
"github.com/nixc/reverse-ssh-traefik/internal/server"
|
||||
)
|
||||
|
||||
|
|
@ -40,7 +41,7 @@ func envInt(key string, fallback int) int {
|
|||
|
||||
func main() {
|
||||
log.SetFlags(log.LstdFlags | log.Lshortfile)
|
||||
log.Println("tunnel-server starting")
|
||||
log.Printf("tunnel-server starting commit=%s", buildinfo.Commit)
|
||||
|
||||
// SSH server config (for accepting tunnel clients).
|
||||
sshPort := envOr("SSH_PORT", "2222")
|
||||
|
|
|
|||
Loading…
Reference in New Issue