Requirements
Git
Docker engine version 19.x or higher
Features and Capabilities
Multiple PHP Versions:
PHP 8.0 and PHP 7.4 with a set of commonly used extensions.
Flexibility:
Enables using different PHP versions for various web projects.
Pre-configured Tools:
Includes a ready-to-use process supervisor.
Pre-configured Nginx web server.
Databases:
MySQL 5.7
MySQL 8
PostgreSQL (latest)
MongoDB 4.2
Redis (latest)
Configuration Flexibility:
Environment parameters are set through the
.env
file.Services can be modified via
docker-compose.yml
.
Docker Images:
Uses official images for all Docker containers.
Structured
Dockerfile
for creating PHP images.
Data Management:
Most container directories storing user data and configuration parameters are mounted locally.
Service Isolation:
Adheres to the principle that each container should only run one service.
Project Structure
.env-example .gitignore .ssh README.md docker-compose.yml mongo mysql-5.7 mysql-8 nginx php-ini php-workers php-workspace postgres projects redis
.env-example
: Example file with basic environment settings..gitignore
: Specifies files and directories to be ignored by Git..ssh
: Stores SSH keys.docker-compose.yml
: Defines multi-container application rules.Databases:
mongo
: MongoDB database settings, dumps, and configurations.mysql-5.7
andmysql-8
: MySQL database settings, dumps, and logs.postgres
: PostgreSQL database settings and dumps.
nginx
: Stores Nginx configuration and logs.php-ini
: Contains PHP configuration files for different versions.php-workers
: Stores Supervisor configuration files.projects
: Directory for storing web projects accessible to PHP containers.redis
: Redis key-value store configuration and data.
Getting Started
Clone the repository:
git clone git@bitbucket.org:datingpro/pg_docker.git
Update Environment Settings:
Copy the
.env-example
file:cp .env-example .env
Modify the
.env
file to suit your requirements.
Clone Web Projects:
Clone your web projects into the
projects
directory.Example:
dev.loc
: Uses PHP 8.0.prod.loc
: Uses PHP 7.4.
Update Nginx Configuration:
Modify virtual host settings in
./nginx/conf.d/
.
Set Up Hosts File:
Map domain names to the local machine’s IP:
On Mac/Linux:
/etc/hosts
On Windows:
C:\Windows\System32\drivers\etc\hosts
127.0.0.1 dev.loc 127.0.0.1 prod.loc
Optional: Add Routing Within Containers:
To enable containers to communicate with each other, add
extra_hosts
indocker-compose.yml
:extra_hosts: - 'dev.loc:IP_HOST_MACHINE' - 'prod.loc:IP_HOST_MACHINE'
Start the Containers:
docker-compose build && docker-compose up -d
Install Dependencies:
Use Composer or npm to install dependencies for web applications.
Example:
docker exec -it php-8.0 bash composer install
Check Running Containers:
docker ps
Database Management
MySQL:
Load a dump file:
docker exec -i mysql mysql --user=root --password=secret --force < databases-dump.sql
Use
Percona XtraBackup
for hot backups if required.
PostgreSQL:
Restore a database:
docker exec -i postgres psql --username user_name database_name < /path/to/dump/pgsql-backup.sql
MongoDB:
Restore a dump:
docker exec -it mongo sh mongorestore -d database_name /dump/databases/database_name
FAQ
How to stop and remove containers?
docker-compose down
How to get detailed information about a container?
docker inspect container_name
How to list all containers?
docker ps -a
How to delete all containers?
docker rm -v $(docker ps -aq)
How to check installed PHP extensions?
docker exec -it php-8.0 php -m
For detailed information and updates, refer to the original documentation or reach out to the support team.