From 669ced90731785374b3ae9003a261d282752c561 Mon Sep 17 00:00:00 2001 From: rikugun Date: Sun, 12 Apr 2020 21:58:20 +0800 Subject: [PATCH 1/4] =?UTF-8?q?feat:=20=E5=A2=9E=E5=8A=A0docker=20?= =?UTF-8?q?=E6=94=AF=E6=8C=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .dockerignore | 119 ++++++++++++++++++++++++++++++++ Dockerfile | 41 +++++++++++ docker/docker-start.sh | 4 ++ docker/etc/nginx/nginx.conf.tpl | 56 +++++++++++++++ server/config.yaml | 4 +- server/{db => }/db.db | Bin 368640 -> 372736 bytes server/initialize/sqlite.go | 2 +- server/service/sys_menu.go | 7 +- 8 files changed, 227 insertions(+), 6 deletions(-) create mode 100644 .dockerignore create mode 100644 Dockerfile create mode 100755 docker/docker-start.sh create mode 100644 docker/etc/nginx/nginx.conf.tpl rename server/{db => }/db.db (90%) diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 00000000..4e352a51 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,119 @@ +# Created by .ignore support plugin (hsz.mobi) +### Node template +# Logs +logs +*.log +npm-debug.log* +yarn-debug.log* +yarn-error.log* +lerna-debug.log* + +# Diagnostic reports (https://nodejs.org/api/report.html) +report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json + +# Runtime data +pids +*.pid +*.seed +*.pid.lock + +# Directory for instrumented libs generated by jscoverage/JSCover +lib-cov + +# Coverage directory used by tools like istanbul +coverage +*.lcov + +# nyc test coverage +.nyc_output + +# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) +.grunt + +# Bower dependency directory (https://bower.io/) +bower_components + +# node-waf configuration +.lock-wscript + +# Compiled binary addons (https://nodejs.org/api/addons.html) +build/Release + +# Dependency directories +node_modules/ +jspm_packages/ + +# Snowpack dependency directory (https://snowpack.dev/) +web_modules/ + +# TypeScript cache +*.tsbuildinfo + +# Optional npm cache directory +.npm + +# Optional eslint cache +.eslintcache + +# Microbundle cache +.rpt2_cache/ +.rts2_cache_cjs/ +.rts2_cache_es/ +.rts2_cache_umd/ + +# Optional REPL history +.node_repl_history + +# Output of 'npm pack' +*.tgz + +# Yarn Integrity file +.yarn-integrity + +# dotenv environment variables file +.env +.env.test + +# parcel-bundler cache (https://parceljs.org/) +.cache +.parcel-cache + +# Next.js build output +.next + +# Nuxt.js build / generate output +.nuxt +dist + +# Gatsby files +.cache/ +# Comment in the public line in if your project uses Gatsby and not Next.js +# https://nextjs.org/blog/next-9-1#public-directory-support +# public + +# vuepress build output +.vuepress/dist + +# Serverless directories +.serverless/ + +# FuseBox cache +.fusebox/ + +# DynamoDB Local files +.dynamodb/ + +# TernJS port file +.tern-port + +# Stores VSCode versions used for testing VSCode extensions +.vscode-test + +# yarn v2 + +.yarn/cache +.yarn/unplugged +.yarn/build-state.yml +.pnp.* + +**/node_modules diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..5a055230 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,41 @@ +FROM golang:alpine as builder +RUN apk add --update --no-cache yarn make g++ +RUN yarn global add cross-env node-sass + +ENV GOPROXY=https://goproxy.cn,https://goproxy.io,direct \ + GO111MODULE=on \ + CGO_ENABLED=1 +WORKDIR /go/src/gin-vue-admin +RUN go env -w GOPROXY=https://goproxy.cn,https://goproxy.io,direct +COPY server/ ./ +RUN go env && go list && go build -v -a -ldflags "-extldflags \"-static\" " -o gvadmin . + +WORKDIR /web +COPY web/ ./ +RUN yarn install && yarn run build + + +FROM nginx:alpine +LABEL MAINTAINER="rikugun" + +RUN apk add --no-cache gettext tzdata && \ + cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && \ + echo "Asia/Shanghai" > /etc/timezone && \ + date && \ + apk del tzdata + +COPY docker/etc/nginx/nginx.conf.tpl /etc/nginx/nginx.conf.tpl +WORKDIR /app +#copy web +COPY --from=builder /web/dist/ /var/www/ +#copy go app +COPY --from=builder /go/src/gin-vue-admin/gvadmin ./ +COPY --from=builder /go/src/gin-vue-admin/db.db ./ +COPY --from=builder /go/src/gin-vue-admin/config.yaml ./ +COPY --from=builder /go/src/gin-vue-admin/resource ./resource +COPY docker/docker-start.sh ./ + +ENV API_SERVER="http://localhost:8888/" +EXPOSE 80 + +ENTRYPOINT ["./docker-start.sh"] diff --git a/docker/docker-start.sh b/docker/docker-start.sh new file mode 100755 index 00000000..df7e2e76 --- /dev/null +++ b/docker/docker-start.sh @@ -0,0 +1,4 @@ +#!/bin/sh +envsubst '$API_SERVER' < /etc/nginx/nginx.conf.tpl > /etc/nginx/nginx.conf +env nginx +./gvadmin diff --git a/docker/etc/nginx/nginx.conf.tpl b/docker/etc/nginx/nginx.conf.tpl new file mode 100644 index 00000000..c96973cb --- /dev/null +++ b/docker/etc/nginx/nginx.conf.tpl @@ -0,0 +1,56 @@ +daemon on; +worker_processes 50; +#error_log /dev/stdout warn; +error_log /var/log/nginx/error.log error; + + +events { + worker_connections 1024; +} + + +http { + include mime.types; + default_type application/octet-stream; + # See http://licson.net/post/optimizing-nginx-for-large-file-delivery/ for more detail + # This optimizes the server for HLS fragment delivery + sendfile off; + #tcp_nopush on; + keepalive_timeout 65; + log_format main '$remote_addr - $remote_user [$time_local] "$request" ' + '$status $body_bytes_sent "$http_referer" ' + '"$http_user_agent" "$http_x_forwarded_for"'; + #access_log /dev/stdout combined; + +# ssl_ciphers HIGH:!aNULL:!MD5; +# ssl_protocols TLSv1 TLSv1.1 TLSv1.2; +# ssl_session_cache shared:SSL:10m; +# ssl_session_timeout 10m; + +server { + listen 80; + + # Uncomment these lines to enable SSL. + # Update the ssl paths with your own certificate and private key. + # listen 443 ssl; + # ssl_certificate /opt/certs/example.com.crt; + # ssl_certificate_key /opt/certs/example.com.key; + location / { + root /var/www; + try_files $uri $uri/ /index.html; + index index.html; + } + + location /v1/ { + proxy_set_header X-Forwarded-Proto $scheme; + proxy_set_header X-Forwarded-Port $server_port; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection "upgrade"; + proxy_set_header Host $host; + proxy_pass ${API_SERVER} ; + } + +} + +} diff --git a/server/config.yaml b/server/config.yaml index 0f10318a..30af1073 100644 --- a/server/config.yaml +++ b/server/config.yaml @@ -20,7 +20,7 @@ mysql: log-mode: true #sqlite 配置 sqlite: - path: db/db.db + path: db.db log-mode: true config: 'loc=Asia/Shanghai' # oss configuration @@ -39,7 +39,7 @@ system: use-multipoint: false env: 'public' # Change to "develop" to skip authentication for development mode addr: 8888 - db-type: "mysql" + db-type: "sqlite" # support mysql/sqlite # captcha configuration captcha: diff --git a/server/db/db.db b/server/db.db similarity index 90% rename from server/db/db.db rename to server/db.db index 73a5833b85ed0d68bbdeb1772c4bb40d01614b55..edf5416cbbba4718c299306c7f7e8c7a848eadcb 100644 GIT binary patch delta 6986 zcmds5dwdgBzMnHQNhaycoF-|SzS1;p(>6^XNt)24r9g#RYk3tAWl?LT0cz<3+M=Km zf{5(8BJSXxm9l`3>kAf89#yXj=+(Qz74)hfWbf6hE);fMy}p-K(f!R#CM}}Ny7&II zna`Z_`+nzle)FC4J2N@wtUQpu@}2bcSr)p4qNurWmcnU-^V+-00yJIn*fm=)%6>fc zTZ|(D&R5rTqdJDsNpz3eEc2V2B&P5%4{e49|%{WlsvcA@~ z-j2SY1%Zc*u5Ig!wsu9k2l~qH^BwrbR(5hBo=oAd@E7=Fh_u^f68-5Vqi#K6{e}V77Yw<031zv{xaSy%@NAWdyE}o5B@Z^VDd^$`Tv2ND` zD0PGGCn7eFK6bnEwu`}nAjrtRg&q3NA!kh8k_~($W<#;h(h+82|Q}875Tk(DIUGbRsviLliIvr&M#IRT) z7K&M7s;C#f7CsS93vUar3x|XQ!aiX;E*?3A?dk!!ED>VdIL3y;;jllSt4mleZfwHJ z;%XC?ovTS$>0BgX*|>1RO5>^%mX#Zmu*_U2Vd=SG!qRb735(?dij^MrGn_v`dJR6t zDvR-w`m50mtoS))BF|in!cCZ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{7lQYpy!c9aDy>7K&v}mHvmM;X{&n!17h!I&`VzG3 zg3t88G#$?S3g(_1!?KNDtNx@0?L=nM?(&37!ZP!1bET=zRAB<+Zez0H9YX>C7rs<~ zl3a)#`nU#1hPo~(|D>FQr5G_|Va*1;m4`~ltznJY8ho?|HhI!j9cdq=yn{tXOaZK! zmQxf#)a?9bqH`SPCgR;+fW$^*iCiyvx&}q6^cA5Ll&1E{kmMDOLk@{NOU`{LW$=gRi`u(o<^QS6yDnxp)!73 z(;A|?ca+P)uFHU8*AG+GO8@Pjbre))@2u}8_?%Ni)Ex)8!u0s`w7#x0eP^2fvHkhJ zv+cth^vSBH(x6F~Ld;0ALc_0(3KCCO8#jGKe7gVd``T_kzq{|Hrd!W6-h8z!tu{&Z zRhoFeZ#MC&|7)j$#J9PPDMT795?{+9t~hOY zma^fS!PcAGgBioIkVX_et(|1jNi*rS{kfgX O#~)n>%NsY??*9VHmAT3Q diff --git a/server/initialize/sqlite.go b/server/initialize/sqlite.go index 68315ffe..235fa9d4 100644 --- a/server/initialize/sqlite.go +++ b/server/initialize/sqlite.go @@ -11,7 +11,7 @@ import ( func Sqlite() { admin := global.GVA_CONFIG.Sqlite if db, err := gorm.Open("sqlite3", fmt.Sprintf("%s?%s", admin.Path,admin.Config)); err != nil { - global.GVA_LOG.Error("DEFAULTDB数据库启动异常", err) + global.GVA_LOG.Error("DEFAULT DB数据库启动异常", err) } else { global.GVA_DB = db global.GVA_DB.LogMode(admin.LogMode) diff --git a/server/service/sys_menu.go b/server/service/sys_menu.go index ffa04dc3..086386fb 100644 --- a/server/service/sys_menu.go +++ b/server/service/sys_menu.go @@ -14,8 +14,8 @@ import ( // @return err error // @return menus []model.SysMenu func GetMenuTree(authorityId string) (err error, menus []model.SysMenu) { - sql := "SELECT authority_menu.created_at,authority_menu.updated_at,authority_menu.deleted_at,authority_menu.menu_level,authority_menu.parent_id,authority_menu.path,authority_menu.`name`,authority_menu.hidden,authority_menu.component,authority_menu.title,authority_menu.icon,authority_menu.sort,authority_menu.menu_id,authority_menu.authority_id FROM sys_menus authority_menu WHERE authority_menu.authority_id = ? AND authority_menu.parent_id = ?" - + //sql := "SELECT authority_menu.created_at,authority_menu.updated_at,authority_menu.deleted_at,authority_menu.menu_level,authority_menu.parent_id,authority_menu.path,authority_menu.`name`,authority_menu.hidden,authority_menu.component,authority_menu.title,authority_menu.icon,authority_menu.sort,authority_menu.menu_id,authority_menu.authority_id FROM sys_menus authority_menu WHERE authority_menu.authority_id = ? AND authority_menu.parent_id = ?" + sql := "SELECT authority_menu.created_at,authority_menu.updated_at,authority_menu.deleted_at,authority_menu.menu_level,authority_menu.parent_id,authority_menu.path,authority_menu.`name`,authority_menu.hidden,authority_menu.component,authority_menu.title,authority_menu.icon,authority_menu.sort,authority_menu.id menu_id,am.sys_authority_authority_id authority_id FROM sys_base_menus authority_menu left join sys_authority_menus am on authority_menu.id = am.sys_base_menu_id WHERE am.sys_authority_authority_id = ? AND authority_menu.parent_id = ? " err = global.GVA_DB.Raw(sql, authorityId, 0).Scan(&menus).Error for i := 0; i < len(menus); i++ { err = getChildrenList(&menus[i], sql) @@ -119,7 +119,8 @@ func AddMenuAuthority(menus []model.SysBaseMenu, authorityId string) (err error) // @return err error // @return menus []SysBaseMenu func GetMenuAuthority(authorityId string) (err error, menus []model.SysMenu) { - sql := "SELECT authority_menu.created_at,authority_menu.updated_at,authority_menu.deleted_at,authority_menu.menu_level,authority_menu.parent_id,authority_menu.path,authority_menu.`name`,authority_menu.hidden,authority_menu.component,authority_menu.title,authority_menu.icon,authority_menu.sort,authority_menu.menu_id,authority_menu.authority_id FROM sys_menus authority_menu WHERE authority_menu.authority_id = ?" + //sql := "SELECT authority_menu.created_at,authority_menu.updated_at,authority_menu.deleted_at,authority_menu.menu_level,authority_menu.parent_id,authority_menu.path,authority_menu.`name`,authority_menu.hidden,authority_menu.component,authority_menu.title,authority_menu.icon,authority_menu.sort,authority_menu.menu_id,authority_menu.authority_id FROM sys_menus authority_menu WHERE authority_menu.authority_id = ?" + sql := "SELECT authority_menu.created_at,authority_menu.updated_at,authority_menu.deleted_at,authority_menu.menu_level,authority_menu.parent_id,authority_menu.path,authority_menu.`name`,authority_menu.hidden,authority_menu.component,authority_menu.title,authority_menu.icon,authority_menu.sort,authority_menu.id menu_id,am.sys_authority_authority_id authority_id FROM sys_base_menus authority_menu left join sys_authority_menus am on authority_menu.id = am.sys_base_menu_id WHERE am.sys_authority_authority_id = ? " err = global.GVA_DB.Raw(sql, authorityId).Scan(&menus).Error return err, menus } From 251f0219828f824bd99522b8f574ccce42cd1f4b Mon Sep 17 00:00:00 2001 From: rikugun Date: Mon, 13 Apr 2020 10:25:21 +0800 Subject: [PATCH 2/4] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E9=94=99=E8=AF=AF?= =?UTF-8?q?=E7=9A=84=E4=BF=AE=E6=94=B9=E4=BD=BF=E7=94=A8=E8=AF=95=E5=9B=BE?= =?UTF-8?q?=E6=9F=A5=E8=AF=A2=E8=8F=9C=E5=8D=95=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/service/sys_menu.go | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/server/service/sys_menu.go b/server/service/sys_menu.go index 086386fb..e7c81d7a 100644 --- a/server/service/sys_menu.go +++ b/server/service/sys_menu.go @@ -14,8 +14,7 @@ import ( // @return err error // @return menus []model.SysMenu func GetMenuTree(authorityId string) (err error, menus []model.SysMenu) { - //sql := "SELECT authority_menu.created_at,authority_menu.updated_at,authority_menu.deleted_at,authority_menu.menu_level,authority_menu.parent_id,authority_menu.path,authority_menu.`name`,authority_menu.hidden,authority_menu.component,authority_menu.title,authority_menu.icon,authority_menu.sort,authority_menu.menu_id,authority_menu.authority_id FROM sys_menus authority_menu WHERE authority_menu.authority_id = ? AND authority_menu.parent_id = ?" - sql := "SELECT authority_menu.created_at,authority_menu.updated_at,authority_menu.deleted_at,authority_menu.menu_level,authority_menu.parent_id,authority_menu.path,authority_menu.`name`,authority_menu.hidden,authority_menu.component,authority_menu.title,authority_menu.icon,authority_menu.sort,authority_menu.id menu_id,am.sys_authority_authority_id authority_id FROM sys_base_menus authority_menu left join sys_authority_menus am on authority_menu.id = am.sys_base_menu_id WHERE am.sys_authority_authority_id = ? AND authority_menu.parent_id = ? " + sql := "SELECT authority_menu.created_at,authority_menu.updated_at,authority_menu.deleted_at,authority_menu.menu_level,authority_menu.parent_id,authority_menu.path,authority_menu.`name`,authority_menu.hidden,authority_menu.component,authority_menu.title,authority_menu.icon,authority_menu.sort,authority_menu.menu_id,authority_menu.authority_id FROM authority_menu WHERE authority_menu.authority_id = ? AND authority_menu.parent_id = ?" err = global.GVA_DB.Raw(sql, authorityId, 0).Scan(&menus).Error for i := 0; i < len(menus); i++ { err = getChildrenList(&menus[i], sql) @@ -119,8 +118,7 @@ func AddMenuAuthority(menus []model.SysBaseMenu, authorityId string) (err error) // @return err error // @return menus []SysBaseMenu func GetMenuAuthority(authorityId string) (err error, menus []model.SysMenu) { - //sql := "SELECT authority_menu.created_at,authority_menu.updated_at,authority_menu.deleted_at,authority_menu.menu_level,authority_menu.parent_id,authority_menu.path,authority_menu.`name`,authority_menu.hidden,authority_menu.component,authority_menu.title,authority_menu.icon,authority_menu.sort,authority_menu.menu_id,authority_menu.authority_id FROM sys_menus authority_menu WHERE authority_menu.authority_id = ?" - sql := "SELECT authority_menu.created_at,authority_menu.updated_at,authority_menu.deleted_at,authority_menu.menu_level,authority_menu.parent_id,authority_menu.path,authority_menu.`name`,authority_menu.hidden,authority_menu.component,authority_menu.title,authority_menu.icon,authority_menu.sort,authority_menu.id menu_id,am.sys_authority_authority_id authority_id FROM sys_base_menus authority_menu left join sys_authority_menus am on authority_menu.id = am.sys_base_menu_id WHERE am.sys_authority_authority_id = ? " + sql := "SELECT authority_menu.created_at,authority_menu.updated_at,authority_menu.deleted_at,authority_menu.menu_level,authority_menu.parent_id,authority_menu.path,authority_menu.`name`,authority_menu.hidden,authority_menu.component,authority_menu.title,authority_menu.icon,authority_menu.sort,authority_menu.menu_id,authority_menu.authority_id FROM authority_menu WHERE authority_menu.authority_id = ?" err = global.GVA_DB.Raw(sql, authorityId).Scan(&menus).Error return err, menus } From 2023d4de1af494e61aceac8ef7f3d6a131d1ae25 Mon Sep 17 00:00:00 2001 From: rikugun Date: Mon, 13 Apr 2020 10:26:45 +0800 Subject: [PATCH 3/4] =?UTF-8?q?=E9=BB=98=E8=AE=A4=E4=BD=BF=E7=94=A8mysql?= =?UTF-8?q?=20=E6=95=B0=E6=8D=AE=E5=BA=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/config.yaml b/server/config.yaml index 30af1073..9295d953 100644 --- a/server/config.yaml +++ b/server/config.yaml @@ -39,7 +39,7 @@ system: use-multipoint: false env: 'public' # Change to "develop" to skip authentication for development mode addr: 8888 - db-type: "sqlite" # support mysql/sqlite + db-type: "mysql" # support mysql/sqlite # captcha configuration captcha: From 1c960b946721b5b2082db1675b4d3e1e9ea5b54c Mon Sep 17 00:00:00 2001 From: FWangZil Date: Wed, 22 Apr 2020 14:32:20 +0800 Subject: [PATCH 4/4] README.md: fix text bug --- README-zh_CN.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README-zh_CN.md b/README-zh_CN.md index 68a0bb3c..e488f97a 100644 --- a/README-zh_CN.md +++ b/README-zh_CN.md @@ -38,7 +38,7 @@ master:2.0开发版代码 ``` - node版本 > v8.6.0 - golang版本 >= v1.11 -- IDE推荐:Golang +- IDE推荐:Goland - 各位在clone项目以后,把db文件导入自己创建的库后,最好前往七牛云申请自己的空间地址。 - 替换掉项目中的七牛云公钥,私钥,仓名和默认url地址,以免发生测试文件数据错乱 ```