PHP/MySQL/Nginx/Redis Application Docker

*- Create de Dockerfile *

FROM php:8.3-fpm

RUN apt-get update && \
apt-get install -y git unzip iputils-ping && \
docker-php-ext-install pdo pdo_mysql

COPY –from=composer:latest /usr/bin/composer /usr/bin/composer

RUN com…


This content originally appeared on DEV Community and was authored by Sidgley de Almeida Guedes

*- Create de Dockerfile *

FROM php:8.3-fpm

RUN apt-get update && \
    apt-get install -y git unzip iputils-ping && \
    docker-php-ext-install pdo pdo_mysql

COPY --from=composer:latest /usr/bin/composer /usr/bin/composer

RUN composer global require laravel/installer

ENV PATH="$PATH:$HOME/.composer/vendor/bin"

WORKDIR /var/www

- Create de docker-compose.yml

version: '3.8'
services:
  app:
    image: php:8.3-fpm
    container_name: ap-name-app
    working_dir: /var/www
    volumes:
      - ./:/var/www
      - ./docker/php/php.ini:/usr/local/etc/php/php.ini
    networks:
      - laravel
    depends_on:
      - mysql
      - redis

  nginx:
    image: nginx:alpine
    container_name: app-name-nginx
    ports:
      - "8080:80"
    volumes:
      - ./:/var/www
      - ./docker/nginx/nginx.conf:/etc/nginx/nginx.conf
    networks:
      - laravel
    depends_on:
      - app

  mysql:
    image: mysql:8.0
    container_name: app-name-mysql
    environment:
      MYSQL_ROOT_PASSWORD: root
      MYSQL_DATABASE: database
      MYSQL_USER: user
      MYSQL_PASSWORD: password
    ports:
      - "3306:3306"
    volumes:
      - mysql-data:/var/lib/mysql
    networks:
      - laravel

  redis:
    image: redis:alpine
    container_name: app-name-redis
    ports:
      - "6380:6379"
    networks:
      - laravel

networks:
  laravel:
    driver: bridge

volumes:
  mysql-data:

create nginx.conf

worker_processes auto;

events {
    worker_connections 1024;
}

http {
    include /etc/nginx/mime.types;
    default_type application/octet-stream;

    sendfile on;
    keepalive_timeout 65;
    server_tokens off;

    server {
        listen 80;
        server_name localhost;

        root /var/www/public;
        index index.php index.html index.htm;

        location / {
            try_files $uri $uri/ /index.php?$query_string;
        }

        location ~ \.php$ {
            include fastcgi_params;
            fastcgi_pass app:9000;
            fastcgi_index index.php;
            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
            include fastcgi.conf;
        }

        location ~ /\.ht {
            deny all;
        }
    }
}


This content originally appeared on DEV Community and was authored by Sidgley de Almeida Guedes


Print Share Comment Cite Upload Translate Updates
APA

Sidgley de Almeida Guedes | Sciencx (2024-10-09T01:55:14+00:00) PHP/MySQL/Nginx/Redis Application Docker. Retrieved from https://www.scien.cx/2024/10/09/php-mysql-nginx-redis-application-docker/

MLA
" » PHP/MySQL/Nginx/Redis Application Docker." Sidgley de Almeida Guedes | Sciencx - Wednesday October 9, 2024, https://www.scien.cx/2024/10/09/php-mysql-nginx-redis-application-docker/
HARVARD
Sidgley de Almeida Guedes | Sciencx Wednesday October 9, 2024 » PHP/MySQL/Nginx/Redis Application Docker., viewed ,<https://www.scien.cx/2024/10/09/php-mysql-nginx-redis-application-docker/>
VANCOUVER
Sidgley de Almeida Guedes | Sciencx - » PHP/MySQL/Nginx/Redis Application Docker. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2024/10/09/php-mysql-nginx-redis-application-docker/
CHICAGO
" » PHP/MySQL/Nginx/Redis Application Docker." Sidgley de Almeida Guedes | Sciencx - Accessed . https://www.scien.cx/2024/10/09/php-mysql-nginx-redis-application-docker/
IEEE
" » PHP/MySQL/Nginx/Redis Application Docker." Sidgley de Almeida Guedes | Sciencx [Online]. Available: https://www.scien.cx/2024/10/09/php-mysql-nginx-redis-application-docker/. [Accessed: ]
rf:citation
» PHP/MySQL/Nginx/Redis Application Docker | Sidgley de Almeida Guedes | Sciencx | https://www.scien.cx/2024/10/09/php-mysql-nginx-redis-application-docker/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.