Created
July 11, 2021 08:50
-
-
Save ChewySalmon/5702fc1b38feed7ed68ba6995b0785a0 to your computer and use it in GitHub Desktop.
Laravel development Docker setup using PHP 8+, Apache, MySql 8+, PhpMyAdmin and Mailhog. Includes relevant application Dockerfile 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
version: '3.8' | |
services: | |
# Application & web server | |
app: | |
build: | |
context: . | |
working_dir: /var/www | |
volumes: | |
- ./:/var/www | |
depends_on: | |
- "database" | |
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
FROM php:8.0-apache | |
RUN apt-get update && apt-get install -y \ | |
libfreetype6-dev \ | |
libjpeg-dev \ | |
libpng-dev \ | |
libwebp-dev \ | |
--no-install-recommends \ | |
&& docker-php-ext-enable opcache \ | |
&& docker-php-ext-configure gd --with-freetype --with-jpeg \ | |
&& docker-php-ext-install pdo_mysql -j$(nproc) gd \ | |
&& apt-get autoclean -y \ | |
&& rm -rf /var/lib/apt/lists/* | |
# Update apache conf to point to application public directory | |
ENV APACHE_DOCUMENT_ROOT=/var/www/public | |
RUN sed -ri -e 's!/var/www/html!${APACHE_DOCUMENT_ROOT}!g' /etc/apache2/sites-available/*.conf | |
RUN sed -ri -e 's!/var/www/!${APACHE_DOCUMENT_ROOT}!g' /etc/apache2/apache2.conf /etc/apache2/conf-available/*.conf | |
# Update uploads config | |
RUN echo "file_uploads = On\n" \ | |
"memory_limit = 1024M\n" \ | |
"upload_max_filesize = 512M\n" \ | |
"post_max_size = 512M\n" \ | |
"max_execution_time = 1200\n" \ | |
> /usr/local/etc/php/conf.d/uploads.ini | |
# Enable headers module | |
RUN a2enmod rewrite headers |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment