Compare commits
1 Commits
v0.1.5
...
c77c491b64
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c77c491b64 |
@@ -1,6 +1,6 @@
|
||||
FROM docker.io/golang:1.25.4-alpine AS build
|
||||
|
||||
RUN apk add --no-cache upx
|
||||
RUN apk add --no-cache upx git
|
||||
|
||||
WORKDIR /src
|
||||
COPY go.mod go.sum ./
|
||||
@@ -10,7 +10,9 @@ COPY . .
|
||||
RUN go tool templ generate
|
||||
RUN go tool gotailwind -i assets/css/input.css -o assets/css/output.css --minify
|
||||
RUN --mount=type=cache,target=/root/.cache/go-build \
|
||||
CGO_ENABLED=0 go build -ldflags="-s" -o /bin/games .
|
||||
VERSION=$(git describe --tags --always) && \
|
||||
COMMIT=$(git rev-parse --short HEAD) && \
|
||||
CGO_ENABLED=0 go build -ldflags="-s -X github.com/ryanhamamura/games/version.Version=$VERSION -X github.com/ryanhamamura/games/version.Commit=$COMMIT" -o /bin/games .
|
||||
RUN upx -9 -k /bin/games
|
||||
|
||||
FROM scratch
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
package layouts
|
||||
|
||||
import "github.com/ryanhamamura/games/config"
|
||||
import (
|
||||
"github.com/ryanhamamura/games/config"
|
||||
"github.com/ryanhamamura/games/version"
|
||||
)
|
||||
|
||||
templ Base(title string) {
|
||||
<!DOCTYPE html>
|
||||
@@ -16,6 +19,9 @@ templ Base(title string) {
|
||||
<div data-init="@get('/reload', {retryMaxCount: 1000, retryInterval:20, retryMaxWaitMs:200})"></div>
|
||||
}
|
||||
{ children... }
|
||||
<footer class="fixed bottom-1 right-2 text-xs text-gray-500">
|
||||
{ version.Version }
|
||||
</footer>
|
||||
</body>
|
||||
</html>
|
||||
}
|
||||
|
||||
3
main.go
3
main.go
@@ -20,6 +20,7 @@ import (
|
||||
"github.com/ryanhamamura/games/router"
|
||||
"github.com/ryanhamamura/games/sessions"
|
||||
"github.com/ryanhamamura/games/snake"
|
||||
"github.com/ryanhamamura/games/version"
|
||||
|
||||
"github.com/go-chi/chi/v5"
|
||||
"github.com/go-chi/chi/v5/middleware"
|
||||
@@ -45,7 +46,7 @@ func main() {
|
||||
func run(ctx context.Context) error {
|
||||
cfg := config.Global
|
||||
addr := fmt.Sprintf("%s:%s", cfg.Host, cfg.Port)
|
||||
slog.Info("server starting", "addr", addr)
|
||||
slog.Info("server starting", "addr", addr, "version", version.Version, "commit", version.Commit)
|
||||
defer slog.Info("server shutdown complete")
|
||||
|
||||
eg, egctx := errgroup.WithContext(ctx)
|
||||
|
||||
10
version/version.go
Normal file
10
version/version.go
Normal file
@@ -0,0 +1,10 @@
|
||||
// Package version holds build-time version information injected via ldflags.
|
||||
package version
|
||||
|
||||
// Version and Commit are set at build time via:
|
||||
//
|
||||
// -ldflags "-X github.com/ryanhamamura/games/version.Version=... -X github.com/ryanhamamura/games/version.Commit=..."
|
||||
var (
|
||||
Version = "dev"
|
||||
Commit = "unknown"
|
||||
)
|
||||
Reference in New Issue
Block a user