docker构建centos7+openssl 1.1.1+python3.10+nginx镜像以及mysql+redis+myscan_web代码工程部署

前言:毕业设计中的docker部分,dockerfile部分编写centos7+openssl 1.1.1+python3.10基础镜像作为笔记

参考文章:https://blog.csdn.net/qq_39715000/article/details/125009276 openssl

openssl:http://www.openssl.org/source/openssl-1.1.1q.tar.gz

python3.10.6:https://registry.npmmirror.com/binary.html?path=python/3.10.6/

dockerfile编写

build镜像:docker build -t my:v1 .

FROM centos:7

RUN mkdir /usr/local/python3 /home/data /app

COPY .  /home/data

RUN set -ex \
    && yum -y install python3-devel zlib-devel bzip2-devel libffi-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gcc make wget gcc-c++ perl zip unzip deltarpm --nogpgcheck \
    && yum clean all \
    && cd /home/data \
    && tar -zxvf openssl-1.1.1.tar.gz \
    && cd openssl-1.1.1 \
    && ./config shared --openssldir=/usr/local/openssl --prefix=/usr/local/openssl \
    && make && make install \
    && echo "/usr/local/lib64/" >> /etc/ld.so.conf \
    && echo "/usr/local/openssl/lib" >> /etc/ld.so.conf \
    && ldconfig \
    && ln -s /usr/local/openssl/bin/openssl /usr/bin/openssl \
    && ln -s /usr/local/openssl/include/openssl /usr/include/openssl \
    && cd .. \
    && tar -xvJf  Python-3.10.6.tar.xz \
    && cd Python-3.10.6 \
    && ./configure --prefix=/usr/local/python3 --with-openssl=/usr/local/openssl --enable-shared \
    && make && make install \
    && echo "/usr/local/python3/lib" >> /etc/ld.so.conf \
    && ldconfig \
    && cd .. \
	&& yum install -y epel-release \
    && yum install -y python-pip \
	&& rm -f /usr/bin/python \
	&& rm -f /usr/bin/pip \
	&& ln -s /usr/local/python3/bin/python3 /usr/bin/python \
	&& ln -s /usr/local/python3/bin/pip3 /usr/bin/pip \
    && sed -i "s#/usr/bin/python#/usr/bin/python2.7#" /usr/bin/yum \
    && sed -i "s#/usr/bin/python#/usr/bin/python2.7#" /usr/libexec/urlgrabber-ext-down \
	&& python -V \
	&& python -m pip install -i https://pypi.tuna.tsinghua.edu.cn/simple --upgrade pip \
	&& pip list \
	&& echo "build success - zpchcbd"

结果如下图所示

docker images 镜像构建build结果如下图所示

docker run -itd my:v1 测试导入ssl模块,openssl正常,如下图所示

docker-compose

version: '3.7'

volumes:
  myscan_db:
    external: true

services:
  web:
    image: zpchcbd/myscan_web:v3
    container_name: myscan_web
    restart: unless-stopped
    tty: true
    ports:
      - 7878:80
    depends_on:
      - mysql
      - redis
    volumes:
      - ./:/app/
    working_dir: /app/
    entrypoint: ["./run_web.sh"]
    environment:
      - LANG=en_US.UTF-8
      - TZ=Asia/Shanghai

  celery:
    image: zpchcbd/myscan_web:v3
    container_name: myscan_celery
    restart: unless-stopped
    tty: true
    depends_on:
      - mysql
      - redis
    volumes:
      - ./:/app/
    working_dir: /app/
    entrypoint: ["./run_celery.sh"]
    environment:
      - LANG=en_US.UTF-8
      - TZ=Asia/Shanghai

  redis:
    image: redis:6.2.7
    container_name: myscan_redis
    restart: always
    environment:
      - LANG=en_US.UTF-8
      - TZ=Asia/Shanghai

  mysql:
    image: mysql:5.7.40
    container_name: myscan_mysql
    restart: always
    environment:
      MYSQL_DATABASE: myscan
      MYSQL_ROOT_PASSWORD: root
    volumes:
      - myscan_db:/var/lib/mysql
posted @ 2023-01-03 14:15  zpchcbd  阅读(892)  评论(1编辑  收藏  举报