FROM centos:centos7
#MAINTAINER 维护者信息
MAINTAINER mth ****@qq.com
# 安装依赖库 这些依赖库主要有g++、gcc、openssl-devel、pcre-devel和zlib-devel
RUN yum -y update
RUN yum -y install make gcc gcc-c++ glibc glibc-devel lsof
RUN yum -y install pcre pcre-devel
RUN yum -y install openssl openssl--devel
RUN yum -y install gcc build-essential
RUN yum -y install wget
#依赖库
RUN yum -y install gcc gcc-c++ autoconf libjpeg libjpeg-devel libpng libpng-develfreetype freetype-devel libxml2 libxml2-devel zlib zlib-devel glibc glibc-develglib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel curl curl-devele2fsprogs e2fsprogs-devel krb5 krb5-devel libidn libidn-devel opensslopenssl-devel openldap openldap-devel nss_ldap openldap-clientsopenldap-servers
#复制本地依赖库
#COPY ./x86_64/* /app/qcdr/src/x86_64/
#安装本地依赖库
#RUN rpm -Uvh /app/qcdr/src/x86_64/make-3.82-24.el7.x86_64.rpm
#RUN rpm -Uvh /app/qcdr/src/x86_64/gcc-4.8.5-44.el7.x86_64.rpm
#RUN rpm -Uvh /app/qcdr/src/x86_64/gcc-c++-4.8.5-44.el7.x86_64.rpm
#RUN rpm -Uvh /app/qcdr/src/x86_64/glibc-2.17-326.el7_9.x86_64.rpm
#RUN rpm -Uvh /app/qcdr/src/x86_64/glibc-devel-2.17-326.el7_9.x86_64.rpm
#RUN rpm -Uvh /app/qcdr/src/x86_64/lsof-4.87-6.el7.x86_64.rpm
#RUN rpm -Uvh /app/qcdr/src/x86_64/pcre-8.32-17.el7.x86_64.rpm
#RUN rpm -Uvh /app/qcdr/src/x86_64/pcre-devel-8.32-17.el7.x86_64.rpm
#RUN rpm -Uvh /app/qcdr/src/x86_64/openssl-1.0.2k-26.el7_9.x86_64.rpm
#RUN rpm -Uvh /app/qcdr/src/x86_64/zlib-1.2.7-21.el7_9.x86_64.rpm
#RUN rpm -Uvh /app/qcdr/src/x86_64/zlib-devel-1.2.7-21.el7_9.x86_64.rpm
#RUN rpm -Uvh /app/qcdr/src/x86_64/lua-devel-5.1.4-15.el7.x86_64.rpm
#新建模块文件路径
RUN mkdir -p /app/qcdr/src
#添加Nginx Module和lua工具
#添加 ngx_devel_kit 模块
ADD ./nginx-modules/v0.3.1.tar.gz /app/qcdr/src/
#添加 lua-nginx-module 模块
ADD ./nginx-modules/v0.10.14.tar.gz /app/qcdr/src/
#添加 headers-more-nginx-module 模块
ADD ./nginx-modules/v0.33.tar.gz /app/qcdr/src/
#添加 ncurses 模块
#ADD ./nginx-modules/ncurses-5.6.tar.gz /app/qcdr/src/
#WORKDIR /app/qcdr/src/ncurses-5.6/
#RUN ./configure -prefix=/app/qcdr/ncurses-5.6 -with-shared -without-debug
#RUN make PREFIX=/app/qcdr/ncurses-5.6
#RUN make install PREFIX=/app/qcdr/ncurses-5.6
#安装 LuaJIT 模块
ADD ./nginx-modules/v2.1-20201229.tar.gz /app/qcdr/src/
WORKDIR /app/qcdr/src/luajit2-2.1-20201229
RUN make PREFIX=/app/qcdr/luajit
RUN make install PREFIX=/app/qcdr/luajit
#配置环境变量
ENV LUAJIT_LIB=/app/qcdr/luajit/lib
ENV LUAJIT_INC=/app/qcdr/luajit/include/luajit-2.1
#RUN export LUAJIT_LIB=/usr/local/luajit/lib
#RUN export LUAJIT_INC=/usr/local/luajit/include/luajit-2.1
#编译安装Nginx
RUN useradd -M -s /sbin/nologin billing
ADD ./nginx-modules/nginx-1.21.1.tar.gz /app/qcdr/src/
WORKDIR /app/qcdr/src/nginx-1.21.1
RUN ./configure --prefix=/app/qcdr/nginx-1.21.1 --user=billing --group=billing \
--error-log-path=/app/qcdr/nginx/logs/error.log \
--http-log-path=/app/qcdr/nginx/logs/access.log \
--pid-path=/app/qcdr/nginx/logs/nginx.pid \
--lock-path=/var/lock/nginx.lock \
--with-ld-opt="-Wl,-rpath,/app/qcdr/luajit/lib" \
--with-http_stub_status_module \
--with-http_sub_module \
--with-file-aio \
--with-http_gzip_static_module \
--with-pcre \
--with-http_realip_module \
--add-module=/app/qcdr/src/lua-nginx-module-0.10.14 \
--add-module=/app/qcdr/src/ngx_devel_kit-0.3.1 \
--add-module=/app/qcdr/src/headers-more-nginx-module-0.33
RUN make PREFIX=/app/qcdr/nginx-1.21.1
RUN make install PREFIX=/app/qcdr/nginx-1.21.1
#参数说明
#--prefix 用于指定nginx编译后的安装目录
#--add-module 为添加的第三方模块,此次添加了fdfs的nginx模块
#--with..._module 表示启用的nginx模块,如此处启用了http_ssl_module模块
#添加服务
ADD smt-bss-querycenter-web.tar /app/qcdr
COPY error.log /app/qcdr/logs/error.log
COPY nginx.conf /app/qcdr/nginx-1.21.1/conf
COPY start.sh /app/qcdr/start.sh
RUN chmod 777 /app && chown -R billing:billing /app && chmod 755 /app/qcdr/start.sh
RUN mkdir -p /app/logs/querycenterweb && chown -R billing:billing /app/logs/querycenterweb
USER billing
WORKDIR /app/qcdr
ENV LANG en_US.UTF-8
ENV TZ Asia/Shanghai
#启动nginx
#RUN /app/qcdr/src/nginx-1.21.1/sbin/nginx -c /app/qcdr/nginx-1.21.1/conf/nginx.conf
#创建软连接
#RUN ln -s /app/qcdr/src/nginx-1.21.1/sbin/* /app/qcdr/sbin/
#CMD ["/app/qcdr/nginx-1.21.1/sbin/nginx -c /app/qcdr/nginx-1.21.1/conf/nginx.conf -p /app/qcdr/nginx-1.21.1","tail -f /app/qcdr/logs/error.log"]
CMD ["/app/qcdr/nginx-1.21.1/sbin/nginx","-g","daemon off;"]