commit
4d42e1357b
3
.gitignore
vendored
3
.gitignore
vendored
@ -8,4 +8,5 @@ tmp/
|
||||
config/settings.dev.yml
|
||||
logs
|
||||
mysql/data
|
||||
redis/data
|
||||
redis/data
|
||||
data/
|
22
Dockerfile
22
Dockerfile
@ -1,12 +1,28 @@
|
||||
FROM golang:1.14
|
||||
FROM golang:1.16 AS build
|
||||
|
||||
WORKDIR /opt/ferry
|
||||
|
||||
COPY . .
|
||||
|
||||
ENV GOPROXY="https://goproxy.cn"
|
||||
ARG GOPROXY="https://goproxy.cn"
|
||||
|
||||
RUN go mod download
|
||||
RUN go build -o ferry .
|
||||
|
||||
EXPOSE 8002
|
||||
|
||||
FROM debian:buster AS prod
|
||||
|
||||
WORKDIR /opt/ferry
|
||||
|
||||
COPY --from=build /opt/ferry/ferry /opt/ferry/
|
||||
COPY config/ /opt/ferry/default_config/
|
||||
COPY template/ /opt/ferry/template/
|
||||
COPY entrypoint.sh /opt/ferry/
|
||||
RUN mkdir -p logs static/uploadfile static/scripts static/template
|
||||
|
||||
RUN chmod 755 /opt/ferry/entrypoint.sh
|
||||
RUN chmod 755 /opt/ferry/ferry
|
||||
|
||||
EXPOSE 8002
|
||||
VOLUME [ "/opt/ferry/config" ]
|
||||
ENTRYPOINT [ "/opt/ferry/entrypoint.sh" ]
|
||||
|
0
config/needinit
Normal file
0
config/needinit
Normal file
@ -5,14 +5,14 @@ settings:
|
||||
domain: localhost:8002
|
||||
host: 0.0.0.0
|
||||
ishttps: false
|
||||
mode: prod
|
||||
mode: dev
|
||||
name: ferry
|
||||
port: 8002
|
||||
port: "8002"
|
||||
readtimeout: 1
|
||||
writertimeout: 2
|
||||
database:
|
||||
dbtype: mysql
|
||||
host: 127.0.0.1
|
||||
host: ferry_mysql
|
||||
name: ferry
|
||||
password: 123456
|
||||
port: 3306
|
||||
@ -52,10 +52,10 @@ settings:
|
||||
maxbackups: 300
|
||||
maxsize: 10240
|
||||
path: ./logs/ferry.log
|
||||
public:
|
||||
islocation: 0
|
||||
redis:
|
||||
url: redis://127.0.0.1:6379
|
||||
url: redis://ferry_redis:6379
|
||||
ssl:
|
||||
key: keystring
|
||||
pem: temp/pem.pem
|
||||
public:
|
||||
isLocation: 0
|
||||
|
@ -3,40 +3,35 @@ services:
|
||||
db:
|
||||
hostname: mysql
|
||||
container_name: ferry_mysql
|
||||
image: mysql:5.7.31
|
||||
restart: always
|
||||
image: mysql:5.7
|
||||
restart: unless-stopped
|
||||
environment:
|
||||
- TZ=Asia/Shanghai
|
||||
- MYSQL_ROOT_PASSWORD=123456
|
||||
- MYSQL_DATABASE=ferry
|
||||
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'
|
||||
]
|
||||
- ./data/mysql/data:/var/lib/mysql # 映射数据库保存目录到宿主机,防止数据丢失
|
||||
command:
|
||||
[
|
||||
"--character-set-server=utf8mb4",
|
||||
"--collation-server=utf8mb4_unicode_ci",
|
||||
]
|
||||
|
||||
redis:
|
||||
hostname: redis
|
||||
image: redis:5.0.4
|
||||
image: redis:6
|
||||
container_name: ferry_redis
|
||||
restart: always
|
||||
command: redis-server /etc/redis.conf # 启动redis命令
|
||||
restart: unless-stopped
|
||||
environment:
|
||||
- TZ=Asia/Shanghai
|
||||
volumes:
|
||||
- ./redis/data:/var/lib/redis/data
|
||||
- ./redis/config/redis.conf:/etc/redis.conf
|
||||
ports:
|
||||
- 16379:6379
|
||||
- ./data/redis/data:/var/lib/redis/data
|
||||
|
||||
ferry:
|
||||
hostname: ferry
|
||||
image: registry.cn-beijing.aliyuncs.com/lanyulei/ferry:v1.0.0-2
|
||||
container_name: ferry
|
||||
ferry_backend:
|
||||
hostname: ferry_backend
|
||||
image: ferry:latest
|
||||
container_name: ferry_backend
|
||||
build: .
|
||||
depends_on:
|
||||
- db
|
||||
- redis
|
||||
@ -46,26 +41,21 @@ services:
|
||||
ports:
|
||||
- 8002:8002
|
||||
volumes:
|
||||
- ./config:/opt/ferry/config
|
||||
- ./static:/opt/ferry/static
|
||||
- ./template:/opt/ferry/template
|
||||
- ./logs:/opt/ferry/logs
|
||||
- ./data/config:/opt/ferry/config
|
||||
- ./data/logs:/opt/ferry/logs
|
||||
environment:
|
||||
- TZ=Asia/Shanghai
|
||||
restart: always
|
||||
command: ./ferry server -c=/opt/ferry/config/settings.yml
|
||||
restart: unless-stopped
|
||||
|
||||
ferry_web:
|
||||
hostname: ferry_web
|
||||
container_name: ferry_web
|
||||
image: registry.cn-beijing.aliyuncs.com/lanyulei/ferry_web:v1.0.0-1
|
||||
image: ferry_web:latest
|
||||
links:
|
||||
- ferry:ferry_host
|
||||
- ferry_backend:ferry_backend
|
||||
ports:
|
||||
- 8001:8001
|
||||
volumes:
|
||||
- ./docker/nginx/config/nginx.conf:/etc/nginx/nginx.conf
|
||||
- ./docker/nginx/entrypoint/docker-entrypoint.sh:/docker-entrypoint.sh
|
||||
environment:
|
||||
- LISTEN_DOMAIN=fdevops.com
|
||||
- TZ=Asia/Shanghai
|
||||
restart: always
|
||||
restart: unless-stopped
|
||||
|
@ -1,36 +0,0 @@
|
||||
[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 +0,0 @@
|
||||
create database if not exists ferry;
|
@ -1,126 +0,0 @@
|
||||
user nginx;
|
||||
worker_processes auto;
|
||||
|
||||
error_log /var/log/nginx/error.log warn;
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,43 +0,0 @@
|
||||
#!/bin/sh
|
||||
# vim:sw=4:ts=4:et
|
||||
|
||||
grep -r -o "http://fdevops.com:8001" /opt/web |awk -F ':' '{print $1}' | xargs sed -i s'#http://fdevops.com:8001#http://192.168.1.1:8001#g'
|
||||
grep -r -o "VUE_APP_BASE_API" /opt/web |awk -F ':' '{print $1}' | xargs sed -i s'#VUE_APP_BASE_API#http://192.168.1.1:8001#g'
|
||||
grep -r -o "localhost" /opt/web/static/web/js |awk -F ':' '{print $1}' | xargs sed -i s'#localhost#192.168.1.1#g'
|
||||
grep -r -o "fdevops.com" /opt/web/static/web/js |awk -F ':' '{print $1}' | xargs sed -i s'#fdevops.com#192.168.1.1#g'
|
||||
|
||||
set -e
|
||||
|
||||
if [ -z "${NGINX_ENTRYPOINT_QUIET_LOGS:-}" ]; then
|
||||
exec 3>&1
|
||||
else
|
||||
exec 3>/dev/null
|
||||
fi
|
||||
|
||||
if [ "$1" = "nginx" -o "$1" = "nginx-debug" ]; then
|
||||
if /usr/bin/find "/docker-entrypoint.d/" -mindepth 1 -maxdepth 1 -type f -print -quit 2>/dev/null | read v; then
|
||||
echo >&3 "$0: /docker-entrypoint.d/ is not empty, will attempt to perform configuration"
|
||||
|
||||
echo >&3 "$0: Looking for shell scripts in /docker-entrypoint.d/"
|
||||
find "/docker-entrypoint.d/" -follow -type f -print | sort -n | while read -r f; do
|
||||
case "$f" in
|
||||
*.sh)
|
||||
if [ -x "$f" ]; then
|
||||
echo >&3 "$0: Launching $f";
|
||||
"$f"
|
||||
else
|
||||
# warn on shell scripts without exec bit
|
||||
echo >&3 "$0: Ignoring $f, not executable";
|
||||
fi
|
||||
;;
|
||||
*) echo >&3 "$0: Ignoring $f";;
|
||||
esac
|
||||
done
|
||||
|
||||
echo >&3 "$0: Configuration complete; ready for start up"
|
||||
else
|
||||
echo >&3 "$0: No files found in /docker-entrypoint.d/, skipping configuration"
|
||||
fi
|
||||
fi
|
||||
|
||||
exec "$@"
|
File diff suppressed because it is too large
Load Diff
12
entrypoint.sh
Executable file
12
entrypoint.sh
Executable file
@ -0,0 +1,12 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
if [[ ! -f /opt/ferry/config/settings.yml ]]
|
||||
then
|
||||
cp /opt/ferry/default_config/* /opt/ferry/config/
|
||||
fi
|
||||
if [[ -f /opt/ferry/config/needinit ]]
|
||||
then
|
||||
/opt/ferry/ferry init -c=/opt/ferry/config/settings.yml
|
||||
rm -f /opt/ferry/config/needinit
|
||||
fi
|
||||
/opt/ferry/ferry server -c=/opt/ferry/config/settings.yml
|
Loading…
x
Reference in New Issue
Block a user