首页  >  文章  >  数据库  >  [Docker] Laravel、Nginx MySQL

[Docker] Laravel、Nginx MySQL

PHPz
PHPz原创
2024-07-18 21:10:081080浏览

[Docker] Laravel, Nginx MySQL

Dockerización

  • PHP 8.2
  • Laravel 11(最新)
  • Nginx(最新)
  • MySQL(最新)

乌索

  • docker-compose 构建
  • docker-compose up -d

配置

  • 配置 laravel 的 .env

Dockerfile

FROM php:8.2-fpm-alpine

# Update app
RUN apk update && apk add --no-cache tzdata
# Set timezone
ENV TZ="UTC"

RUN apk add --update --no-cache autoconf g++ make openssl-dev
RUN apk add libpng-dev
RUN apk add libzip-dev
RUN docker-php-ext-install gd
RUN docker-php-ext-install zip
RUN docker-php-ext-install bcmath
RUN docker-php-ext-install sockets
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
### End Init install

# Install Redis
RUN pecl install redis
RUN docker-php-ext-enable redis

# Install Mongodb
RUN pecl install mongodb
RUN docker-php-ext-enable mongodb

RUN docker-php-ext-install mysqli pdo pdo_mysql && docker-php-ext-enable pdo_mysql

WORKDIR /home/source/main

docker-compose.yml

version: '3.7'
services:

  mysql:
    image: mysql:latest
    container_name: mysql
    platform: linux/x86_64
    ports:
      - "3306:3306"
    volumes:
      - mysql-volumes:/var/lib/mysql
    environment:
      MYSQL_ROOT_PASSWORD: laravelroot
      MYSQL_DATABASE: db_nginx

  laravel-app:
    build:
      context: ./docker/php
    container_name: laravel-app
    volumes:
      - ./laravel/:/home/source/main
    working_dir: /home/source/main

  nginx:
    build:
      context: ./docker/nginx
    container_name: todo-nginx
    ports:
      - "8000:80"
    depends_on:
      - laravel-app
    volumes:
      - ./laravel/:/home/source/main

volumes:
  mysql-volumes:

networks:
  default:
    name: laravel-app-netword

存储库:
https://github.com/JkDevArg/Docker-NLM

以上是[Docker] Laravel、Nginx MySQL的详细内容。更多信息请关注PHP中文网其他相关文章!

声明:
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn