Created
May 29, 2019 00:07
-
-
Save choonkeat/850dda9aaf87acad21df6db3236b940c to your computer and use it in GitHub Desktop.
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
FROM golang:1.12.5-alpine3.9 as builder | |
RUN apk --no-cache add tzdata | |
COPY . /src | |
RUN go build -o /bin/timenow /src/timenow.go | |
FROM scratch | |
COPY --from=builder /bin/timenow /bin/timenow | |
# without these, TZ env is useless | |
COPY --from=builder /usr/share/zoneinfo /usr/share/zoneinfo | |
# https://golang.org/src/time/zoneinfo_unix.go | |
# COPY --from=builder /usr/share/lib/zoneinfo /usr/share/lib/zoneinfo | |
# COPY --from=builder /usr/lib/locale/TZ /usr/lib/locale/TZ |
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
module github.com/choonkeat/timenow | |
go 1.12 |
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
run: | |
docker build . -t timenow | |
docker run --rm -it -e TZ=$(TZ) timenow /bin/timenow |
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
package main | |
import ( | |
"log" | |
"os" | |
"time" | |
) | |
func main() { | |
log.Println(os.Getenv("TZ")) | |
log.Println(time.Now().Format(time.RFC3339)) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment