webman和php8.3的Dockerfile,支持event扩展

Dockerfile如下:

# 使用 PHP 官方镜像作为基础镜像
FROM php:latest

# 设置环境变量,避免交互式安装提示
ENV DEBIAN_FRONTEND=noninteractive

# 如果 /etc/apt/sources.list 文件不存在,则创建它,并替换为阿里云源
RUN if [ ! -f /etc/apt/sources.list ]; then \
        echo "deb http://mirrors.aliyun.com/debian bullseye main contrib non-free" > /etc/apt/sources.list && \
        echo "deb-src http://mirrors.aliyun.com/debian bullseye main contrib non-free" >> /etc/apt/sources.list && \
        echo "deb http://mirrors.aliyun.com/debian-security bullseye-security main contrib non-free" >> /etc/apt/sources.list && \
        echo "deb-src http://mirrors.aliyun.com/debian-security bullseye-security main contrib non-free" >> /etc/apt/sources.list && \
        echo "deb http://mirrors.aliyun.com/debian bullseye-updates main contrib non-free" >> /etc/apt/sources.list && \
        echo "deb-src http://mirrors.aliyun.com/debian bullseye-updates main contrib non-free" >> /etc/apt/sources.list; \
    fi

# 强制更新 apt 并设置缓存选项,加快访问速度
RUN apt-get clean && apt-get update && \
    apt-get install -y --no-install-recommends \
    software-properties-common \
    gnupg2 \
    ca-certificates \
    lsb-release \
    apt-transport-https

RUN touch /etc/apt/sources.list.d/php-ondrej.list && \
    echo 'deb http://ppa.launchpad.net/ondrej/php/ubuntu focal main' > /etc/apt/sources.list.d/php-ondrej.list && \
    echo 'deb-src http://ppa.launchpad.net/ondrej/php/ubuntu focal main' >> /etc/apt/sources.list.d/php-ondrej.list && \
    apt-key adv --keyserver keyserver.ubuntu.com --recv-keys E5267A6C && \
    apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 71DAEAAB4AD4CAB6

# 安装系统依赖和 PHP 扩展
RUN apt-get update && \
    apt-get install -y --no-install-recommends \
    libpng-dev \
    libjpeg-dev \
    libfreetype6-dev \
    libxml2-dev \
    libevent-dev \
    openssl \
    libssl-dev \
    pkg-config \
    libcurl4-openssl-dev \
    git \
    unzip &&\
    docker-php-ext-configure gd --with-freetype --with-jpeg && \
    docker-php-ext-install gd pdo pdo_mysql pcntl sockets && \
    docker-php-ext-enable gd pdo pdo_mysql pcntl sockets && \
    apt-get clean && \
    rm -rf /var/lib/apt/lists/*

# 有时候下载会超时,所以把这个文件下载到本地安装,具体可查看gitee地址
COPY ./redis-6.0.2.tgz /tmp/redis-6.0.2.tgz
COPY ./event-3.1.4.tgz /tmp/event-3.1.4.tgz
RUN pecl install /tmp/redis-6.0.2.tgz && pecl install /tmp/event-3.1.4.tgz && docker-php-ext-enable redis

# 设置工作目录
WORKDIR /var/www

# 暴露端口
EXPOSE 8787

# 启动命令
CMD ["php", "/var/www/start.php", "start"]

docker-compose.yml如下:

services:
  nginx:
    restart: on-failure
    image: nginx:latest
    container_name: nginx_admin
    environment:
      - TZ=${TZ}
    volumes:
      - ./docker/nginx/conf.d/:/etc/nginx/conf.d/:ro
      - ./docker/nginx/nginx.conf:/etc/nginx/nginx.conf:ro
      - ./docker/nginx/log/:/var/log/nginx/:rw
      - ./docker/nginx/www/dist:/usr/share/nginx/html/dist:rw
      - ./docker/zoneinfo/localtime:/etc/localtime
    ports:
      - '8090:80'
    networks:
      - webman_net
  webman:
    restart: on-failure
    build:
      context: ./docker/webman
      dockerfile: Dockerfile
    container_name: webman
    environment:
      - TZ=${TZ}
      - PHP_MEMORY_LIMIT=${PHP_MEMORY_LIMIT}
    depends_on:
      - mysql
      - redis
    volumes:
      - ./:/var/www:rw
      - ./docker/webman/event.ini:/usr/local/etc/php/conf.d/event.ini:rw
      - ./docker/zoneinfo/localtime:/etc/localtime
    networks:
      - webman_net
    command: php -d memory_limit=${PHP_MEMORY_LIMIT} /var/www/start.php start
    ports:
      - '8090:8787'
  redis:
    restart: on-failure
    image: redis:latest
    container_name: redis_admin
    environment:
      - TZ=${TZ}
    volumes:
      - ./docker/redis/redis.conf:/etc/redis/redis.conf:ro
      - ./docker/redis/data:/data
      - ./docker/redis/log:/var/log/rfedis
      - ./docker/zoneinfo/localtime:/etc/localtime
    command: redis-server /etc/redis/redis.conf --appendonly yes
    ports:
      - '6379:6379'
    privileged: true
    networks:
      - webman_net
  mysql:
    restart: on-failure
    image: mysql:latest
    container_name: mysql_admin
    ports:
      - '3306:3306'
    volumes:
      - ./docker/mysql/data:/var/lib/mysql
      - ./docker/mysql/conf/my.cnf:/etc/mysql/my.cnf
      - ./docker/mysql/log:/var/log:rw
      - ./docker/zoneinfo/localtime:/etc/localtime
    command:
      [
        'mysqld',
        '--innodb-buffer-pool-size=80M',
        '--character-set-server=utf8mb4',
        '--collation-server=utf8mb4_unicode_ci',
        '--default-time-zone=+8:00',
      ]
    environment:
      - MYSQL_ROOT_PASSWORD=${MYSQL_ROOT_PASSWORD}
      - TZ=${TZ}
    privileged: true
    networks:
      - webman_net
  # phpmyadmin:
  #   restart: unless-stopped
  #   image: phpmyadmin:latest
  #   container_name: phpmyadmin_admin
  #   volumes:
  #     - ./docker/phpmyadmin/tmp:/var/tmp:rw
  #   environment:
  #     - PMA_HOST=${PMA_HOST}
  #     - PMA_PASSWORD=${PMA_PASSWORD}
  #     - PMA_UPLOADDIR=${PMA_UPLOADDIR}
  #     - UPLOAD_LIMIT=${UPLOAD_LIMIT}
  #   ports:
  #     - '9000:80'
  #   networks:
  #     - webman_net
networks:
  webman_net:
    driver: bridge

这是docker-compose.yml的全部配置,各位自己下载参考
https://gitee.com/iorange_636/webman_docker.git

182 1 2
1个评论

wds

有docker-Compose吗带ng和mysql那种

app自动化爬虫uniapp跨端

250
积分
0
获赞数
0
粉丝数
2024-04-08 加入
×
🔝