diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000000000000000000000000000000000000..4e352a5199b1210d61b1429f1b13a40c45221ba4 --- /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 0000000000000000000000000000000000000000..5a055230e9d201b1baa8bf3abb7885598269bb0b --- /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/README-zh_CN.md b/README-zh_CN.md index 2ed395a22f0dbc82d59054ff538ec19d79053e02..447bd5edbd1a6b4a7092563659716555a917d374 100644 --- a/README-zh_CN.md +++ b/README-zh_CN.md @@ -68,7 +68,7 @@ Gin-vue-admin 的成长离不开大家的支持,如果你愿意为 gin-vue-adm ``` - node版本 > v8.6.0 - golang版本 >= v1.11 -- IDE推荐:Golang +- IDE推荐:Goland - 各位在clone项目以后,把db文件导入自己创建的库后,最好前往七牛云申请自己的空间地址。 - 替换掉项目中的七牛云公钥,私钥,仓名和默认url地址,以免发生测试文件数据错乱 ``` diff --git a/docker/docker-start.sh b/docker/docker-start.sh new file mode 100755 index 0000000000000000000000000000000000000000..df7e2e76c740b6553edec7c4374ba06cf8b29afc --- /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 0000000000000000000000000000000000000000..c96973cb6b7af8df2e6e6d5b62ab51caa09e88ff --- /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 6f516f4fdbf4a32764dae6d6edfb422f06145783..ea5bab077775e773b6d3c84e54b300783484abe5 100644 --- a/server/config.yaml +++ b/server/config.yaml @@ -1,40 +1,55 @@ -captcha: - key-long: 4 - img-width: 120 - img-height: 40 +# Gin-Vue-Admin Global Configuration + +# casbin configuration casbin: - model-path: ./resource/rbac_model.conf + model-path: './resource/rbac_model.conf' + +# jwt configuration jwt: - signing-key: qmPlus -log: - prefix: '[GIN-VUE-ADMIN]' - log-file: true - stdout: DEBUG - file: DEBUG + signing-key: 'qmPlus' + +# mysql connect configuration mysql: - username: root - password: Aa@6447985 - path: 127.0.0.1:3306 - db-name: qmplus - config: charset=utf8&parseTime=True&loc=Local - max-idle-conns: 10 - max-open-conns: 10 - log-mode: true + username: root + password: 'Aa@6447985' + path: '127.0.0.1:3306' + db-name: 'qmPlus' + config: 'charset=utf8&parseTime=True&loc=Local' + max-idle-conns: 10 + max-open-conns: 10 + log-mode: true +#sqlite 配置 +sqlite: + path: db/db.db + log-mode: true + config: 'loc=Asia/Shanghai' +# oss configuration qiniu: - access-key: 25j8dYBZ2wuiy0yhwShytjZDTX662b8xiFguwxzZ - secret-key: pgdbqEsf7ooZh7W3xokP833h3dZ_VecFXPDeG5JY + access-key: '25j8dYBZ2wuiy0yhwShytjZDTX662b8xiFguwxzZ' + secret-key: 'pgdbqEsf7ooZh7W3xokP833h3dZ_VecFXPDeG5JY' + +# redis configuration redis: - addr: 127.0.0.1:6379 - password: "" - db: 0 -sqlite: - username: "" - password: "" - path: db/db.db - config: loc=Asia/Shanghai - log-mode: true + addr: '127.0.0.1:6379' + passwprd: '' + db: 0 + +# system configuration system: - use-multipoint: false - env: public - addr: 8888 - db-type: mysql + use-multipoint: false + env: 'public' # Change to "develop" to skip authentication for development mode + addr: 8888 + db-type: "mysql" # support mysql/sqlite + +# captcha configuration +captcha: + key-long: 4 + img-width: 120 + img-height: 40 + +# logger configuration +log: + prefix: '[GIN-VUE-ADMIN]' + log-file: true + stdout: 'DEBUG' + file: 'DEBUG' 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 Binary files a/server/db/db.db and b/server/db.db differ