Last active
August 29, 2018 10:24
-
-
Save kawaken/36db383bc77a83fcdd47918f119a3bcb to your computer and use it in GitHub Desktop.
JST on Alpine Linux with Docker
This file contains 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
GOOS=linux GOARCH=amd64 go build -o time-test | |
docker build -t jst-time-test1 -f Dockerfile1 . | |
docker build -t jst-time-test2 -f Dockerfile2 . | |
docker build -t jst-time-test3 -f Dockerfile3 . |
This file contains 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 alpine:latest | |
COPY ["time-test", "/"] | |
CMD [ "/time-test" ] |
This file contains 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 alpine:latest | |
RUN apk --no-cache add tzdata && \ | |
cp /usr/share/zoneinfo/Asia/Tokyo /etc/localtime && \ | |
apk del tzdata | |
COPY ["time-test", "/"] | |
CMD [ "/time-test" ] |
This file contains 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 alpine:latest | |
RUN apk --no-cache add tzdata && \ | |
cp /usr/share/zoneinfo/Asia/Tokyo /etc/localtime | |
COPY ["time-test", "/"] | |
CMD [ "/time-test" ] |
This file contains 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 ( | |
"fmt" | |
"time" | |
) | |
func main() { | |
t := time.Now() | |
fmt.Println(t) | |
jst, _ := time.LoadLocation("Asia/Tokyo") | |
fmt.Println(t.In(jst)) | |
} |
This file contains 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
$ docker run --rm jst-time-test1 | |
2018-08-29 10:20:04.5279391 +0000 UTC m=+0.000194801 | |
panic: time: missing Location in call to Time.In | |
goroutine 1 [running]: | |
time.Time.In(0xbed9bab51f77b61c, 0x2f8f1, 0x53ab80, 0x0, 0xc42000e1e0, 0x0, 0xc42000e1c0) | |
/usr/local/Cellar/go/1.9.2/libexec/src/time/time.go:1073 +0xc0 | |
main.main() | |
/Users/kawano.kentaro/projects/src/github.com/kawaken/jst-docker/main.go:13 +0x111 | |
$ docker run --rm jst-time-test2 | |
2018-08-29 19:20:08.4511553 +0900 JST m=+0.000270001 | |
panic: time: missing Location in call to Time.In | |
goroutine 1 [running]: | |
time.Time.In(0xbed9bab61ae41564, 0x41eb1, 0x53ab80, 0x0, 0xc42000e1e0, 0x0, 0xc42000e1c0) | |
/usr/local/Cellar/go/1.9.2/libexec/src/time/time.go:1073 +0xc0 | |
main.main() | |
/Users/kawano.kentaro/projects/src/github.com/kawaken/jst-docker/main.go:13 +0x111 | |
$ docker run --rm jst-time-test3 | |
2018-08-29 19:20:10.9607839 +0900 JST m=+0.000242201 | |
2018-08-29 19:20:10.9607839 +0900 JST |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment