0
点赞
收藏
分享

微信扫一扫

C#创建一个自定义控件类

冬冬_79d4 2024-08-18 阅读 34
nginxphp

生产环境docker nginx+php8.0镜像
自定义创建php8.0镜像,创建dockerfile

FROM php:8.0-fpm

# 安装系统依赖
RUN sed -i 's|http://deb.debian.org/debian|http://mirrors.aliyun.com/debian|g' /etc/apt/sources.list && \
    apt-get update && apt-get install -y \
    libfreetype6-dev \
    libjpeg62-turbo-dev \
    libpng-dev \
    libzip-dev \
    libonig-dev \
    zip \
    unzip \
    && docker-php-ext-configure gd --with-freetype --with-jpeg \
    && docker-php-ext-install -j$(nproc) gd \
    && docker-php-ext-install pdo pdo_mysql mbstring zip exif pcntl bcmath \
    && pecl install redis \
    && docker-php-ext-enable redis

# 复制PHP配置文件(可选)
#COPY php.ini /usr/local/etc/php/

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

# 运行前的清理
RUN apt-get clean && rm -rf /var/lib/apt/lists/*

在dockerfile目录下执行构建命令

docker build -t php8.0 .

构建完docker images查看
创建docker-compose.yml文件

version: '3.8'

services:
  nginx:
    image: nginx:latest
    ports:
      - "80:80"
    volumes:
      - ./nginx.conf:/etc/nginx/nginx.conf
      - ./code:/var/www/html
    networks:
      - my_network
    deploy:
      replicas: 3
      restart_policy:
        condition: on-failure

  php:
    image: php:8.0-fpm
    volumes:
      - ./code:/var/www/html
    networks:
      - my_network
    deploy:
      replicas: 3
      restart_policy:
        condition: on-failure

networks:
  my_network:
    driver: overlay

使用docker stack deploy命令将Stack部署到Swarm集群中。

docker stack deploy -c docker-compose.yml my_stack
举报

相关推荐

0 条评论