Embed IANA timezone database in the binary#21
Open
AevumDecessus wants to merge 1 commit into
Open
Conversation
The dashboard schedule view renders current hour and weekday using time.Now() in the process's local timezone. On minimal container base images (debian:bookworm-slim, distroless, scratch) the IANA zoneinfo files are not present, so Go's runtime falls back to UTC regardless of what the TZ environment variable says. The result is a UTC schedule grid for users in any other zone, and notification timestamps formatted in UTC at serve.go:1006. Importing time/tzdata embeds the IANA zone database into the binary at link time, so the runtime can resolve any zone name without filesystem zoneinfo. Users still need to set TZ in their environment (e.g. TZ=America/New_York) for the binary to know which zone, but with this import the lookup succeeds regardless of base image. Binary size impact is approximately 400 KB on a 22 MB starting binary (about 2%). Native go install users benefit identically to docker users. Verified locally: TZ=America/New_York with the embedded tzdata renders 9:29 EDT for the current moment vs 13:29 UTC, exactly as expected.
AevumDecessus
added a commit
to AevumDecessus/anantha
that referenced
this pull request
May 11, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
The dashboard's schedule view renders current time using
time.Now().Hour()andtime.Now().Weekday()incmd/anantha/cmd/templates.go. On minimal container base images (debian:bookworm-slim,distroless,scratch) the IANA zoneinfo files are not present, so Go's runtime falls back to UTC regardless of what theTZenvironment variable says. The result is a UTC-rendered schedule grid for users in any other zone, and the notification timestamp formatter atserve.go:1006(t.Local().Format(...)) is similarly stuck on UTC.This PR adds a single anonymous import of
time/tzdatatocmd/anantha/main.go. That embeds the IANA zone database into the binary at link time. Users still need to setTZin their environment (e.g.TZ=America/New_Yorkin their compose file or viaenvironment:), but with the embed the lookup succeeds regardless of base image.Why this approach
Three options were considered:
tzdatain the Dockerfile: works, ~2.6 MB image growth, but only fixes the official Docker image. Users running anantha natively viago install github.com/anupcshan/anantha/cmd/anantha@lateststill see UTC.time/tzdata(this PR): ~400 KB binary growth, fixes both Docker and native install paths, future-proof against base-image churn (Dockerfile could later switch toscratchordistrolesswithout breaking timezones).The embed-only approach is the minimal change that fixes the broadest set of deployment shapes.
Verification
Built locally with
go buildand confirmed:TZ=America/New_Yorkset,time.LoadLocation("America/New_York")succeeds and renders local hour (9 EDT) vs UTC (13). WithoutTZ, behavior is unchanged from main (still UTC).go build,go vet,go fmt,golangci-lint(0 issues).User-facing change
After merging, users who want local-time rendering should set
TZin their environment:Without
TZset, behavior is identical to today (UTC). No regression for existing deployments.