feat: 添加docker-compost

This commit is contained in:
Mr. Lan 2020-11-12 01:29:46 +08:00
parent 3f3db768e7
commit 5785a609b4
3 changed files with 163 additions and 24 deletions

View File

@ -1,7 +1,5 @@
FROM golang:1.14
MAINTAINER lanyulei "fdevops@163.com"
WORKDIR /opt/ferry
COPY . .

View File

@ -1,26 +1,5 @@
version: "3"
services:
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
db:
hostname: mysql
container_name: ferry_mysql
@ -52,4 +31,40 @@ services:
- ./redis/data:/var/lib/redis/data
- ./redis/config/redis.conf:/etc/redis.conf
ports:
- 16379:6379
- 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
restart: always

View 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;
}
}
}