fix:数据库时间问题

pull/358/head
lifei6671 2018-09-17 17:07:58 +08:00
parent fe4398f8ba
commit 2b8bd2cfb2
2 changed files with 10 additions and 9 deletions

View File

@ -1,4 +1,4 @@
FROM golang:1.10.3-alpine3.7 FROM golang:1.10.3-alpine3.7 AS build
#新增 GLIBC #新增 GLIBC
ENV GLIBC_VERSION "2.28-r0" ENV GLIBC_VERSION "2.28-r0"
@ -34,7 +34,7 @@ ADD . /go/src/github.com/lifei6671/mindoc
WORKDIR /go/src/github.com/lifei6671/mindoc WORKDIR /go/src/github.com/lifei6671/mindoc
RUN go get -u github.com/golang/dep/cmd/dep && dep ensure && \ RUN go get -u github.com/golang/dep/cmd/dep && dep ensure && \
CGO_ENABLE=1 go build -v -o mindoc_linux_amd64 -ldflags="-w -X main.VERSION=$TAG -X 'main.BUILD_TIME=`date`' -X 'main.GO_VERSION=`go version`'" && \ CGO_ENABLE=1 go build -v -a -o mindoc_linux_amd64 -ldflags="-w -s -X main.VERSION=$TAG -X 'main.BUILD_TIME=`date`' -X 'main.GO_VERSION=`go version`'" && \
rm -rf commands controllers models modules routers tasks vendor docs search data utils graphics .git Godeps uploads/* .gitignore .travis.yml Dockerfile gide.yaml LICENSE main.go README.md conf/enumerate.go conf/mail.go install.lock simsun.ttc rm -rf commands controllers models modules routers tasks vendor docs search data utils graphics .git Godeps uploads/* .gitignore .travis.yml Dockerfile gide.yaml LICENSE main.go README.md conf/enumerate.go conf/mail.go install.lock simsun.ttc
ADD start.sh /go/src/github.com/lifei6671/mindoc ADD start.sh /go/src/github.com/lifei6671/mindoc
@ -46,7 +46,6 @@ LABEL maintainer="longfei6671@163.com"
RUN apk add --update && \ RUN apk add --update && \
apk add --no-cache --upgrade \ apk add --no-cache --upgrade \
ca-certificates \
mesa-gl \ mesa-gl \
python \ python \
qt5-qtbase-x11 \ qt5-qtbase-x11 \
@ -61,11 +60,12 @@ RUN apk add --update && \
update-ms-fonts && \ update-ms-fonts && \
fc-cache -f fc-cache -f
COPY --from=0 /var/glibc.apk . COPY --from=build /var/glibc.apk .
COPY --from=0 /var/glibc-bin.apk . COPY --from=build /var/glibc-bin.apk .
COPY --from=0 /etc/apk/keys/sgerrand.rsa.pub /etc/apk/keys/sgerrand.rsa.pub COPY --from=build /etc/apk/keys/sgerrand.rsa.pub /etc/apk/keys/sgerrand.rsa.pub
COPY --from=0 /var/linux-installer.py . COPY --from=build /var/linux-installer.py .
COPY --from=0 /usr/share/fonts/win/simsun.ttc /usr/share/fonts/win/ COPY --from=build /usr/share/fonts/win/simsun.ttc /usr/share/fonts/win/
COPY --from=certs /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt
RUN apk add glibc-bin.apk glibc.apk && \ RUN apk add glibc-bin.apk glibc.apk && \
/usr/glibc-compat/sbin/ldconfig /lib /usr/glibc-compat/lib && \ /usr/glibc-compat/sbin/ldconfig /lib /usr/glibc-compat/lib && \

View File

@ -31,6 +31,7 @@ import (
func RegisterDataBase() { func RegisterDataBase() {
beego.Info("正在初始化数据库配置.") beego.Info("正在初始化数据库配置.")
adapter := beego.AppConfig.String("db_adapter") adapter := beego.AppConfig.String("db_adapter")
orm.DefaultTimeLoc = time.Local
if strings.EqualFold(adapter, "mysql") { if strings.EqualFold(adapter, "mysql") {
host := beego.AppConfig.String("db_host") host := beego.AppConfig.String("db_host")
@ -55,7 +56,7 @@ func RegisterDataBase() {
os.Exit(1) os.Exit(1)
} }
} else if strings.EqualFold(adapter, "sqlite3") { } else if strings.EqualFold(adapter, "sqlite3") {
orm.DefaultTimeLoc = time.UTC
database := beego.AppConfig.String("db_database") database := beego.AppConfig.String("db_database")
if strings.HasPrefix(database, "./") { if strings.HasPrefix(database, "./") {
database = filepath.Join(conf.WorkingDirectory, string(database[1:])) database = filepath.Join(conf.WorkingDirectory, string(database[1:]))