refactor: 去掉 top 顶层目录,镜像与部署编排直接放在仓库根下
This commit is contained in:
@@ -0,0 +1,56 @@
|
||||
FROM registry.cn-shanghai.aliyuncs.com/odboy/kenaito:alinux3-update20261111
|
||||
LABEL MAINTAINER="tianjun@odboy.cn"
|
||||
ENV TimeZone=Asia/Shanghai
|
||||
ENV TENGINE_VERSION=3.1.0
|
||||
ENV NGINX_HOME=/usr/local/nginx
|
||||
ENV PATH="${NGINX_HOME}/sbin:$PATH"
|
||||
WORKDIR /home/admin
|
||||
# 使用自定义配置覆盖默认可映射的目录:conf/nginx.conf、conf/conf.d、conf/ssl
|
||||
COPY nginx.conf ${NGINX_HOME}/conf/nginx.conf
|
||||
# https://tengine.taobao.org/download/tengine-3.1.0.tar.gz
|
||||
ADD https://tengine.taobao.org/download/tengine-${TENGINE_VERSION}.tar.gz ./
|
||||
RUN yum install \
|
||||
gcc \
|
||||
gcc-c++ \
|
||||
make \
|
||||
tar \
|
||||
pcre-devel \
|
||||
zlib-devel \
|
||||
openssl-devel \
|
||||
libxml2-devel \
|
||||
libxslt-devel \
|
||||
gd-devel \
|
||||
geoip-devel \
|
||||
sysstat \
|
||||
net-tools -y; \
|
||||
tar -xzvf tengine-${TENGINE_VERSION}.tar.gz; \
|
||||
cd tengine-${TENGINE_VERSION}; \
|
||||
./configure \
|
||||
--prefix=${NGINX_HOME} \
|
||||
--with-http_stub_status_module \
|
||||
--with-http_ssl_module \
|
||||
--with-http_v2_module \
|
||||
--with-http_realip_module \
|
||||
--with-http_gzip_static_module \
|
||||
--with-http_sub_module \
|
||||
--with-http_dav_module \
|
||||
--with-http_secure_link_module \
|
||||
--with-http_slice_module \
|
||||
--with-http_geoip_module \
|
||||
--with-http_xslt_module \
|
||||
--with-http_image_filter_module \
|
||||
--with-stream \
|
||||
--with-stream_ssl_module \
|
||||
--with-stream_realip_module \
|
||||
--with-pcre-jit; \
|
||||
make; \
|
||||
make install; \
|
||||
mkdir -p ${NGINX_HOME}/conf/ssl ${NGINX_HOME}/conf/conf.d; \
|
||||
ls -l ${NGINX_HOME}/sbin; \
|
||||
${NGINX_HOME}/sbin/nginx -t -c ${NGINX_HOME}/conf/nginx.conf; \
|
||||
rm -rf /home/admin/tengine-${TENGINE_VERSION} /home/admin/tengine-${TENGINE_VERSION}.tar.gz
|
||||
|
||||
# tengine 默认以 nobody 用户运行 worker 进程,root 启动后自动降权,可直接监听 80/443
|
||||
EXPOSE 80 443
|
||||
STOPSIGNAL SIGQUIT
|
||||
CMD ["/usr/local/nginx/sbin/nginx", "-g", "daemon off;"]
|
||||
Executable
+3
@@ -0,0 +1,3 @@
|
||||
IMAGE=registry.cn-shanghai.aliyuncs.com/odboy/kenaito:proxy-tengine3
|
||||
docker build -t "${IMAGE}" .
|
||||
docker push "${IMAGE}"
|
||||
@@ -0,0 +1,63 @@
|
||||
user root;
|
||||
# 按 CPU 核数设置,超过 8 个收益很小;需要时可直接改成具体数字,如 4
|
||||
worker_processes auto;
|
||||
# 每个 worker 打开的文件描述符上限,为高并发场景预留
|
||||
worker_rlimit_nofile 65535;
|
||||
|
||||
# 错误日志级别 warn,避免大量冗余 info 日志;容器内输出到 stderr 方便收集
|
||||
error_log stderr warn;
|
||||
|
||||
events {
|
||||
# 高并发场景用 epoll;worker_connections 与 worker_processes 相乘即最大并发连接数
|
||||
use epoll;
|
||||
worker_connections 10240;
|
||||
multi_accept on;
|
||||
}
|
||||
|
||||
http {
|
||||
include mime.types;
|
||||
default_type application/octet-stream;
|
||||
|
||||
log_format main '"$http_x_forwarded_for" $remote_addr - $remote_user [$time_local] "$request" '
|
||||
'$status $body_bytes_sent "$http_referer" '
|
||||
'"$http_user_agent" "$http_x_forwarded_for" "$upstream_addr"';
|
||||
|
||||
# 容器环境下日志输出到 stdout/stderr,交给 docker 日志驱动统一处理
|
||||
access_log /dev/stdout main;
|
||||
|
||||
# 只为低版本浏览器不支持的格式做 gzip,现代浏览器直接用 gzip_static 提供的 .gz 文件
|
||||
gzip on;
|
||||
gzip_vary on;
|
||||
gzip_comp_level 5;
|
||||
gzip_min_length 1k;
|
||||
gzip_proxied any;
|
||||
gzip_types text/plain text/css text/xml application/json application/javascript
|
||||
application/rss+xml application/atom+xml image/svg+xml;
|
||||
|
||||
sendfile on;
|
||||
tcp_nopush on;
|
||||
tcp_nodelay on;
|
||||
keepalive_timeout 65;
|
||||
# 客户端请求头/请求体超时,防止慢连接长期占用 worker
|
||||
client_header_timeout 15s;
|
||||
client_body_timeout 15s;
|
||||
send_timeout 15s;
|
||||
|
||||
# 调优: 32的倍数
|
||||
server_names_hash_max_size 1024;
|
||||
server_names_hash_bucket_size 128;
|
||||
proxy_headers_hash_max_size 51200;
|
||||
proxy_headers_hash_bucket_size 6400;
|
||||
|
||||
client_max_body_size 1200m;
|
||||
# 大文件上传时先把请求体落到磁盘,避免占用内存
|
||||
client_body_buffer_size 128k;
|
||||
|
||||
# 文件缓存,减少磁盘 stat 次数;大小可视容器内打开文件数调整
|
||||
open_file_cache max=10000 inactive=30s;
|
||||
open_file_cache_valid 60s;
|
||||
open_file_cache_min_uses 2;
|
||||
open_file_cache_errors on;
|
||||
|
||||
include /usr/local/nginx/conf/conf.d/*.conf;
|
||||
}
|
||||
Reference in New Issue
Block a user