Skip to content

Commit

Permalink
Merge pull request TruthHun#7 from barnettZQG/master
Browse files Browse the repository at this point in the history
PR a Dockerfile reference
  • Loading branch information
TruthHun authored Jun 12, 2018
2 parents 499f1d2 + 10ccf6e commit ccd597d
Show file tree
Hide file tree
Showing 4 changed files with 70 additions and 0 deletions.
33 changes: 33 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
FROM goodrainapps/alpine:3.4

ENV LD_LIBRARY_PATH $LD_LIBRARY_PATH:/opt/calibre/lib
ENV PATH $PATH:/opt/calibre/bin:/run
ENV CALIBRE_INSTALLER_SOURCE_CODE_URL https://raw.githubusercontent.com/kovidgoyal/calibre/master/setup/linux-installer.py
RUN apk update && \
apk add --no-cache --upgrade \
imagemagick \
poppler-utils \
poppler-glib \
msttcorefonts-installer \
bash \
ca-certificates \
gcc \
mesa-gl \
python \
qt5-qtbase-x11 \
wget \
xdg-utils \
xz && \
wget -O- ${CALIBRE_INSTALLER_SOURCE_CODE_URL} | python -c "import sys; main=lambda:sys.stderr.write('Download failed\n'); exec(sys.stdin.read()); main(install_dir='/opt', isolated=True)" && \
update-ms-fonts && \
rm -rf /tmp/calibre-installer-cache
ADD .output /run
ADD static /run/static
COPY conf/app.conf.example /run/app.conf
COPY conf/database.conf.example /run/database.conf
COPY conf/email.conf.example /run/email.conf
COPY conf/oss.conf.example /run/oss.conf

WORKDIR /run
EXPOSE 8090
CMD ["/run/dochub"]
12 changes: 12 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
BUILD_HOME=/go/src/github.com/TruthHun/DocHub
IMAGE_NAME=truthhun/dochub
VERSION=1.0
.PHONY: build

build:
@docker build -t pdf2svg:builder ./build/Dockerfile
@docker run -it -v `pwd`/.output:/pdf2svg/.output --rm pdf2svg:builder
@docker run -it -v `pwd`:$(BUILD_HOME) -w $(BUILD_HOME) golang:1.8.3 go get && go build -ldflags '-w -s' -o .output/dochub
image: build
@docker build -t $(IMAGE_NAME):$(VERSION) .
@rm -rf .output
13 changes: 13 additions & 0 deletions build/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
FROM goodrainapps/alpine:3.4
LABEL version="0.2.3-alpine3.6"

RUN apk add --update-cache make gcc libc-dev cairo-dev poppler-dev git

ENV PDF2SVG_VERSION v0.2.3

RUN git clone https://github.com/dawbarton/pdf2svg pdf2svg

WORKDIR /pdf2svg

RUN git checkout $PDF2SVG_VERSION && ./configure && make
CMD [ "cp","/pdf2svg/pdf2svg","/pdf2svg/.output/pdf2svg"]
12 changes: 12 additions & 0 deletions models/Models.go
Original file line number Diff line number Diff line change
Expand Up @@ -177,13 +177,25 @@ func RegisterDB() {
orm.RegisterModelWithPrefix(beego.AppConfig.String("db::prefix"), models...)
db_user := beego.AppConfig.String("db::user")
db_password := beego.AppConfig.String("db::password")
if envpass := os.Getenv("MYSQL_PASSWORD"); envpass != "" {
db_password = envpass
}
db_database := beego.AppConfig.String("db::database")
if envdatabase := os.Getenv("MYSQL_DATABASE"); envdatabase != "" {
db_database = envdatabase
}
db_charset := beego.AppConfig.String("db::charset")
db_host := beego.AppConfig.String("db::hostInternal")
if beego.AppConfig.String("runmode") == "dev" {
db_host = beego.AppConfig.String("db::hostOuter")
}
if envhost := os.Getenv("MYSQL_HOST"); envhost != "" {
db_host = envhost
}
db_port := beego.AppConfig.String("db::port")
if envport := os.Getenv("MYSQL_PORT"); envport != "" {
db_port = envport
}
dblink := fmt.Sprintf("%s:%s@tcp(%s:%s)/%s?charset=%s", db_user, db_password, db_host, db_port, db_database, db_charset)
//下面两个参数后面要放到app.conf提供用户配置使用
// (可选)设置最大空闲连接
Expand Down

0 comments on commit ccd597d

Please sign in to comment.