Dockerfile部署openresty

FROM centos:centos7
MAINTAINER chen
ENV VERSION=1.19.9.1
# 配置阿里yum源
RUN cd /etc/yum.repos.d/ && yum install -y wget  && wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
#基础依赖
RUN yum install -y pcre-devel openssl-devel gcc postgresql-devel perl make
#RUN useradd nginx -s /sbin/nologin

#安装openresty
RUN wget https://openresty.org/download/openresty-${VERSION}.tar.gz && \
    mv openresty-${VERSION}.tar.gz /usr/local  &&  \
    tar -xzvf  /usr/local/openresty-${VERSION}.tar.gz -C /usr/local/ && cd /usr/local/openresty-${VERSION} &&  \
    ./configure --prefix=/usr/local/openresty \
	--sbin-path=/usr/local/openresty/nginx/sbin/nginx \
	--conf-path=/usr/local/openresty/nginx/conf/nginx.conf \
	--pid-path=/usr/local/openresty/nginx/run/nginx.pid \
	--error-log-path=/usr/local/openresty/nginx/logs/error.log \
	--http-log-path=/usr/local/openresty/nginx/logs/access.log \
	--user=nginx \
	--group=nginx \
	--with-pcre \
	--with-stream \
	--with-threads \
	--with-file-aio \
	--with-http_v2_module \
	--with-http_ssl_module \
	--with-http_realip_module \
	--with-http_gzip_static_module \
	--with-http_stub_status_module && cd /usr/local/openresty-${VERSION} && \
	make && make install


ENV PATH=$PATH:/usr/local/openresty/bin
WORKDIR /usr/local/openresty
EXPOSE 80 443
CMD ["/usr/local/openresty/bin/openresty", "-g", "daemon off;"]


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Docker是一种容器化技术,可以将应用程序及其依赖项打包成一个独立的可移植容器。OpenResty是一个基于Nginx的Web应用服务器,它集成了Lua脚本语言,可以通过编写Lua脚本来扩展Nginx的功能。 要在Docker中部署OpenResty,可以按照以下步骤进行操作: 1. 首先,你需要安装Docker。你可以根据你的操作系统选择合适的安装方式,并确保Docker已经成功安装并运行。 2. 创建一个Dockerfile,用于构建OpenResty的镜像。在Dockerfile中,你可以指定基础镜像、安装OpenResty及其依赖项、配置Nginx等。以下是一个简单的示例: ``` # 使用官方提供的OpenResty基础镜像 FROM openresty/openresty:latest # 安装其他依赖项 RUN apt-get update && apt-get install -y \ # 安装其他需要的软件包 # 复制配置文件到容器中 COPY nginx.conf /usr/local/openresty/nginx/conf/nginx.conf # 暴露端口 EXPOSE 80 # 启动Nginx服务 CMD ["/usr/local/openresty/bin/openresty", "-g", "daemon off;"] ``` 3. 创建一个nginx.conf文件,用于配置Nginx。你可以根据你的需求进行配置,例如设置监听端口、定义虚拟主机等。 4. 构建镜像。在Dockerfile所在的目录下执行以下命令来构建镜像: ``` docker build -t my-openresty . ``` 其中,`my-openresty`是你给镜像起的名称,可以根据需要进行修改。 5. 运行容器。执行以下命令来运行容器: ``` docker run -d -p 80:80 my-openresty ``` 其中,`my-openresty`是你之前构建的镜像名称。 现在,你已经成功在Docker中部署OpenResty。你可以通过访问`http://localhost`来验证OpenResty是否正常工作。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值