feat(docker): migrate from MySQL to PostgreSQL in Sail configuration

- Updated .env.sail.example to reflect PostgreSQL settings for database connection.
- Modified docker-compose.yml to replace MySQL service with PostgreSQL, including environment variables and health checks.
- Revised documentation in sail.md to update references from MySQL to PostgreSQL, ensuring consistency across database operations and service descriptions.

These changes enhance the development environment by transitioning to PostgreSQL, providing improved performance and compatibility for the TorrentPier application.
This commit is contained in:
Yury Pikhtarev 2025-07-09 17:52:10 +02:00
commit 2c287cbaaf
No known key found for this signature in database
3 changed files with 40 additions and 34 deletions

View file

@ -20,9 +20,9 @@ LOG_STACK=single
LOG_DEPRECATIONS_CHANNEL=null
LOG_LEVEL=debug
DB_CONNECTION=mysql
DB_HOST=mysql
DB_PORT=3306
DB_CONNECTION=pgsql
DB_HOST=pgsql
DB_PORT=5432
DB_DATABASE=torrentpier
DB_USERNAME=sail
DB_PASSWORD=password
@ -84,6 +84,8 @@ FORWARD_REDIS_PORT=6379
FORWARD_MEILISEARCH_PORT=7700
FORWARD_MAILPIT_PORT=1025
FORWARD_MAILPIT_DASHBOARD_PORT=8025
FORWARD_MINIO_PORT=9000
FORWARD_MINIO_CONSOLE_PORT=8900
# Sail PHP configuration
SAIL_XDEBUG_MODE=off

View file

@ -22,33 +22,34 @@ services:
networks:
- sail
depends_on:
- mysql
- pgsql
- redis
- meilisearch
- mailpit
- minio
mysql:
image: 'mysql/mysql-server:8.0'
pgsql:
image: 'postgres:17'
ports:
- '${FORWARD_DB_PORT:-3306}:3306'
- '${FORWARD_DB_PORT:-5432}:5432'
environment:
MYSQL_ROOT_PASSWORD: '${DB_PASSWORD}'
MYSQL_ROOT_HOST: '%'
MYSQL_DATABASE: '${DB_DATABASE}'
MYSQL_USER: '${DB_USERNAME}'
MYSQL_PASSWORD: '${DB_PASSWORD}'
MYSQL_ALLOW_EMPTY_PASSWORD: 1
PGPASSWORD: '${DB_PASSWORD:-secret}'
POSTGRES_DB: '${DB_DATABASE}'
POSTGRES_USER: '${DB_USERNAME}'
POSTGRES_PASSWORD: '${DB_PASSWORD:-secret}'
volumes:
- 'sail-mysql:/var/lib/mysql'
- './vendor/laravel/sail/database/mysql/create-testing-database.sh:/docker-entrypoint-initdb.d/10-create-testing-database.sh'
- 'sail-pgsql:/var/lib/postgresql/data'
- './vendor/laravel/sail/database/pgsql/create-testing-database.sql:/docker-entrypoint-initdb.d/10-create-testing-database.sql'
networks:
- sail
healthcheck:
test:
- CMD
- mysqladmin
- ping
- '-p${DB_PASSWORD}'
- pg_isready
- '-q'
- '-d'
- '${DB_DATABASE}'
- '-U'
- '${DB_USERNAME}'
retries: 3
timeout: 5s
redis:
@ -117,7 +118,7 @@ networks:
sail:
driver: bridge
volumes:
sail-mysql:
sail-pgsql:
driver: local
sail-redis:
driver: local

View file

@ -84,9 +84,9 @@ The `.env.sail.example` file contains pre-configured settings for Docker service
```env
# Database
DB_CONNECTION=mysql
DB_HOST=mysql
DB_PORT=3306
DB_CONNECTION=pgsql
DB_HOST=pgsql
DB_PORT=5432
DB_DATABASE=torrentpier
DB_USERNAME=sail
DB_PASSWORD=password
@ -116,7 +116,7 @@ AWS_USE_PATH_STYLE_ENDPOINT=true
TorrentPier's Sail configuration includes:
- **MySQL 8.0** - Primary database
- **PostgreSQL 17** - Primary database
- **Redis** - Caching and queues
- **Meilisearch** - Full-text search engine
- **Mailpit** - Email testing interface
@ -131,10 +131,13 @@ To add additional services:
```
Available services include:
- PostgreSQL
- MySQL
- MariaDB
- MongoDB
- Valkey
- Memcached
- MinIO
- Typesense
- RabbitMQ
- Selenium
- Soketi
@ -211,14 +214,14 @@ Available services include:
### Database Operations
```bash
# Access MySQL CLI
./vendor/bin/sail mysql
# Access PostgreSQL CLI
./vendor/bin/sail psql
# Export database
./vendor/bin/sail exec mysql mysqldump -u sail -ppassword torrentpier > backup.sql
./vendor/bin/sail exec pgsql pg_dump -U sail torrentpier > backup.sql
# Import database
./vendor/bin/sail exec mysql mysql -u sail -ppassword torrentpier < backup.sql
./vendor/bin/sail exec pgsql psql -U sail torrentpier < backup.sql
```
### Shell Access
@ -360,7 +363,7 @@ If you get port conflicts, customize ports in `.env`:
```env
APP_PORT=8080
FORWARD_DB_PORT=3307
FORWARD_DB_PORT=5433
FORWARD_REDIS_PORT=6380
FORWARD_MEILISEARCH_PORT=7701
FORWARD_MAILPIT_PORT=1026
@ -406,16 +409,16 @@ rm -rf vendor node_modules
If you can't connect to the database:
1. Wait for MySQL to be ready:
1. Wait for PostgreSQL to be ready:
```bash
./vendor/bin/sail exec mysql mysqladmin ping -h localhost --silent --wait=30
./vendor/bin/sail exec pgsql pg_isready -h localhost -U sail
```
2. Check MySQL logs:
2. Check PostgreSQL logs:
```bash
./vendor/bin/sail logs mysql
./vendor/bin/sail logs pgsql
```
3. Verify credentials match `.env` file