SHARE
TWEET

Untitled

a guest Oct 17th, 2019 94 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. main.go
  2.  
  3. 由于alpine镜像缺少时区文件,下面代码运行会报错
  4. ```
  5. func init() {
  6.     # set global time location
  7.     location, e := time.LoadLocation("Asia/Shanghai")
  8.     if e != nil {
  9.         log.Printf("load location error:%s", e)
  10.         os.Exit(1)
  11.     }
  12.     time.Local = location
  13. }
  14. ```
  15.  
  16. Dockerfile
  17.  
  18. ```
  19. FROM alpine:latest
  20.  
  21. MAINTAINER ZhouChang "zhouchangqaz@gmail.com"
  22.  
  23. # 设置时区为上海
  24. RUN apk --no-cache add tzdata  && \
  25.     ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && \
  26.     echo "Asia/Shanghai" > /etc/timezone
  27.  
  28.  
  29. ADD ./bin/product_srv /usr/local/bin/
  30.  
  31. ENTRYPOINT ["/usr/local/bin/product_srv"]
  32. ```
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top