dockerfile.centos

```language FROM centos:7.9.2009 # MAINTAINER维护者信息 maintainer 615973808@qq.com ENV TZ "Asia/Shanghai" ENV wkdir /home/wwww # GCC编译器 RUN yum install gcc -y # Python依赖 RUN yum install -y zlib zlib-devel bzip2 bzip2-devel ncurses ncurses-devel readline readline-devel openssl openssl-devel # wget RUN yum install wget -y # git RUN yum install git -y RUN git config --global user.name "oslock" RUN git config --global user.email "615973808@qq.com" # 指定工作目录 WORKDIR /opt/nginx RUN wget http://nginx.org/download/nginx-1.24.0.tar.gz RUN tar -zxvf nginx-1.24.0.tar.gz # 编译安装nginx RUN set -ex \ && yum install -y gcc make pcre-devel zlib-devel zlib openssl patch openssl-devel\ # 进入nginx目录进行编译安装 && cd /opt/nginx/nginx-1.24.0/ \ # 下载安装补丁 && git clone https://gitee.com/sunlge/ngx_http_proxy_connect_module.git \ && patch -p1 < /opt/nginx/nginx-1.24.0/ngx_http_proxy_connect_module/patch/proxy_connect_rewrite_102101.patch \ # 指定shell环境,否则nginx编译会报错 && bash /opt/nginx/nginx-1.24.0/configure --prefix=/opt/nginx \ --with-http_flv_module \ --with-http_ssl_module \ --with-http_gzip_static_module \ --with-http_stub_status_module \ --with-http_realip_module \ --with-http_v2_module \ --with-stream \ --with-stream_ssl_module \ --with-stream_ssl_preread_module \ --with-stream_ssl_preread_module \ --with-threads \ --add-module=/opt/nginx/nginx-1.24.0/ngx_http_proxy_connect_module \ && make && make install \ && ln -sv /opt/nginx/sbin/nginx /usr/local/sbin/ \ && rm -rf /opt/nginx/nginx-1.24.0 #目录 RUN mkdir -p $wkdir/ WORKDIR $wkdir/ #SQLite升级 # RUN wget https://www.sqlite.org/2024/sqlite-autoconf-3450300.tar.gz --no-check-certificate COPY sqlite-autoconf-3450300.tar.gz $wkdir/sqlite-autoconf-3450300.tar.gz RUN tar -zxvf sqlite-autoconf-3450300.tar.gz WORKDIR $wkdir/sqlite-autoconf-3450300 RUN ./configure RUN make && make install ENV LD_LIBRARY_PATH="/usr/local/lib" # openssl升级 WORKDIR $wkdir/ RUN yum -y install perl-I* COPY openssl-1.1.1w.tar.gz $wkdir/openssl-1.1.1w.tar.gz RUN tar -zxvf openssl-1.1.1w.tar.gz WORKDIR $wkdir/openssl-1.1.1w RUN ./config --prefix=/usr/local/openssl1.1.1 shared zlib RUN make && make install RUN mv /usr/bin/openssl /usr/bin/openssl.bak RUN ln -s /usr/local/openssl1.1.1/bin/openssl /usr/bin/openssl RUN ln -s /usr/local/openssl1.1.1/include/openssl/ /usr/include/openssl WORKDIR /usr/local/openssl1.1.1/ RUN echo "/usr/local/openssl1.1.1/lib" >> /etc/ld.so.conf RUN export LD_LIBRARY_PATH=/usr/local/openssl1.1.1/lib:$LD_LIBRARY_PATH RUN ldconfig -v | grep -i "libssl" RUN openssl version #Python3.10环境 WORKDIR $wkdir/ # RUN wget https://www.python.org/ftp/python/3.10.12/Python-3.10.12.tgz COPY Python-3.10.12.tar.xz $wkdir/Python-3.10.12.tar.xz RUN tar -xvJf Python-3.10.12.tar.xz WORKDIR $wkdir/Python-3.10.12/ RUN ./configure --prefix=/usr/local/python3.10 \ --with-openssl=/usr/local/openssl1.1.1 RUN make && make install RUN ln -s /usr/local/python3.10/bin/python3.10 /usr/bin/python3 RUN ln -s /usr/local/python3.10/bin/pip3.10 /usr/bin/pip3 RUN pip3 config set global.index-url https://mirrors.aliyun.com/pypi/simple/ # git拉代码 WORKDIR $wkdir/ RUN git clone https://gitee.com/wupeiqi/blog.git WORKDIR $wkdir/blog/ RUN pip3 install -r requirements.txt #虚拟环境 RUN pip3 install virtualenv RUN ln -s /usr/local/python3.10/bin/virtualenv /usr/bin/virtualenv RUN virtualenv /envs/dj --python=python3 RUN /envs/dj/bin/pip3 install django==3.2 # 运行项目 WORKDIR $wkdir/blog/ CMD ["/envs/dj/bin/python3", "manage.py", "runserver", "0.0.0.0:9000"] ```