commit
032664e684
4
.gitignore
vendored
4
.gitignore
vendored
@ -6,4 +6,6 @@ temp/
|
||||
vendor
|
||||
tmp/
|
||||
config/settings.dev.yml
|
||||
logs
|
||||
logs
|
||||
mysql/data
|
||||
redis/data
|
12
Dockerfile
Normal file
12
Dockerfile
Normal file
@ -0,0 +1,12 @@
|
||||
FROM golang:1.14
|
||||
|
||||
WORKDIR /opt/ferry
|
||||
|
||||
COPY . .
|
||||
|
||||
ENV GOPROXY="https://goproxy.cn"
|
||||
|
||||
RUN go mod download
|
||||
RUN go build -o ferry .
|
||||
|
||||
EXPOSE 8002
|
72
docker-compose.yml
Normal file
72
docker-compose.yml
Normal file
@ -0,0 +1,72 @@
|
||||
version: "3"
|
||||
services:
|
||||
db:
|
||||
hostname: mysql
|
||||
container_name: ferry_mysql
|
||||
image: mysql:5.7.31
|
||||
restart: always
|
||||
environment:
|
||||
- TZ=Asia/Shanghai
|
||||
- MYSQL_ROOT_PASSWORD=123456
|
||||
volumes:
|
||||
- ./docker/mysql/data:/var/lib/mysql/data # 映射数据库保存目录到宿主机,防止数据丢失
|
||||
- ./docker/mysql/config/my.cnf:/etc/mysql/my.cnf # 映射数据库配置文件
|
||||
- ./docker/mysql/init_sql:/docker-entrypoint-initdb.d
|
||||
ports:
|
||||
- 13306:3306
|
||||
command: [
|
||||
'--character-set-server=utf8mb4',
|
||||
'--collation-server=utf8mb4_unicode_ci'
|
||||
]
|
||||
|
||||
redis:
|
||||
hostname: redis
|
||||
image: redis:5.0.4
|
||||
container_name: ferry_redis
|
||||
restart: always
|
||||
command: redis-server /etc/redis.conf # 启动redis命令
|
||||
environment:
|
||||
- TZ=Asia/Shanghai
|
||||
volumes:
|
||||
- ./redis/data:/var/lib/redis/data
|
||||
- ./redis/config/redis.conf:/etc/redis.conf
|
||||
ports:
|
||||
- 16379:6379
|
||||
|
||||
ferry:
|
||||
hostname: ferry
|
||||
image: registry.cn-beijing.aliyuncs.com/lanyulei/ferry:v1.0.0
|
||||
container_name: ferry
|
||||
depends_on:
|
||||
- db
|
||||
- redis
|
||||
links:
|
||||
- db:ferry_mysql
|
||||
- redis:ferry_redis
|
||||
ports:
|
||||
- 8002:8002
|
||||
volumes:
|
||||
- ./config:/opt/ferry/config
|
||||
- ./static:/opt/ferry/static
|
||||
- ./template:/opt/ferry/template
|
||||
- ./logs:/opt/ferry/logs
|
||||
environment:
|
||||
- TZ=Asia/Shanghai
|
||||
restart: always
|
||||
command: ./ferry server -c=/opt/ferry/config/settings.yml
|
||||
|
||||
ferry_web:
|
||||
hostname: ferry_web
|
||||
container_name: ferry_web
|
||||
image: registry.cn-beijing.aliyuncs.com/lanyulei/ferry_web:v1.0.0
|
||||
links:
|
||||
- ferry:ferry_host
|
||||
ports:
|
||||
- 8001:8001
|
||||
volumes:
|
||||
- ./docker/nginx/config/nginx.conf:/usr/local/etc/nginx/nginx.conf
|
||||
environment:
|
||||
- TZ=Asia/Shanghai
|
||||
- VUE_APP_BASE_API=http://127.0.0.1:8002
|
||||
- ENV=production
|
||||
restart: always
|
36
docker/mysql/config/my.cnf
Normal file
36
docker/mysql/config/my.cnf
Normal file
@ -0,0 +1,36 @@
|
||||
[client]
|
||||
port = 3306
|
||||
socket = /var/lib/mysql/data/mysql.sock
|
||||
[mysqld]
|
||||
# 针对5.7版本执行group by字句出错问题解决
|
||||
sql_mode='STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION'
|
||||
# 一般配置选项
|
||||
basedir = /var/lib/mysql
|
||||
datadir = /var/lib/mysql/data
|
||||
port = 3306
|
||||
socket = /var/lib/mysql/data/mysql.sock
|
||||
lc-messages-dir = /usr/share/mysql # 务必配置此项,否则执行sql出错时,只能显示错误代码而不显示具体错误消息
|
||||
character-set-server=utf8
|
||||
back_log = 300
|
||||
max_connections = 3000
|
||||
max_connect_errors = 50
|
||||
table_open_cache = 4096
|
||||
max_allowed_packet = 32M
|
||||
#binlog_cache_size = 4M
|
||||
max_heap_table_size = 128M
|
||||
read_rnd_buffer_size = 16M
|
||||
sort_buffer_size = 16M
|
||||
join_buffer_size = 16M
|
||||
thread_cache_size = 16
|
||||
query_cache_size = 64M
|
||||
query_cache_limit = 4M
|
||||
ft_min_word_len = 8
|
||||
thread_stack = 512K
|
||||
transaction_isolation = REPEATABLE-READ
|
||||
tmp_table_size = 64M
|
||||
#log-bin=mysql-bin
|
||||
long_query_time = 6
|
||||
server_id=1
|
||||
innodb_buffer_pool_size = 256M
|
||||
innodb_thread_concurrency = 16
|
||||
innodb_log_buffer_size = 16M
|
1
docker/mysql/init_sql/init.sql
Normal file
1
docker/mysql/init_sql/init.sql
Normal file
@ -0,0 +1 @@
|
||||
create database if not exists ferry;
|
126
docker/nginx/config/nginx.conf
Normal file
126
docker/nginx/config/nginx.conf
Normal file
@ -0,0 +1,126 @@
|
||||
user www www;
|
||||
worker_processes auto;
|
||||
|
||||
error_log /data/wwwlogs/error_nginx.log crit;
|
||||
pid /var/run/nginx.pid;
|
||||
worker_rlimit_nofile 51200;
|
||||
|
||||
events {
|
||||
use epoll;
|
||||
worker_connections 51200;
|
||||
multi_accept on;
|
||||
}
|
||||
|
||||
http {
|
||||
include mime.types;
|
||||
default_type application/octet-stream;
|
||||
server_names_hash_bucket_size 128;
|
||||
client_header_buffer_size 32k;
|
||||
large_client_header_buffers 4 32k;
|
||||
client_max_body_size 1024m;
|
||||
client_body_buffer_size 10m;
|
||||
sendfile on;
|
||||
tcp_nopush on;
|
||||
keepalive_timeout 120;
|
||||
server_tokens off;
|
||||
tcp_nodelay on;
|
||||
|
||||
fastcgi_connect_timeout 300;
|
||||
fastcgi_send_timeout 300;
|
||||
fastcgi_read_timeout 300;
|
||||
fastcgi_buffer_size 64k;
|
||||
fastcgi_buffers 4 64k;
|
||||
fastcgi_busy_buffers_size 128k;
|
||||
fastcgi_temp_file_write_size 128k;
|
||||
fastcgi_intercept_errors on;
|
||||
|
||||
#Gzip Compression
|
||||
gzip on;
|
||||
gzip_buffers 16 8k;
|
||||
gzip_comp_level 6;
|
||||
gzip_http_version 1.1;
|
||||
gzip_min_length 256;
|
||||
gzip_proxied any;
|
||||
gzip_vary on;
|
||||
gzip_types
|
||||
text/xml application/xml application/atom+xml application/rss+xml application/xhtml+xml image/svg+xml
|
||||
text/javascript application/javascript application/x-javascript
|
||||
text/x-json application/json application/x-web-app-manifest+json
|
||||
text/css text/plain text/x-component
|
||||
font/opentype application/x-font-ttf application/vnd.ms-fontobject
|
||||
image/x-icon;
|
||||
gzip_disable "MSIE [1-6]\.(?!.*SV1)";
|
||||
|
||||
proxy_ignore_client_abort on;
|
||||
|
||||
server {
|
||||
listen 8001; # 监听端口
|
||||
# server_name -; # 域名可以有多个,用空格隔开
|
||||
|
||||
#charset koi8-r;
|
||||
|
||||
#access_log logs/host.access.log main;
|
||||
location / {
|
||||
root /opt/web;
|
||||
index index.html index.htm; #目录内的默认打开文件,如果没有匹配到index.html,则搜索index.htm,依次类推
|
||||
}
|
||||
|
||||
#ssl配置省略
|
||||
location /api {
|
||||
# rewrite ^.+api/?(.*)$ /$1 break;
|
||||
proxy_pass http://ferry_host:8002; #node api server 即需要代理的IP地址
|
||||
proxy_redirect off;
|
||||
proxy_set_header Host $host:$server_port;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
}
|
||||
|
||||
# 登陆
|
||||
location /login {
|
||||
proxy_pass http://ferry_host:8002; #node api server 即需要代理的IP地址
|
||||
proxy_redirect off;
|
||||
proxy_ignore_client_abort on;
|
||||
proxy_max_temp_file_size 256m;
|
||||
proxy_connect_timeout 90;
|
||||
proxy_send_timeout 90;
|
||||
proxy_read_timeout 90;
|
||||
proxy_buffer_size 4k;
|
||||
proxy_buffers 4 32k;
|
||||
proxy_busy_buffers_size 32k;
|
||||
proxy_temp_file_write_size 64k;
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Connection "";
|
||||
proxy_set_header Host $host:$server_port;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
}
|
||||
|
||||
# 刷新token
|
||||
location /refresh_token {
|
||||
proxy_pass http://ferry_host:8002; #node api server 即需要代理的IP地址
|
||||
proxy_set_header Host $host:$server_port;
|
||||
}
|
||||
|
||||
# 接口地址
|
||||
location /swagger {
|
||||
proxy_pass http://ferry_host:8002; #node api server 即需要代理的IP地址
|
||||
proxy_set_header Host $host:$server_port;
|
||||
}
|
||||
|
||||
# 后端静态文件路径
|
||||
location /static/uploadfile {
|
||||
proxy_pass http://ferry_host:8002; #node api server 即需要代理的IP地址
|
||||
proxy_set_header Host $host:$server_port;
|
||||
}
|
||||
|
||||
#error_page 404 /404.html; #对错误页面404.html 做了定向配置
|
||||
|
||||
# redirect server error pages to the static page /50x.html
|
||||
#将服务器错误页面重定向到静态页面/50x.html
|
||||
#
|
||||
error_page 500 502 503 504 /50x.html;
|
||||
location = /50x.html {
|
||||
root html;
|
||||
}
|
||||
}
|
||||
}
|
1373
docker/redis/config/redis.conf
Normal file
1373
docker/redis/config/redis.conf
Normal file
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user