Browse Source

update docker-compose related and update server/Dockerfile

main
SliverHorn 4 years ago
parent
commit
64f731d404
  1. 32
      .docker-compose/shell/server-handle.sh
  2. 18
      dockerfile_server
  3. 29
      server/Dockerfile

32
.docker-compose/shell/server-handle.sh

@ -49,8 +49,6 @@ system:
addr: 8888
db-type: 'mysql'
oss-type: 'local'
config-env: 'GVA_CONFIG'
need-init-data: true
use-multipoint: false
# captcha configuration
@ -70,36 +68,6 @@ mysql:
max-open-conns: 10
log-mode: false
# sqlite connect configuration (sqlite需要gcc支持 windows用户需要自行安装gcc)
sqlite:
path: 'db.db'
max-idle-conns: 10
max-open-conns: 10
logger: true
# Sqlserver connect configuration
sqlserver:
path: 'localhost:9930'
db-name: 'gorm'
username: 'gorm'
password: 'LoremIpsum86'
max-idle-conns: 10
max-open-conns: 10
logger: true
# Postgresql connect configuration
postgresql:
host: '127.0.0.1'
port: '9920'
config: 'sslmode=disable TimeZone=Asia/Shanghai'
db-name: 'gorm'
username: 'gorm'
password: 'gorm'
max-idle-conns: 10
max-open-conns: 10
prefer-simple-protocol: true
logger: false
# local configuration
local:
path: 'uploads/file'

18
dockerfile_server

@ -12,6 +12,7 @@ RUN sh ./server-handle.sh
RUN rm -f server-handle.sh
RUN cat ./config.yaml
RUN go build -o gva cmd/main.go
RUN go env && go build -o server .
@ -20,24 +21,11 @@ LABEL MAINTAINER="SliverHorn@sliver_horn@qq.com"
WORKDIR /go/src/gin-vue-admin
COPY --from=0 /go/src/gin-vue-admin/gva ./
COPY --from=0 /go/src/gin-vue-admin/server ./
COPY --from=0 /go/src/gin-vue-admin/config.yaml ./
COPY --from=0 /go/src/gin-vue-admin/resource ./resource
EXPOSE 8888
ENTRYPOINT ./server
# 根据Dockerfile生成Docker镜像
# docker build -t gva-server:1.0 .
#- 根据Docker镜像启动Docker容器
# - 后台运行
# - ```
# docker run -d -p 8888:8888 --name gva-server-v1 gva-server:1.0
# ```
# - 以可交互模式运行, Ctrl + p + q
# - ```
# docker run -it -p 8888:8888 --name gva-server-v1 gva-server:1.0
# ```
ENTRYPOINT ./gva initdb && ./server

29
server/Dockerfile

@ -1,19 +1,20 @@
FROM golang:alpine as builder
FROM golang:alpine
# 设置go mod proxy 国内代理
# 设置golang path
ENV GOPROXY=https://goproxy.cn,https://goproxy.io,direct \
GO111MODULE=on \
CGO_ENABLED=1
WORKDIR /ginvue
RUN go env -w GOPROXY=https://goproxy.cn,https://goproxy.io,direct
ENV GO111MODULE=on
ENV GOPROXY=https://goproxy.io,direct
WORKDIR /go/src/gin-vue-admin
COPY . .
RUN go env && go list && go build -o app main.go
RUN go env && go build -o server .
FROM alpine:latest
LABEL MAINTAINER="SliverHorn@sliver_horn@qq.com"
WORKDIR /go/src/gin-vue-admin
COPY --from=0 /go/src/gin-vue-admin/server ./
COPY --from=0 /go/src/gin-vue-admin/config.yaml ./
COPY --from=0 /go/src/gin-vue-admin/resource ./resource
EXPOSE 8888
ENTRYPOINT /ginvue/app
# 根据Dockerfile生成Docker镜像
# docker build -t ginvue .
# 根据Docker镜像启动Docker容器
# docker run -itd -p 8888:8888 --name ginvue ginvue
ENTRYPOINT ./server
Loading…
Cancel
Save