Last active
March 8, 2024 14:00
-
-
Save ChewySalmon/accfd54967471b4b4faaef1e5c5b8f15 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. [GD edition]
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM php:8.0-fpm | |
RUN apt-get update && apt-get install -y \ | |
libfreetype6-dev \ | |
libjpeg-dev \ | |
libpng-dev \ | |
libwebp-dev \ | |
--no-install-recommends \ | |
&& docker-php-ext-configure gd --with-freetype --with-jpeg \ | |
&& docker-php-ext-install pdo_mysql -j$(nproc) gd |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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