feat: add PostgreSQL support with Compose profiles
- Add db-postgres service behind 'postgres' profile (MariaDB moved to 'mariadb' profile) - Both databases aliased as 'db'; PHP waits for healthy DB (Compose >= 2.20) - Pass DB_TYPE to the PHP container - New PHP extensions: pdo_pgsql, gd, bcmath - Upgrade Node.js to v26.x - Update README with database selection docs and v1.2.0 changelog
This commit is contained in:
1 parent
d6493fb02d
commit
89fd137aca
5 files changed
+197
-53
No files matched your search
+12
-2
@@ -22,7 +22,17 @@ PROJECT_NAME=''
|
|||||||
# Database Configurations #
|
# Database Configurations #
|
||||||
#=========================#
|
#=========================#
|
||||||
|
|
||||||
MYSQL_ROOT_PASSWORD=root
|
# Pick one: postgres | mariadb
|
||||||
MYSQL_DATABASE=database
|
COMPOSE_PROFILES=postgres
|
||||||
|
DB_TYPE=postgres
|
||||||
|
|
||||||
|
# Postgres
|
||||||
|
POSTGRES_DB=app
|
||||||
|
POSTGRES_USER=app
|
||||||
|
POSTGRES_PASSWORD=secret
|
||||||
|
|
||||||
|
# MariaDB
|
||||||
|
MYSQL_ROOT_PASSWORD=rootsecret
|
||||||
|
MYSQL_DATABASE=app
|
||||||
MYSQL_USER_DATABASE=app
|
MYSQL_USER_DATABASE=app
|
||||||
MYSQL_PASSWORD_DATABASE=secret
|
MYSQL_PASSWORD_DATABASE=secret
|
||||||
+12
-9
@@ -4,6 +4,9 @@ FROM dunglas/frankenphp:php${PHP_VERSION}-trixie AS base
|
|||||||
# add additional extensions here:
|
# add additional extensions here:
|
||||||
RUN install-php-extensions \
|
RUN install-php-extensions \
|
||||||
pdo_mysql \
|
pdo_mysql \
|
||||||
|
pdo_pgsql \
|
||||||
|
gd \
|
||||||
|
bcmath \
|
||||||
mbstring \
|
mbstring \
|
||||||
curl \
|
curl \
|
||||||
xml \
|
xml \
|
||||||
@@ -28,12 +31,12 @@ RUN chmod +x /usr/bin/composer
|
|||||||
# -------------------------
|
# -------------------------
|
||||||
FROM base AS node
|
FROM base AS node
|
||||||
RUN apt-get update \
|
RUN apt-get update \
|
||||||
&& apt-get install -y curl gnupg \
|
&& apt-get install -y curl gnupg \
|
||||||
&& curl -fsSL https://deb.nodesource.com/setup_20.x | bash - \
|
&& curl -fsSL https://deb.nodesource.com/setup_26.x | bash - \
|
||||||
&& apt-get install -y nodejs \
|
&& apt-get install -y nodejs \
|
||||||
&& node -v \
|
&& node -v \
|
||||||
&& npm -v \
|
&& npm -v \
|
||||||
&& rm -rf /var/lib/apt/lists/*
|
&& rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
# -------------------------
|
# -------------------------
|
||||||
# Symfony profile
|
# Symfony profile
|
||||||
@@ -89,6 +92,6 @@ RUN if [ -d /app/storage ]; then chown -R 65534:65534 /app/storage /app/bootstra
|
|||||||
ARG MODE
|
ARG MODE
|
||||||
# production mode: direct run container on server
|
# production mode: direct run container on server
|
||||||
RUN if [ "$MODE" = "prod" ]; then \
|
RUN if [ "$MODE" = "prod" ]; then \
|
||||||
# Enable PHP production settings
|
# Enable PHP production settings
|
||||||
mv "$PHP_INI_DIR/php.ini-production" "$PHP_INI_DIR/php.ini"; \
|
mv "$PHP_INI_DIR/php.ini-production" "$PHP_INI_DIR/php.ini"; \
|
||||||
fi
|
fi
|
||||||
@@ -5,27 +5,37 @@ A modern, lightweight Docker environment for PHP applications using FrankenPHP,
|
|||||||
## Features
|
## Features
|
||||||
|
|
||||||
- 🚀 **FrankenPHP Server**: Modern PHP server with HTTP/2, HTTP/3, and automatic HTTPS via Caddy
|
- 🚀 **FrankenPHP Server**: Modern PHP server with HTTP/2, HTTP/3, and automatic HTTPS via Caddy
|
||||||
- 🗄️ **MariaDB Database**: Persistent relational database for your applications
|
- 🗄️ **Database Support**: PostgreSQL or MariaDB — pick one with Docker Compose profiles, both reachable as host `db`
|
||||||
- 📦 **Node.js Integration**: Full Node.js runtime (v20.x) for frontend tooling and build processes
|
- 📦 **Node.js Integration**: Full Node.js runtime (v26.x) for frontend tooling and build processes
|
||||||
- 🎯 **Multi-Framework Support**: Optimized build targets for Laravel, Symfony, Magento2, WordPress, and OpenCart
|
- 🎯 **Multi-Framework Support**: Optimized build targets for Laravel, Symfony, Magento2, WordPress, and OpenCart
|
||||||
- 🧰 **CLI Tools Included**: Symfony CLI is available for Symfony projects and WP-CLI is included for WordPress workflows
|
- 🧰 **CLI Tools Included**: Symfony CLI is available for Symfony projects and WP-CLI is included for WordPress workflows
|
||||||
- 🗄️ **Redis Support**: A dedicated Redis container is included with health checks and PHP connectivity for supported stacks
|
- 🗄️ **Redis Support**: A dedicated Redis container is included with health checks and PHP connectivity for supported stacks
|
||||||
- 📝 **PHP 8.0 - 8.5**: Support for multiple PHP versions with configurable extensions
|
- 📝 **PHP 8.0 - 8.5**: Support for multiple PHP versions with configurable extensions
|
||||||
- 🔧 **Flexible Configuration**: Local, proxy, and production modes
|
- 🔧 **Flexible Configuration**: Local, proxy, and production modes
|
||||||
- 🔒 **Automatic HTTPS**: Let's Encrypt SSL certificates in production
|
- 🔒 **Automatic HTTPS**: Let's Encrypt SSL certificates in production
|
||||||
- 🎨 **Extension-Rich**: Pre-installed essential PHP extensions (PDO/MySQL, Redis, APCu, and more)
|
- 🎨 **Extension-Rich**: Pre-installed essential PHP extensions (PDO/MySQL, PDO/PostgreSQL, Redis, APCu, and more)
|
||||||
- ⚡ **Alpine-Based**: Lightweight, fast, and efficient container images
|
- ⚡ **Debian Trixie-Based**: Lightweight, fast, and efficient container images
|
||||||
- 🔄 **Hot Reload**: Automatic code reloading during development
|
- 🔄 **Hot Reload**: Automatic code reloading during development
|
||||||
|
|
||||||
### Recently Added
|
### Recently Added
|
||||||
|
|
||||||
|
- PostgreSQL support — choose `postgres` or `mariadb` via Docker Compose profiles (`COMPOSE_PROFILES`), both exposed to the app as host `db`
|
||||||
|
- `DB_TYPE` environment variable passed to the PHP container so applications can detect the active database
|
||||||
|
- `pdo_pgsql`, `gd`, and `bcmath` PHP extensions pre-installed
|
||||||
|
- Node.js upgraded to v26.x
|
||||||
|
- Health checks for both database services; PHP waits for a healthy database before starting
|
||||||
- Symfony CLI pre-installed for Symfony-based applications
|
- Symfony CLI pre-installed for Symfony-based applications
|
||||||
- WP-CLI pre-installed for WordPress administration and site management
|
- WP-CLI pre-installed for WordPress administration and site management
|
||||||
- Redis container support with health checks and framework-ready PHP integration
|
- Redis container support with health checks and framework-ready PHP integration
|
||||||
|
- Caddy web server with HTTP/2 and HTTP/3 support
|
||||||
|
- Automatic HTTPS via Let's Encrypt in production mode
|
||||||
|
- Multi-stage Docker builds optimized per framework
|
||||||
|
- Alpine-based lightweight container images
|
||||||
|
- Built-in health checks for Redis and database services
|
||||||
|
|
||||||
## Requirements
|
## Requirements
|
||||||
|
|
||||||
- Docker Desktop (or Docker Engine + Docker Compose)
|
- Docker Desktop (or Docker Engine + Docker Compose v2.20+; required for optional `depends_on` entries)
|
||||||
- 2GB+ RAM available
|
- 2GB+ RAM available
|
||||||
- Terminal/Command-line access
|
- Terminal/Command-line access
|
||||||
|
|
||||||
@@ -54,9 +64,18 @@ MODE=proxy # Mode: local, prod, proxy
|
|||||||
PORT=80 # Local port
|
PORT=80 # Local port
|
||||||
PROJECT_NAME=opencart # Project name
|
PROJECT_NAME=opencart # Project name
|
||||||
|
|
||||||
# Database Configuration
|
# Database Configuration (pick one: postgres | mariadb)
|
||||||
MYSQL_ROOT_PASSWORD=root
|
COMPOSE_PROFILES=postgres # Which database container to start
|
||||||
MYSQL_DATABASE=database
|
DB_TYPE=postgres # Passed to the PHP container
|
||||||
|
|
||||||
|
# Postgres
|
||||||
|
POSTGRES_DB=app
|
||||||
|
POSTGRES_USER=app
|
||||||
|
POSTGRES_PASSWORD=secret
|
||||||
|
|
||||||
|
# MariaDB (used when COMPOSE_PROFILES=mariadb)
|
||||||
|
MYSQL_ROOT_PASSWORD=rootsecret
|
||||||
|
MYSQL_DATABASE=app
|
||||||
MYSQL_USER_DATABASE=app
|
MYSQL_USER_DATABASE=app
|
||||||
MYSQL_PASSWORD_DATABASE=secret
|
MYSQL_PASSWORD_DATABASE=secret
|
||||||
```
|
```
|
||||||
@@ -83,12 +102,43 @@ docker-compose up -d
|
|||||||
| `MODE` | Run mode | `local` (dev), `proxy` (behind reverse proxy), `prod` (production) |
|
| `MODE` | Run mode | `local` (dev), `proxy` (behind reverse proxy), `prod` (production) |
|
||||||
| `PORT` | HTTP port | Any available port (default: `80`) |
|
| `PORT` | HTTP port | Any available port (default: `80`) |
|
||||||
| `PROJECT_NAME` | Project identifier | Any alphanumeric name |
|
| `PROJECT_NAME` | Project identifier | Any alphanumeric name |
|
||||||
| `MYSQL_ROOT_PASSWORD` | Database root password | Your secure password |
|
| `COMPOSE_PROFILES` | Database service to start | `postgres` or `mariadb` |
|
||||||
| `MYSQL_DATABASE` | Database name | `database` |
|
| `DB_TYPE` | Active database type (passed to the app) | `postgres` or `mariadb` |
|
||||||
| `MYSQL_USER_DATABASE` | Database user | `app` |
|
| `POSTGRES_DB` | Postgres database name | `app` |
|
||||||
| `MYSQL_PASSWORD_DATABASE` | Database user password | Your secure password |
|
| `POSTGRES_USER` | Postgres user | `app` |
|
||||||
|
| `POSTGRES_PASSWORD` | Postgres password | Your secure password |
|
||||||
|
| `MYSQL_ROOT_PASSWORD` | MariaDB root password | Your secure password |
|
||||||
|
| `MYSQL_DATABASE` | MariaDB database name | `app` |
|
||||||
|
| `MYSQL_USER_DATABASE` | MariaDB user | `app` |
|
||||||
|
| `MYSQL_PASSWORD_DATABASE` | MariaDB user password | Your secure password |
|
||||||
| `SERVER_NAME` | Domain (prod mode) | Your domain (e.g., `example.com`) |
|
| `SERVER_NAME` | Domain (prod mode) | Your domain (e.g., `example.com`) |
|
||||||
|
|
||||||
|
### Database Selection
|
||||||
|
|
||||||
|
Both database services run behind Docker Compose profiles, so only the one you enable will start:
|
||||||
|
|
||||||
|
- **PostgreSQL**: `COMPOSE_PROFILES=postgres`
|
||||||
|
- **MariaDB**: `COMPOSE_PROFILES=mariadb`
|
||||||
|
|
||||||
|
Keep `DB_TYPE` in sync (it is passed into the PHP container so your application can detect which database is active). Both services are aliased as `db` on `app-network`, so your application always connects to host `db` regardless of the choice:
|
||||||
|
|
||||||
|
```ini
|
||||||
|
# Laravel / generic PDO
|
||||||
|
DB_CONNECTION=pgsql # or DB_CONNECTION=mysql
|
||||||
|
DB_HOST=db
|
||||||
|
DB_PORT=5432 # 3306 for MariaDB
|
||||||
|
DB_DATABASE=app
|
||||||
|
DB_USERNAME=app
|
||||||
|
DB_PASSWORD=secret
|
||||||
|
```
|
||||||
|
|
||||||
|
To switch databases, change the two variables in `.env` and run:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
docker-compose down
|
||||||
|
docker-compose up -d
|
||||||
|
```
|
||||||
|
|
||||||
### Framework-Specific Setup
|
### Framework-Specific Setup
|
||||||
|
|
||||||
#### Laravel
|
#### Laravel
|
||||||
@@ -225,7 +275,8 @@ docker-compose logs -f
|
|||||||
|
|
||||||
# View specific service logs
|
# View specific service logs
|
||||||
docker-compose logs -f php
|
docker-compose logs -f php
|
||||||
docker-compose logs -f db
|
docker-compose logs -f db-postgres
|
||||||
|
docker-compose logs -f db-mariadb
|
||||||
```
|
```
|
||||||
|
|
||||||
### Access Container Shell
|
### Access Container Shell
|
||||||
@@ -234,8 +285,9 @@ docker-compose logs -f db
|
|||||||
# PHP container
|
# PHP container
|
||||||
docker-compose exec php sh
|
docker-compose exec php sh
|
||||||
|
|
||||||
# Database container
|
# Database container (depending on your profile)
|
||||||
docker-compose exec db mysql -u app -p
|
docker-compose exec db-postgres psql -U app -d app
|
||||||
|
docker-compose exec db-mariadb mysql -u app -p
|
||||||
```
|
```
|
||||||
|
|
||||||
## Development Workflow
|
## Development Workflow
|
||||||
@@ -258,7 +310,8 @@ docker-compose exec php php artisan migrate # Laravel
|
|||||||
docker-compose exec php bin/console doctrine:schema # Symfony
|
docker-compose exec php bin/console doctrine:schema # Symfony
|
||||||
|
|
||||||
# Database management
|
# Database management
|
||||||
docker-compose exec db mysql -u app -p database
|
docker-compose exec db-postgres psql -U app -d app # Postgres
|
||||||
|
docker-compose exec db-mariadb mysql -u app -p app # MariaDB
|
||||||
```
|
```
|
||||||
|
|
||||||
### File Structure
|
### File Structure
|
||||||
@@ -459,18 +512,30 @@ The Dockerfile uses multi-stage builds to optimize for different frameworks:
|
|||||||
|
|
||||||
#### PHP Service (FrankenPHP)
|
#### PHP Service (FrankenPHP)
|
||||||
|
|
||||||
- **Image**: `dunglas/frankenphp:php{PHP_VERSION}-alpine`
|
- **Image**: `dunglas/frankenphp:php{PHP_VERSION}-trixie`
|
||||||
- **Includes**:
|
- **Includes**:
|
||||||
- PHP 8.0-8.5
|
- PHP 8.0-8.5
|
||||||
- Node.js v20.x
|
- Node.js v26.x
|
||||||
- Caddy web server
|
- Caddy web server
|
||||||
- Framework-specific extensions
|
- Framework-specific extensions
|
||||||
|
|
||||||
|
#### Database Service (PostgreSQL)
|
||||||
|
|
||||||
|
- **Profile**: `postgres` (enabled via `COMPOSE_PROFILES=postgres`)
|
||||||
|
- **Image**: `postgres`
|
||||||
|
- **Volume**: `postgres_data` (persistent)
|
||||||
|
- **Port**: `5432` (internal)
|
||||||
|
- **Network Alias**: `db` — the app connects to host `db`
|
||||||
|
- **Health Check**: `pg_isready`
|
||||||
|
|
||||||
#### Database Service (MariaDB)
|
#### Database Service (MariaDB)
|
||||||
|
|
||||||
- **Image**: `mariadb:latest`
|
- **Profile**: `mariadb` (enabled via `COMPOSE_PROFILES=mariadb`)
|
||||||
- **Volume**: `db_data` (persistent)
|
- **Image**: `mariadb`
|
||||||
|
- **Volume**: `mariadb_data` (persistent)
|
||||||
- **Port**: `3306` (internal)
|
- **Port**: `3306` (internal)
|
||||||
|
- **Network Alias**: `db` — the app connects to host `db`
|
||||||
|
- **Health Check**: `healthcheck.sh --connect --innodb_initialized`
|
||||||
|
|
||||||
#### Redis Service (Cache)
|
#### Redis Service (Cache)
|
||||||
|
|
||||||
@@ -490,18 +555,21 @@ networks:
|
|||||||
volumes:
|
volumes:
|
||||||
caddy_data: # Caddy cache and data
|
caddy_data: # Caddy cache and data
|
||||||
caddy_config: # Caddy configuration
|
caddy_config: # Caddy configuration
|
||||||
db_data: # Database persistence
|
postgres_data: # PostgreSQL persistence
|
||||||
|
mariadb_data: # MariaDB persistence
|
||||||
|
redis_data: # Redis persistence
|
||||||
```
|
```
|
||||||
|
|
||||||
## PHP Extensions
|
## PHP Extensions
|
||||||
|
|
||||||
### Core Extensions
|
### Core Extensions
|
||||||
|
|
||||||
- **Database**: `pdo_mysql`, `mysqli`
|
- **Database**: `pdo_mysql`, `pdo_pgsql`, `mysqli`
|
||||||
- **String**: `mbstring`, `ctype`, `iconv`
|
- **String**: `mbstring`, `ctype`, `iconv`
|
||||||
- **Data**: `xml`, `dom`, `simplexml`, `fileinfo`
|
- **Data**: `xml`, `dom`, `simplexml`, `fileinfo`
|
||||||
- **Security**: `openssl`, `tokenizer`
|
- **Security**: `openssl`, `tokenizer`
|
||||||
- **Utilities**: `curl`, `zip`, `intl`, `opcache`
|
- **Utilities**: `curl`, `zip`, `intl`, `opcache`
|
||||||
|
- **Math & Image**: `bcmath`, `gd`
|
||||||
|
|
||||||
### Framework-Specific Extensions
|
### Framework-Specific Extensions
|
||||||
|
|
||||||
@@ -529,11 +597,18 @@ PORT=8080 docker-compose up -d
|
|||||||
|
|
||||||
### Database Connection Issues
|
### Database Connection Issues
|
||||||
|
|
||||||
Verify credentials in `.env`:
|
Verify credentials in `.env` and make sure `COMPOSE_PROFILES` matches the running service:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
|
# Postgres
|
||||||
docker-compose exec php php -r "
|
docker-compose exec php php -r "
|
||||||
\$db = new mysqli('db', 'app', 'secret', 'database');
|
\$db = new PDO('pgsql:host=db;port=5432;dbname=app', 'app', 'secret');
|
||||||
|
echo 'Connected successfully!';
|
||||||
|
"
|
||||||
|
|
||||||
|
# MariaDB
|
||||||
|
docker-compose exec php php -r "
|
||||||
|
\$db = new mysqli('db', 'app', 'secret', 'app');
|
||||||
if (\$db->connect_error) exit('Connection failed: ' . \$db->connect_error);
|
if (\$db->connect_error) exit('Connection failed: ' . \$db->connect_error);
|
||||||
echo 'Connected successfully!';
|
echo 'Connected successfully!';
|
||||||
"
|
"
|
||||||
@@ -599,16 +674,20 @@ docker stats
|
|||||||
|
|
||||||
### Database Optimization
|
### Database Optimization
|
||||||
|
|
||||||
1. Set appropriate `MYSQL_ROOT_PASSWORD`
|
1. Set appropriate `POSTGRES_PASSWORD` (or `MYSQL_ROOT_PASSWORD` for MariaDB)
|
||||||
2. Monitor with:
|
2. Monitor with:
|
||||||
```bash
|
```bash
|
||||||
docker-compose exec db mysql -u root -p -e "SHOW PROCESSLIST;"
|
# Postgres
|
||||||
|
docker-compose exec db-postgres psql -U app -d app -c "SELECT datname, numbackends FROM pg_stat_database;"
|
||||||
|
|
||||||
|
# MariaDB
|
||||||
|
docker-compose exec db-mariadb mysql -u root -p -e "SHOW PROCESSLIST;"
|
||||||
```
|
```
|
||||||
|
|
||||||
## Security Best Practices
|
## Security Best Practices
|
||||||
|
|
||||||
- ✅ Change default database credentials in `.env`
|
- ✅ Change default database credentials in `.env`
|
||||||
- ✅ Use strong passwords for `MYSQL_ROOT_PASSWORD` and `MYSQL_PASSWORD_DATABASE`
|
- ✅ Use strong passwords for `POSTGRES_PASSWORD`, `MYSQL_ROOT_PASSWORD`, and `MYSQL_PASSWORD_DATABASE`
|
||||||
- ✅ Set `MODE=prod` for production deployments
|
- ✅ Set `MODE=prod` for production deployments
|
||||||
- ✅ Keep `php.ini` locked to read-only (default)
|
- ✅ Keep `php.ini` locked to read-only (default)
|
||||||
- ✅ Use environment variables for sensitive data
|
- ✅ Use environment variables for sensitive data
|
||||||
@@ -637,12 +716,26 @@ docker stats
|
|||||||
|
|
||||||
## Changelog
|
## Changelog
|
||||||
|
|
||||||
### v1.1.0 (Current)
|
### v1.2.0 (Current)
|
||||||
|
- PostgreSQL support with `COMPOSE_PROFILES=postgres` (MariaDB moved behind the `mariadb` profile)
|
||||||
|
- `DB_TYPE` environment variable exposes the active database type to the PHP container
|
||||||
|
- Both database services are network-aliased as `db` with health checks; PHP waits for a healthy database before starting
|
||||||
|
- New PHP extensions: `pdo_pgsql`, `gd`, `bcmath`
|
||||||
|
- Node.js upgraded from v20.x to v26.x
|
||||||
|
|
||||||
|
### v1.1.0
|
||||||
- Multi-stage Docker build for framework-specific optimization
|
- Multi-stage Docker build for framework-specific optimization
|
||||||
- Node.js v20.x integration
|
- Node.js v20.x integration
|
||||||
- Support for 5+ PHP frameworks with dedicated configurations
|
- Support for 5+ PHP frameworks with dedicated configurations
|
||||||
- Improved documentation and examples
|
- Improved documentation and examples
|
||||||
- Production mode with automatic HTTPS
|
- Production mode with automatic HTTPS
|
||||||
|
- Caddy web server with HTTP/2 and HTTP/3 support
|
||||||
|
- Automatic HTTPS via Let's Encrypt in production mode
|
||||||
|
- Multi-stage Docker builds optimized per framework
|
||||||
|
- Alpine-based lightweight container images
|
||||||
|
- Built-in health checks for Redis and database services
|
||||||
|
- Symfony CLI and WP-CLI pre-installed for framework-specific workflows
|
||||||
|
- Redis container with health checks and PHP connectivity
|
||||||
|
|
||||||
### v1.0.0
|
### v1.0.0
|
||||||
- Initial release with FrankenPHP and MariaDB
|
- Initial release with FrankenPHP and MariaDB
|
||||||
@@ -651,5 +744,5 @@ docker stats
|
|||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
**Last Updated**: March 2026
|
**Last Updated**: November 2026
|
||||||
**Maintainer**: Development Team
|
**Maintainer**: Development Team
|
||||||
+48
-12
@@ -5,48 +5,83 @@ services:
|
|||||||
dockerfile: Dockerfile
|
dockerfile: Dockerfile
|
||||||
target: ${FRAMEWORK}
|
target: ${FRAMEWORK}
|
||||||
args:
|
args:
|
||||||
# args from .env file
|
# args from .env file
|
||||||
PHP_VERSION: ${PHP_VERSION}
|
PHP_VERSION: ${PHP_VERSION}
|
||||||
MODE: ${MODE}
|
MODE: ${MODE}
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
networks:
|
networks:
|
||||||
- app-network
|
- app-network
|
||||||
environment:
|
environment:
|
||||||
# proxy,local mode
|
# proxy,local mode
|
||||||
CADDY_TLS_INTERNAL: 0
|
CADDY_TLS_INTERNAL: 0
|
||||||
SERVER_NAME: ":${PORT}"
|
SERVER_NAME: ":${PORT}"
|
||||||
# production mode
|
# production mode
|
||||||
# SERVER_NAME: ${SERVER_NAME}
|
# SERVER_NAME: ${SERVER_NAME}
|
||||||
# FRANKENPHP_HTTP2: 1
|
# FRANKENPHP_HTTP2: 1
|
||||||
# FRANKENPHP_HTTP3: 1
|
# FRANKENPHP_HTTP3: 1
|
||||||
|
DB_TYPE: ${DB_TYPE}
|
||||||
|
depends_on:
|
||||||
|
db-postgres:
|
||||||
|
condition: service_healthy
|
||||||
|
required: false # ignored when the profile is inactive (Compose ≥ 2.20)
|
||||||
|
db-mariadb:
|
||||||
|
condition: service_healthy
|
||||||
|
required: false
|
||||||
ports:
|
ports:
|
||||||
# proxy,local mode
|
# proxy,local mode
|
||||||
- "${PORT}:${PORT}" # HTTP
|
- "${PORT}:${PORT}" # HTTP
|
||||||
# production mode
|
# production mode
|
||||||
# - "443:443" # HTTPS
|
# - "443:443" # HTTPS
|
||||||
# - "443:443/udp" # HTTP/3
|
# - "443:443/udp" # HTTP/3
|
||||||
volumes:
|
volumes:
|
||||||
- ./php.ini:/usr/local/etc/php/php.ini:ro
|
- ./php.ini:/usr/local/etc/php/php.ini:ro
|
||||||
- caddy_data:/data
|
- caddy_data:/data
|
||||||
- caddy_config:/config
|
- caddy_config:/config
|
||||||
# opencart,wordpress
|
# opencart,wordpress
|
||||||
- ./www:/app/public
|
- ./www:/app/public
|
||||||
# laravel,symfony
|
# laravel,symfony
|
||||||
# - ./www:/app
|
# - ./www:/app
|
||||||
|
|
||||||
|
db-postgres:
|
||||||
|
profiles: [ "postgres" ]
|
||||||
|
image: postgres
|
||||||
|
restart: unless-stopped
|
||||||
|
networks:
|
||||||
|
app-network:
|
||||||
|
aliases:
|
||||||
|
- db # app always connects to host "db"
|
||||||
|
environment:
|
||||||
|
POSTGRES_DB: ${POSTGRES_DB}
|
||||||
|
POSTGRES_USER: ${POSTGRES_USER}
|
||||||
|
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
|
||||||
|
volumes:
|
||||||
|
- postgres_data:/var/lib/postgresql
|
||||||
|
healthcheck:
|
||||||
|
test: [ "CMD-SHELL", "pg_isready -U $${POSTGRES_USER} -d $${POSTGRES_DB}" ]
|
||||||
|
interval: 5s
|
||||||
|
timeout: 5s
|
||||||
|
retries: 10
|
||||||
|
|
||||||
db:
|
db-mariadb:
|
||||||
|
profiles: [ "mariadb" ]
|
||||||
image: mariadb
|
image: mariadb
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
networks:
|
networks:
|
||||||
- app-network
|
app-network:
|
||||||
|
aliases:
|
||||||
|
- db
|
||||||
environment:
|
environment:
|
||||||
MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD}
|
MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD}
|
||||||
MYSQL_DATABASE: ${MYSQL_DATABASE}
|
MYSQL_DATABASE: ${MYSQL_DATABASE}
|
||||||
MYSQL_USER: ${MYSQL_USER_DATABASE}
|
MYSQL_USER: ${MYSQL_USER_DATABASE}
|
||||||
MYSQL_PASSWORD: ${MYSQL_PASSWORD_DATABASE}
|
MYSQL_PASSWORD: ${MYSQL_PASSWORD_DATABASE}
|
||||||
volumes:
|
volumes:
|
||||||
- db_data:/var/lib/mysql
|
- mariadb_data:/var/lib/mysql
|
||||||
|
healthcheck:
|
||||||
|
test: [ "CMD", "healthcheck.sh", "--connect", "--innodb_initialized" ]
|
||||||
|
interval: 5s
|
||||||
|
timeout: 5s
|
||||||
|
retries: 10
|
||||||
|
|
||||||
redis:
|
redis:
|
||||||
image: redis:alpine
|
image: redis:alpine
|
||||||
@@ -56,7 +91,7 @@ services:
|
|||||||
volumes:
|
volumes:
|
||||||
- redis_data:/data
|
- redis_data:/data
|
||||||
healthcheck:
|
healthcheck:
|
||||||
test: ["CMD", "redis-cli", "ping"]
|
test: [ "CMD", "redis-cli", "ping" ]
|
||||||
labels:
|
labels:
|
||||||
glance.parent: redis
|
glance.parent: redis
|
||||||
glance.name: Redis
|
glance.name: Redis
|
||||||
@@ -65,7 +100,8 @@ services:
|
|||||||
volumes:
|
volumes:
|
||||||
caddy_data:
|
caddy_data:
|
||||||
caddy_config:
|
caddy_config:
|
||||||
db_data:
|
postgres_data:
|
||||||
|
mariadb_data:
|
||||||
redis_data:
|
redis_data:
|
||||||
|
|
||||||
networks:
|
networks:
|
||||||
|
|||||||
Reference in new issue
Block a user