DEV Community

JkDev
JkDev

Posted on

[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
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode

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

Top comments (0)