Home > Database > Mysql Tutorial > body text

[Docker] Laravel, Nginx MySQL

PHPz
Release: 2024-07-18 21:10:08
Original
1084 people have browsed it

[Docker] Laravel, Nginx MySQL

Dockerización

  • PHP 8.2
  • Laravel 11 (Latest)
  • Nginx (Latest)
  • MySQL (Latest)

Uso

  • docker-compose build
  • docker-compose up -d

Config

  • Configurar el .env de laravel

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
Copy after login

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
Copy after login

Repositorio:
https://github.com/JkDevArg/Docker-NLM

The above is the detailed content of [Docker] Laravel, Nginx MySQL. For more information, please follow other related articles on the PHP Chinese website!

source:dev.to
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!