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 . .
|
COPY . .
|
||||||
|
|
||||||
# Build both binaries as static.
|
ARG GIT_COMMIT=unknown
|
||||||
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/
|
# 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 ---
|
# --- Server image ---
|
||||||
FROM alpine:3.21 AS server
|
FROM alpine:3.21 AS server
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,7 @@ import (
|
||||||
"strconv"
|
"strconv"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/nixc/reverse-ssh-traefik/internal/buildinfo"
|
||||||
"github.com/nixc/reverse-ssh-traefik/internal/client"
|
"github.com/nixc/reverse-ssh-traefik/internal/client"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -26,7 +27,7 @@ func envOr(key, fallback string) string {
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
log.SetFlags(log.LstdFlags | log.Lshortfile)
|
log.SetFlags(log.LstdFlags | log.Lshortfile)
|
||||||
log.Println("tunnel-client starting")
|
log.Printf("tunnel-client starting commit=%s", buildinfo.Commit)
|
||||||
|
|
||||||
serverAddr := envRequired("TUNNEL_SERVER")
|
serverAddr := envRequired("TUNNEL_SERVER")
|
||||||
domain := envRequired("TUNNEL_DOMAIN")
|
domain := envRequired("TUNNEL_DOMAIN")
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,7 @@ import (
|
||||||
"strconv"
|
"strconv"
|
||||||
"syscall"
|
"syscall"
|
||||||
|
|
||||||
|
"github.com/nixc/reverse-ssh-traefik/internal/buildinfo"
|
||||||
"github.com/nixc/reverse-ssh-traefik/internal/server"
|
"github.com/nixc/reverse-ssh-traefik/internal/server"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -40,7 +41,7 @@ func envInt(key string, fallback int) int {
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
log.SetFlags(log.LstdFlags | log.Lshortfile)
|
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).
|
// SSH server config (for accepting tunnel clients).
|
||||||
sshPort := envOr("SSH_PORT", "2222")
|
sshPort := envOr("SSH_PORT", "2222")
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue