内容简介:但openresty官方没有发布docker相关东西,所以以:结合openresty安装、参考官方声明依赖:perl 5.6.1+, libpcre, libssl
前言
为什么要使用openresty?
官方说 明:OpenResty® 是一个基于 Nginx 与 Lua 的高性能 Web 平台,其内部集成了大量精良的 Lua 库、第三方模块以及大多数的依赖项。所以。
但openresty官方没有发布 docker 相关东西,所以以:结合openresty安装、参考 docker-nginx官方 的为原则编写。
1.依赖安装测试
官方声明依赖:perl 5.6.1+, libpcre, libssl
a.按nginx的alpine3.9测试
# perl查找 / # apk search perl5 perl-5.26.3-r0 #就一个可选 / # apk search libpcre libpcre2-32-10.32-r1 #貌似最新版本了,32位的? pcre-dev-8.42-r1 libpcre2-16-10.32-r1 pcre2-dev-10.32-r1 libpcre16-8.42-r1 libpcre32-8.42-r1 pcre2-10.32-r1 pcre-8.42-r1 libpcrecpp-8.42-r1 / # apk search libssl openssl-dev-1.1.1b-r1 libressl-dev-2.7.5-r0 #看起来最合适 nss-3.41-r0 libssl1.1-1.1.1b-r1 dovecot-2.3.6-r0 libressl2.7-libssl-2.7.5-r0 / # apk add perl-5.26.3-r0 libpcre2-32-10.32-r1 libressl-dev-2.7.5-r0 # 完全报错,这个alpine依赖搞不了,官方https://pkgs.alpinelinux.org/包的搜索页捉襟见肘,不得不放弃“小而美”。
b.容器测试
参考官方选则debian,github上构建平台镜像的许多镜像选择stretch-slim精简版的,看下大小最新的只有55.3M,比较满意。
环境安装测试:
[]:~/tmp/dk/openresty# docker run -itd --name df -v /root/tmp/dk/openresty:/tmp/host debian:stretch-slim []:~/tmp/dk/openresty# docker exec df -it /bin/bash
初始安装清华源,切换百度源(云本机),apt-get update超慢,后回归官源,后期卡死用网易源。
问题:
1、./configure: error: ngx_postgres addon was unable to detect version of the libpq library.
apt-get libpq-dev -y
2、./configure: error: the HTTP gzip module requires the zlib library.
apt-get install openssl libssl-dev libperl-dev -y apt-get install zlib1g-dev -y
到此OK。
c.第一步通过的代码
FROM debian:stretch-slim #MAINTAINER 维护者信息 MAINTAINER cffycls@foxmail.com ENV RESOURCE "\ deb http://mirrors.163.com/debian/ stretch main non-free contrib \n\ deb http://mirrors.163.com/debian/ stretch-updates main non-free contrib \n\ deb http://mirrors.163.com/debian/ stretch-backports main non-free contrib \n\ deb-src http://mirrors.163.com/debian/ stretch main non-free contrib \n\ deb-src http://mirrors.163.com/debian/ stretch-updates main non-free contrib \n\ deb-src http://mirrors.163.com/debian/ stretch-backports main non-free contrib \n\ deb http://mirrors.163.com/debian-security/ stretch/updates main non-free contrib \n\ deb-src http://mirrors.163.com/debian-security/ stretch/updates main non-free contrib \ " ENV VERSION 1.15.8.1 # !!!注意字符串变量、转义自动解析 RUN echo $RESOURCE > /etc/apt/sources.list && cat /etc/apt/sources.list \ && apt-get update \ && apt-get install libpcre3-dev libssl-dev perl make build-essential curl \ -y COPY openresty-$VERSION.tar.gz /tmp/openresty.tar.gz RUN groupadd -r openresty && useradd -r -g openresty openresty \ # && curl \ && mkdir -p /usr/src && cd /usr/src && mv /tmp/openresty.tar.gz ./ \ && tar -zxf openresty.tar.gz --strip-components 1 \ && ./configure \ --prefix=/usrl/ocal/openresty \ --with-luajit \ --without-http_redis2_module \ --with-http_iconv_module \ --with-http_postgres_module \ \ && make -j "$(nproc)" \ && make install \ && rm -rf /usr/src # COPY nginx.conf /etc/nginx/nginx.conf # COPY nginx.vh.default.conf /etc/nginx/conf.d/default.conf # COPY vhost.conf /etc/nginx/conf.d/vhost.conf VOLUME ["/etc/nginx","/var/www/html"] EXPOSE 80 STOPSIGNAL SIGTERM # CMD ["nginx", "-g", "daemon off;"] #注意官方提示
2.运行测试
准备配置数据(之前旧配置),注意 html和nginx文件夹 的参数共享:
[]:~/tmp/dk/openresty# tree ./ ./ ├── config │ ├── conf.d │ │ └── nginx.vh.default.conf │ │ └── vhost.conf │ └── nginx.conf └── html
a.测试启动
测试容器df(手动搭建,系统无法ps),运行正常:
root@df08a646aaa0:/# nginx nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use) nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
但Dockerfile所建镜像的容器启动关闭无日志,更换openresty官方配置:
[]:~/tmp/dk/openresty# docker run -itd --name n1 -v /root/tmp/dk/openresty/config:/etc/nginx \ -v /root/tmp/dk/openresty/html:/var/www/html cffycls/openresty:0.9 \ /usrl/ocal/openresty/nginx/sbin/nginx #无法启动,容器运行终止,无日志。应该是配置文件问题
b.修改配置文件
使用官方原包未修改:
# 官包解压路径:./bundle/nginx-1.15.8/conf/nginx.conf []:~/tmp/dk/openresty# tree conf conf ├── fastcgi.conf ├── fastcgi_params ├── koi-utf ├── koi-win ├── mime.types ├── nginx.conf ├── scgi_params ├── uwsgi_params └── win-utf
去掉run加的命令,加上端口,运行Up了。
c.运行测试
CMD ["/usrl/ocal/openresty/nginx/sbin/nginx", "-g", "daemon off;"] []:~/tmp/dk/openresty# docker run -itd --name n1 -p 80:80 \ -v /root/tmp/dk/openresty/conf:/usrl/ocal/openresty/nginx/conf \ -v /root/tmp/dk/openresty/html:/usrl/ocal/openresty/nginx/html \ openresty/openresty:1.0
运行成功,大小357M,太大了感觉,提交到云端。
3.启动官方镜像
提交到云端,偶然想搜索下有没有,docker-hub竟然(反问)有官方镜像,pull了个下来,144M还不错。真是重复造轮子了!!!
折腾半天,算是个教训了,算是测得到了运行方法,结果也还行。
[]:~/tmp/dk/openresty# docker run -itd --name n1 -p 80:80 \ -v /root/tmp/dk/openresty/conf:/usrl/local/openresty/nginx/conf \ -v /root/tmp/dk/openresty/html:/usr/local/openresty/nginx/html \ openresty/openresty
访问web端正常
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持 码农网
猜你喜欢:- 漏洞管理的定义与最佳实践
- 聊聊Dubbo(七):自定义Filter实践
- 2018云原生技术实践峰会(CNBPS) 重新定义云原生
- Swoole dispatch_func 自定义分配worker 进程踩坑实践
- Android 自定义 View (04自定义属性)
- Vue自定义组件(简单实现一个自定义组件)
本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们。
Don't Make Me Think
Steve Krug / New Riders Press / 18 August, 2005 / $35.00
Five years and more than 100,000 copies after it was first published, it's hard to imagine anyone working in Web design who hasn't read Steve Krug's "instant classic" on Web usability, but people are ......一起来看看 《Don't Make Me Think》 这本书的介绍吧!