首頁  >  文章  >  資料庫  >  [Docker] Laravel、Nginx MySQL

[Docker] Laravel、Nginx MySQL

PHPz
PHPz原創
2024-07-18 21:10:081099瀏覽

[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