diff --git a/README-en.md b/README-en.md new file mode 100644 index 000000000..3120eaef3 --- /dev/null +++ b/README-en.md @@ -0,0 +1,370 @@ +### Live source code, short video, live with goods, games to play, imitation than the heart, hunting, TT voice chat, beauty about to play, play with the system source code open black, about to play source code + +---------------- +
+ + + + + + +
+ +English | [简体中文](./README.md) + +### Front-end: Vue Mobile Terminal: Android + iOS + +### The micro service (Docker container) consists of: + +- **goim** :Bilibili station IM architecture: +- **livego** :High-performance RTMP server based on Golang test model: Aliyun 32 core 64G exclusive server 30000 concurrent pull stream, CPU occupation rate is less than 50%! +- **webrtc** :Janus Gateway: MeetEcho's excellent universal WebRTC server (SFU); +- **MongoDB** :Distributed database based on documents built in cloud era; +- **Redis**:In-memory data structure storage, used as a database, cache, and message broker; +- **kafka** :Queue group chat, private chat, message notification, etc. +- **Coturn** :Open source projects for Turn and Stun Server; +- **Nginx** :High performance load balancer, Web server and reverse proxies supported by HTTP3 / Quiche and Brtoli; +- **Docker**:A platform for building, deploying, and managing containerized applications. +- **Admin**: PHP (old business PHP backend) + GIN (API interface refactoring) + VUE + ELEMent-UI +---------------- + + +**Contact us:** +![](https://img-blog.csdnimg.cn/20200623093238797.png) + +---------------- +WeChat:BCFind5 【Please note the good information】 + +Telegram:@BCFind5 + +---------------- + + +[Background presentation address:](http://www.jinqianlive.com/admin) http://www.jinqianlive.com/admin + +user :test +pass: test + +---------------- +[Live short video](https://baoya.lanzous.com/imcL9e57tej) https://baoya.lanzous.com/imcL9e57tej + +---------------- +[Voice chat room](http://app.6sjs.com/wej8) http://app.6sjs.com/wej8 + +---------------- +IOS :https://pan.baidu.com/s/18KaHu-39TMQLetb0m7XD0Q 提取码:v929 + +---------------- + +doc:http://www.jinqianlive.com/appapi/listAllApis.php?type=expand + +---------------- + +**The front-end display** +![The front-end display](https://img-blog.csdnimg.cn/20200908194734911.jpg?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3UwMTIxMTUxOTc=,size_16,color_FFFFFF,t_70#pic_center) + +**Backend interface** +![Backend interface](https://img-blog.csdnimg.cn/20200907180807339.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3UwMTIxMTUxOTc=,size_16,color_FFFFFF,t_70#pic_center) + + +---------------- + +### Technical structure + + +**System development language** +- **PHP | golang video interactive system by the WEB system, REDIS service, MYSQL services, video services, chat, background management system, and regularly monitor, background management using PHP + golang language development, all services provide lateral extension.** + +------------ + +### Environment set up + + +**Install golang** +```bash +wget http://www.golangtc.com/static/go/go1.3.linux-amd64.tar.gz +``` +```bash +tar -C /usr/local -zxvf go1.3.linux-amd64.tar.gz +``` + +```bash +vim /etc/profile +export GOROOT=/usr/local/go +export PATH=$PATH:$GOROOT/bin +export GOPATH="$HOME/go +``` +**success** + +![](https://img-blog.csdnimg.cn/20200922210610471.png#pic_center) + +**install etcd** +```bash +curl -L https://github.com/coreos/etcd/releases/download/v3.3.2/etcd-v3.3.2-linux-amd64.tar.gz -o etcd-v3.3.2-linux-amd64.tar.gz +``` +```bash +tar -zxf etcd-v3.3.2-linux-amd64.tar.gz +``` +```bash +mv etcd-v3.3.2-linux-amd64/etcd* /$GOPATH/bin +``` +```bash +./etcd +``` +**success** + +![](https://img-blog.csdnimg.cn/20200922213137699.png#pic_center) + +**install Protobuf tools** + +```bash +mkdir /www/go/live +``` +```bash +cd /www/go/live +``` +```bash +go mod init live +#go.mod file +``` +**Go Micro RPC** +```bash +go get github.com/micro/go-micro +``` +**install protoc** +```bash +from https://github.com/protocolbuffers/protobuf/releases down`new`version protoc : +./configure +make && make install +``` +```bash +protoc --version +``` +![success](https://img-blog.csdnimg.cn/20200922221355356.png#pic_center) + +**install protoc-gen-micro** +```bash +go get -u github.com/micro/protoc-gen-micro +``` +**install protoc-gen-go** +```bash +go get -u github.com/golang/protobuf/protoc-gen-go + +cp protoc-gen-* /usr/local/bin/ + +$GOPATH/bin copy /usr/local/bin +``` + +![](https://img-blog.csdnimg.cn/20200922222247686.png#pic_center) + +```golang +mkdir /www/go/live/proto +``` +```proto3 +syntax = "proto3"; + +service Live { +rpc Call(LiveRequest) returns (LiveResponse) {} +} + +message LiveRequest { +string name = 1; +} + +message liveResponse { +string result = 1; +} +``` +```bash +protoc auto code +protoc --proto_path=. --micro_out=. --go_out=. proto/live.proto +``` +>: +![](https://img-blog.csdnimg.cn/20200922224029282.png#pic_center) + +**Write the Go service implementation code live make mian.go** +```golang +package main + +import ( + "context" + "fmt" + "github.com/micro/go-micro" + proto "live/proto" +) + +type LiveServiceHandler struct{} + +func (g *LiveServiceHandler)Call(ctx context.Context, req *proto.LiveRequest, rsp *proto.LiveResponse) error { + rsp.Result = "github:https://github.com/DOUBLE-Baller/" + req.Name + return nil +} + +func main() { + service := micro.NewService( + micro.Name("go.micro.api.Live"), //go.micro.api namespace + ) + + // init + service.Init() + + // register + proto.RegisterLiveHandler(service.Server(), new(LiveServiceHandler)) + + // run + if err := service.Run(); err != nil { + fmt.Println(err) + } +} +``` +```golang +go run main.go +``` +```bash +attention:add MICRO_REGISTRY=etcd used go run main.go --registry=etcd +``` + +![](https://img-blog.csdnimg.cn/2020092223034366.png#pic_center) +failure +![](https://img-blog.csdnimg.cn/20200922225010494.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3UwMTIxMTUxOTc=,size_16,color_FFFFFF,t_70#pic_center) +```bash +attention:add go.mod last +replace google.golang.org/grpc => google.golang.org/grpc v1.26.0 +``` +![](https://img-blog.csdnimg.cn/20200923092941557.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3UwMTIxMTUxOTc=,size_16,color_FFFFFF,t_70#pic_center) + + +**use go micro provide HTTP API** +```bash +go get github.com/micro/micro/v2 + +finish, $GOPATH/bin make micro run,cp from /user/local/bin +``` +```bash +micro api --handler=rpc +``` +```bash +default:8080 +``` + +![](https://img-blog.csdnimg.cn/20200922233014118.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3UwMTIxMTUxOTc=,size_16,color_FFFFFF,t_70#pic_center) + +visit IP:8080 ![](https://img-blog.csdnimg.cn/20200922233410216.png#pic_center) + +```bash +micro call go.micro.api.Live Live.Call '{"name": "momo"}' +``` +![](https://img-blog.csdnimg.cn/20200923111240482.png#pic_center) + + +goim +============== +`Terry-Mao/goim` is a IM and push notification server cluster. + +--------------------------------------- + * [Features](#features) + * [Installing](#installing) + * [Configurations](#configurations) + * [Examples](#examples) + * [Documents](#documents) + * [More](#more) + +--------------------------------------- + +## Features + * Light weight + * High performance + * Pure Golang + * Supports single push, multiple push, room push and broadcasting + * Supports one key to multiple subscribers (Configurable maximum subscribers count) + * Supports heartbeats (Application heartbeats, TCP, KeepAlive) + * Supports authentication (Unauthenticated user can't subscribe) + * Supports multiple protocols (WebSocket,TCP) + * Scalable architecture (Unlimited dynamic job and logic modules) + * Asynchronous push notification based on Kafka + +## Installing +### Dependencies +```sh +$ yum -y install java-1.7.0-openjdk +``` + +### Install Kafka + +Please follow the official quick start [here](http://kafka.apache.org/documentation.html#quickstart). + +### Install Golang environment + +Please follow the official quick start [here](https://golang.org/doc/install). + +### Deploy goim +1.Download goim +```sh +$ yum install git +$ cd $GOPATH/src +$ git clone https://github.com/Terry-Mao/goim.git +$ cd $GOPATH/src/goim +$ go get ./... +``` + +2.Install router、logic、comet、job modules(You might need to change the configuration files based on your servers) +```sh +$ cd $GOPATH/src/goim/router +$ go install +$ cp router-example.conf $GOPATH/bin/router.conf +$ cp router-log.xml $GOPATH/bin/ +$ cd ../logic/ +$ go install +$ cp logic-example.conf $GOPATH/bin/logic.conf +$ cp logic-log.xml $GOPATH/bin/ +$ cd ../comet/ +$ go install +$ cp comet-example.conf $GOPATH/bin/comet.conf +$ cp comet-log.xml $GOPATH/bin/ +$ cd ../logic/job/ +$ go install +$ cp job-example.conf $GOPATH/bin/job.conf +$ cp job-log.xml $GOPATH/bin/ +``` + +Everything is DONE! + +### Run goim +You may need to change the log files location. +```sh +$ cd /$GOPATH/bin +$ nohup $GOPATH/bin/router -c $GOPATH/bin/router.conf 2>&1 > /data/logs/goim/panic-router.log & +$ nohup $GOPATH/bin/logic -c $GOPATH/bin/logic.conf 2>&1 > /data/logs/goim/panic-logic.log & +$ nohup $GOPATH/bin/comet -c $GOPATH/bin/comet.conf 2>&1 > /data/logs/goim/panic-comet.log & +$ nohup $GOPATH/bin/job -c $GOPATH/bin/job.conf 2>&1 > /data/logs/goim/panic-job.log & +``` + +If it fails, please check the logs for debugging. + +### Testing + +Check the push protocols here[push HTTP protocols](./docs/push.md) + +## Configurations +TODO + +## Examples +Websocket: [Websocket Client Demo](https://github.com/Terry-Mao/goim/tree/master/examples/javascript) + +Android: [Android SDK](https://github.com/roamdy/goim-sdk) + +iOS: [iOS](https://github.com/roamdy/goim-oc-sdk) + +## Documents +[push HTTP protocols](./docs/en/push.md) + +[Comet client protocols](./docs/en/proto.md) + + +==The problem of feedback== + +**Please let us know if you have any problems during use. You can use the following contact information to communicate with us** + + + + diff --git a/README.md b/README.md index 38b0cf982..cd0e7b011 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,17 @@ ### 直播源码,短视频,直播带货,游戏陪玩,仿比心,猎游,tt语音聊天,美女约玩,陪玩系统源码开黑,约玩源码 ---------------- +
+ + + + + + +
+ +[English](./README-en.md) | 简体中文 + ### 前端: VUE 移动端: Android + ios ### 微服务(Docker容器)组成: @@ -14,12 +25,12 @@ - **Coturn** :TURN和STUN Server的开源项目; - **Nginx** :高性能负载平衡器,Web服务器和有HTTP3 / Quiche和Brtoli支持的反向代理; - **Docker**:用于构建、部署和管理容器化应用程序的平台。 -- **后台管理界面**: php7 laravel +- **后台管理界面**: php(老业务php后台)+ gin(API接口重构)+ vue + Element-UI ---------------- **技术群:** -![技术群](https://img-blog.csdnimg.cn/20200623093238797.png) +![](https://img-blog.csdnimg.cn/20200623093238797.png) 纯技术群,入群有一定门槛,谢谢理解。 @@ -28,15 +39,16 @@ 博客地址:https://blog.csdn.net/u012115197/article/details/106916635 + ---------------- -### 团队接活 +### 商业合作 (UI设计,定制开发,系统重构,代理推广等) | 类目 | 价格 | 商业授权 | | -------- | -----: | :----: | -| 基础开源版本 | ¥0 | 无(不可商用) | -| 授权版本 | ¥15000 | 有(可以商用) | -| 定制,系统优化,重构,商业合作等| ¥30000起| 有(可以商用) | +| 基础开源版本(php+go的基础版本仅供学习使用) | ¥0 | 无(不可商用) | +| php国内商用版本 | ¥15000 | 有(可以商用) | +| golang海外商用版本 | ¥30000起| 有(可以商用)| ---------------- @@ -86,14 +98,14 @@ IOS 视频演示:https://pan.baidu.com/s/18KaHu-39TMQLetb0m7XD0Q 提取码:v ## 后端 **系统开发语言** -- **PHP 视频互动系统由 WEB 系统、REDIS 服务、MYSQL 服务、视频服务、聊天服务、后台管理系统和定时监控组成,后台管理采用PHP 语言开发,所有服务提供横向扩展。** +- **PHP|golang 视频互动系统由 WEB 系统、REDIS 服务、MYSQL 服务、视频服务、聊天服务、后台管理系统和定时监控组成,后台管理采用PHP + golang 语言开发,所有服务提供横向扩展。** 1. WEB 系统提供页面、接口逻辑。 2. REDIS 服务提供数据的缓存、存储动态数据。 3. MYSQL 服务提供静态数据的存储。 4. 视频服务提供视频直播,傍路直播,转码、存储、点播等 支持腾讯云 阿里云 七牛等 自建流媒体服务器等(包括两套成熟方案 nginx_rtmp 和 golang的)。 5. golang +kafka 队列 聊天服务提供直播群聊,私聊,消息通知等。 -6. consul + grpc + docker 系统监控:监听主播异常掉线情况、直播消息推送等。 +6. consul + grpc 系统监控:监听主播异常掉线情况、直播消息推送等。 ------------ ## 分布式架构 @@ -450,8 +462,7 @@ micro call go.micro.api.Live Live.Call '{"name": "momo"}' ``` ------------ - -**聊天服务** +## goim聊天服务 #### 特性 * 轻量级 @@ -600,6 +611,7 @@ router 属于有状态节点,logic可以使用一致性hash配置节点,增 job 根据kafka的partition来扩展多job工作方式,具体可以参考下kafka的partition负载 ------------ + ## PHP 为什么 “慢” ??? ### Laravel + Swoole 提速 30倍 @@ -816,69 +828,6 @@ class DatabaseManager extends LaravelDatabaseManager } ``` - - -swoole扩展安装 -```shell -pecl install swoole -``` - -swoole框架 -```shell -composer install -``` -将`webroot`目录配置到Nginx/Apache的虚拟主机目录中,使`webroot/`可访问。 - -详细部署说明 ----- - -__1. 安装composer(php依赖包工具)__ - -```shell -curl -sS https://getcomposer.org/installer | php -mv composer.phar /usr/local/bin/composer -``` - -注意:如果未将php解释器程序设置为环境变量PATH中,需要设置。因为composer文件第一行为#!/usr/bin/env php,并不能修改。 -更加详细的对composer说明:http://blog.csdn.net/zzulp/article/details/18981029 - -__2. composer install__ - -切换到PHPWeb项目目录,执行指令composer install,如很慢则 - -```shell -composer install --prefer-dist -``` - -__3. Ningx配置HTTPS__ - -* Apache请参照Nginx配置,自行修改实现 -* 这里使用了`www.xxx.com`作为域名,需要配置host或者改成你的域名 - -```shell -server { - listen 80; - server_name www.xxx.com; - index index.html index.php; - - location / { - root /path/to/web/webroot; - - proxy_set_header X-Real-IP $remote_addr; - if (!-e $request_filename) { - rewrite ^/(.*)$ /index.php; - } - } - - location ~ .*\.(php|php5)?$ { - fastcgi_pass 127.0.0.1:9000; - fastcgi_index index.php; - include fastcgi.conf; - } -} -``` -`**注意:https下必须采取wss So-有两种方案 1.采用nginx 反向代理4431端口 swoole 的端口和4431进行通讯。2.swoole 确认是否启用了openssl,是否在编译时加入了--enable-openssl的支持,然后在set 证书路径即可。两种方案选择其一就好,不过第一种方案有个潜在神坑就是你通过反向代理拿不到真实的IP地址了,这点值得注意,Nginx有办法拿到真实的ip,不懂可以私聊我,光wss的坑太多了就不一一说了。**` - ------------ ## 何为 laravel-admin @@ -985,7 +934,6 @@ php artisan admin:controller UserController **在使用中有任何问题,欢迎反馈给我们,可以用以下联系方式跟我们交流** +English | [简体中文](./README.md) -~~整套直播教学视频 进群后@群主索取~~ -![在这里插入图片描述](https://img-blog.csdnimg.cn/20200623094714713.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3UwMTIxMTUxOTc=,size_16,color_FFFFFF,t_70#pic_center) diff --git a/go_admin/.docker-compose/nginx/conf.d/my.conf b/go_admin/.docker-compose/nginx/conf.d/my.conf new file mode 100644 index 000000000..9a1685dee --- /dev/null +++ b/go_admin/.docker-compose/nginx/conf.d/my.conf @@ -0,0 +1,26 @@ +server { + listen 8080; + server_name localhost; + + #charset koi8-r; + #access_log logs/host.access.log main; + + location / { + root /usr/share/nginx/html; + add_header Cache-Control 'no-store, no-cache, must-revalidate, proxy-revalidate, max-age=0'; + try_files $uri $uri/ /index.html; + } + + location /api { + proxy_set_header Host $http_host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + rewrite ^/api/(.*)$ /$1 break; #重写 + proxy_pass http://177.7.0.12:8888; # 设置代理服务器的协议和地址 + } + + location /api/swagger/index.html { + proxy_pass http://127.0.0.1:8888/swagger/index.html; + } + } \ No newline at end of file diff --git a/go_admin/.docker-compose/shell/server-handle.sh b/go_admin/.docker-compose/shell/server-handle.sh new file mode 100644 index 000000000..46cec0fcc --- /dev/null +++ b/go_admin/.docker-compose/shell/server-handle.sh @@ -0,0 +1,88 @@ +#! /bin/bash + +rm -f ./config.yaml +# 生成config.yaml文件, 用于docker-compose的使用 +touch ./config.yaml +filename="./config.yaml" +cat>"${filename}"< /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/go_admin/LICENSE b/go_admin/LICENSE new file mode 100644 index 000000000..d9dd9501f --- /dev/null +++ b/go_admin/LICENSE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright 2019 JiZhao Jiang + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/go_admin/docker-compose.yaml b/go_admin/docker-compose.yaml new file mode 100644 index 000000000..d997d7995 --- /dev/null +++ b/go_admin/docker-compose.yaml @@ -0,0 +1,66 @@ +version: "3" + +networks: + network: + ipam: + driver: default + config: + - subnet: '177.7.0.0/16' + +services: + web: + build: + context: ./ + dockerfile: ./dockerfile_web + container_name: gva-web + restart: always + ports: + - '8080:8080' + depends_on: + - server + command: [ 'nginx-debug', '-g', 'daemon off;' ] + networks: + network: + ipv4_address: 177.7.0.11 + + server: + build: + context: ./ + dockerfile: ./dockerfile_server + container_name: gva-server + restart: always + ports: + - '8888:8888' + depends_on: + - mysql + - redis + links: + - mysql + - redis + networks: + network: + ipv4_address: 177.7.0.12 + + mysql: + image: mysql:8.0.21 + container_name: gva-mysql + command: mysqld --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci #设置utf8字符集 + restart: always + ports: + - "13306:3306" # host物理直接映射端口为13306 + environment: + MYSQL_DATABASE: 'qmPlus' # 初始化启动时要创建的数据库的名称 + MYSQL_ROOT_PASSWORD: 'Aa@6447985' # root管理员用户密码 + networks: + network: + ipv4_address: 177.7.0.13 + + redis: + image: redis:6.0.6 + container_name: gva-redis # 容器名 + restart: always + ports: + - '16379:6379' + networks: + network: + ipv4_address: 177.7.0.14 \ No newline at end of file diff --git a/go_admin/docker/docker-start.sh b/go_admin/docker/docker-start.sh new file mode 100644 index 000000000..df7e2e76c --- /dev/null +++ b/go_admin/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/go_admin/docker/etc/nginx/nginx.conf.tpl b/go_admin/docker/etc/nginx/nginx.conf.tpl new file mode 100644 index 000000000..c96973cb6 --- /dev/null +++ b/go_admin/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/go_admin/dockerfile_server b/go_admin/dockerfile_server new file mode 100644 index 000000000..54d23ddad --- /dev/null +++ b/go_admin/dockerfile_server @@ -0,0 +1,28 @@ +FROM golang:alpine + +ENV GO111MODULE=on +ENV GOPROXY=https://goproxy.io,direct +WORKDIR /go/src/gin-vue-admin +COPY server/ ./ + +RUN cat ./config.yaml +COPY .docker-compose/shell/server-handle.sh . +RUN ls -al +RUN sh ./server-handle.sh +RUN rm -f server-handle.sh +RUN cat ./config.yaml + +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 ./server diff --git a/go_admin/dockerfile_web b/go_admin/dockerfile_web new file mode 100644 index 000000000..2f0d26a15 --- /dev/null +++ b/go_admin/dockerfile_web @@ -0,0 +1,18 @@ +FROM node:12.16.1 + +WORKDIR /gva_web/ +COPY web/ . + +RUN npm install -g cnpm --registry=https://registry.npm.taobao.org +RUN cnpm install || npm install +RUN npm run build + +FROM nginx:alpine +LABEL MAINTAINER="SliverHorn@sliver_horn@qq.com" + +COPY .docker-compose/nginx/conf.d/my.conf /etc/nginx/conf.d/my.conf +COPY --from=0 /gva_web/dist /usr/share/nginx/html +RUN cat /etc/nginx/nginx.conf +RUN cat /etc/nginx/conf.d/my.conf +RUN ls -al /usr/share/nginx/html +CMD ls -al /usr/share/nginx/html diff --git a/go_admin/package-lock.json b/go_admin/package-lock.json new file mode 100644 index 000000000..48e341a09 --- /dev/null +++ b/go_admin/package-lock.json @@ -0,0 +1,3 @@ +{ + "lockfileVersion": 1 +}