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_DEPRECATIONS_CHANNEL=null
LOG_LEVEL=debug LOG_LEVEL=debug
DB_CONNECTION=mysql DB_CONNECTION=pgsql
DB_HOST=mysql DB_HOST=pgsql
DB_PORT=3306 DB_PORT=5432
DB_DATABASE=torrentpier DB_DATABASE=torrentpier
DB_USERNAME=sail DB_USERNAME=sail
DB_PASSWORD=password DB_PASSWORD=password
@ -84,6 +84,8 @@ FORWARD_REDIS_PORT=6379
FORWARD_MEILISEARCH_PORT=7700 FORWARD_MEILISEARCH_PORT=7700
FORWARD_MAILPIT_PORT=1025 FORWARD_MAILPIT_PORT=1025
FORWARD_MAILPIT_DASHBOARD_PORT=8025 FORWARD_MAILPIT_DASHBOARD_PORT=8025
FORWARD_MINIO_PORT=9000
FORWARD_MINIO_CONSOLE_PORT=8900
# Sail PHP configuration # Sail PHP configuration
SAIL_XDEBUG_MODE=off SAIL_XDEBUG_MODE=off

View file

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

View file

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