Skip to content

[build] embed IANA tzdata so named time zones work in minimal images (STAR-57)#22

Merged
vt128 merged 1 commit into
masterfrom
feat/embed-tzdata
Jun 22, 2026
Merged

[build] embed IANA tzdata so named time zones work in minimal images (STAR-57)#22
vt128 merged 1 commit into
masterfrom
feat/embed-tzdata

Conversation

@vt128

@vt128 vt128 commented Jun 22, 2026

Copy link
Copy Markdown
Member

What

Embed the IANA time-zone database into the binary via import _ "time/tzdata" so named zones resolve without a host /usr/share/zoneinfo.

Why

starcli's time module resolves named zones (parse_time(location=…), in_location, is_valid_timezone) through time.LoadLocation, which needs the IANA tz data. The binary relied on the host's /usr/share/zoneinfo β€” fine on the current ubuntu Docker image, but a slim binary or a scratch/distroless/alpine image has no tz data, so named zones fail there. v0.2 is heading toward goreleaser binaries + minimal images, so embedding keeps the CLI self-contained and "runs anywhere".

Proof (linux/amd64 static binary in plain alpine, which has no zoneinfo)

build is_valid_timezone("America/New_York")
with the import True βœ…
without it False ❌

Cost: +400 KiB stripped (32.8 β†’ 33.2 MB) β€” negligible against the existing size.

Changes

  • main.go: blank import of time/tzdata with the rationale.
  • e2e: two golden cases (is_valid_timezone + an in_location conversion) guard that named zones keep resolving through the real binary.

Verification

  • Full -race green; Docker golang:1.25 (go floor) green; gofmt/vet clean.

Tracks STAR-57 (the tzdata half). CA certs for scratch/distroless images are handled in the goreleaser/Docker step (P1-b) β€” system cert pool covers real OSes.

…(STAR-57)

starcli's time module resolves named zones (parse_time location=, in_location,
is_valid_timezone) via time.LoadLocation, which needs the IANA tz database. The
binary relied on the host's /usr/share/zoneinfo β€” fine on the ubuntu Docker
image, but a slim binary or a scratch/distroless/alpine image has no tz data, so
named zones would fail there. With v0.2 heading toward goreleaser binaries and
minimal images, embed the database via `import _ "time/tzdata"` so the CLI is
self-contained and "runs anywhere".

Proof (linux/amd64 static binary in plain alpine, which has no zoneinfo):
  with the import  -> is_valid_timezone("America/New_York") == True
  without it       -> == False
Cost: +400 KiB stripped (32.8 -> 33.2 MB), negligible against the existing size.

- main.go: blank import of time/tzdata with the rationale.
- e2e: two golden cases (is_valid_timezone + in_location conversion) guard that
  named zones keep resolving through the real binary.

Full -race green; Docker golang:1.25 floor green; gofmt/vet clean.
@vt128 vt128 merged commit c332c11 into master Jun 22, 2026
6 checks passed
@vt128 vt128 deleted the feat/embed-tzdata branch June 22, 2026 06:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant