Skip to content

Instantly share code, notes, and snippets.

@ChewySalmon
Last active March 27, 2023 18:00
Show Gist options
  • Save ChewySalmon/5cd5ecffaf76f8c3811d74013588bc46 to your computer and use it in GitHub Desktop.
Save ChewySalmon/5cd5ecffaf76f8c3811d74013588bc46 to your computer and use it in GitHub Desktop.
Laravel development docker setup using PHP 8+, Nginx, MySql 8+, PhpMyAdmin and Mailhog. Includes all relevant service Dockerfiles and the Compose file. [Imagick edition]
FROM php:8.0-fpm
RUN apt-get update && apt-get install -y \
libmagickwand-dev \
--no-install-recommends \
&& pecl install imagick \
&& docker-php-ext-enable imagick \
&& docker-php-ext-install pdo_mysql
version: '3.8'
services:
# Application
app:
build:
context: .
dockerfile: app.dockerfile
working_dir: /var/www
volumes:
- ./:/var/www
depends_on:
- "database"
# Web Server
web:
build:
context: .
dockerfile: web.dockerfile
working_dir: /var/www
volumes:
- ./:/var/www
depends_on:
- "app"
ports:
- 80:80
# Database
database:
image: mysql:8.0
volumes:
- dbdata:/var/lib/mysql
environment:
MYSQL_DATABASE: ${DB_DATABASE}
MYSQL_ROOT_PASSWORD: ${DB_PASSWORD}
MYSQL_PASSWORD: ${DB_PASSWORD}
MYSQL_USER: ${DB_USERNAME}
ports:
- 33061:3306
# Database management
pma:
image: phpmyadmin:5.1
environment:
- PMA_ARBITRARY=1
- PMA_HOST=${DB_HOST}
- PMA_USER=${DB_USERNAME}
- PMA_PASSWORD=${DB_PASSWORD}
- PMA_PORT=${DB_PORT}
depends_on:
- database
ports:
- 8888:80
# Mailing Server
mailhog:
image: mailhog/mailhog
logging:
driver: 'none'
ports:
- 1025:1025
- 8025:8025
volumes:
dbdata:
server {
listen 80;
index index.php index.html;
root /var/www/public;
location / {
try_files $uri /index.php?$args;
}
location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass app:9000;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
}
}
FROM nginx:1.21
COPY vhost.conf /etc/nginx/conf.d/default.conf
RUN ln -sf /dev/stdout /var/log/nginx/access.log \
&& ln -sf /dev/stderr /var/log/nginx/error.log
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment