Docker container stack for a web service development using PHP.
The stack consists of Nginx / php-fpm / Postgres / Redis, each container is based on Debian.
When using it in a non-local environment, please set appropriate environment variables on the host without using .env
.
Also, it is better to change the application code so that it is installed when creating the image instead of being shared by mounting.
- Clone this repository.
- Rename .env.example to .env and refer to the comment to set the value.
- Create the app directory at the same level as the build directory.(
app
is mounted as/var/www/html/app
)
Do you want to change the document root underapp
directory?
In that case, copy/docker/web/conf/default.conf
to any location in your project directory, change theroot
directive, and bind-mount it as/etc/nginx/conf.d/default.conf
. - Execute the
docker compose up -d
command. - Create an
index.php
file and put<?php phpinfo();
to file in theapp
directory of your project root, and accesshttp://localhost:8080
from your browser! - Let's develop it freely!😎
- Use a common TimeZone for all containers (this can be specified in
.env
) - In the
app
andweb
containers, the system language is changed based on the.env
configuration value.
- Use the official image of PHP 8.2
- Xdebug's extension is valid (Listen on port
9003
| Default ide keyIDEKEY
| Start with request trigger) - PHP's extension that Laravel depends on is installed
- Composer is installed in system global (from composer official image)
- If you want to change php settings, bind mount any
php.ini
to/usr/local/etc/php/php.ini
- If you want to change php-fpm settings, mount any
zzz-www.conf
to/usr/local/etc/php-fpm.d/zzz-www.conf
- The
app
directory in the project root will be bind mounted as/var/www/html/app
- Use the official image of Nginx 1.25
- Cooperation with php-fpm container is valid (Communicate with php-fpm on TCP port 9000)
- If you want to change nginx settings, bind mount any
default.conf
to/etc/nginx/conf.d/default.conf
,nginx.conf
to/etc/nginx/nginx.conf
- The
app
directory in the project root will be bind mounted as/var/www/html/app
(This is the default document root)
- Use the official image of Postgres 15.4
- The initial database name, default username, and user password are passed to the container as environment variables (The actual values are defined in the .env file)
- The data is persisted by
postgres-data
volume
- Use the official image of redis 7.0
- This container does not persist data
- Use the official image of mailhog 1.0.1
- It can be used as a destination for sending test mails via SMTP (open http://localhost:8025 to check the mail)
- The data is persisted by
mail-data
volume
This has been abolition.
It is a container for both web and app using the official php container (Apache/PHP 8.1).To use, comment outapp
andweb
fromservices
indocker-compose.yml
and uncommentapp-web
to enable it.Xdebug's extension is valid (Listen on port9003
| Default ide keyIDEKEY
| Start with request trigger)PHP's extension that Laravel depends on is installedComposer is installed in system global (from composer official image)If you want to change php settings, bind mount anyphp.ini
to/usr/local/etc/php/php.ini
Theapp
directory in the project root will be bind mounted as/var/www/html/app
MIT