Initial Base
This commit is contained in:
97
docker-compose.yml
Normal file
97
docker-compose.yml
Normal file
@@ -0,0 +1,97 @@
|
||||
## Docker Compose stack for Symfony app
|
||||
## - php: PHP-FPM container that runs Symfony and Composer
|
||||
## - nginx: Frontend web server proxying PHP to php-fpm
|
||||
## - db: Postgres database for Doctrine
|
||||
## - pgadmin: Optional UI to inspect the database
|
||||
services:
|
||||
php:
|
||||
# Build multi-stage image defined in docker/php/Dockerfile
|
||||
build:
|
||||
context: .
|
||||
dockerfile: docker/php/Dockerfile
|
||||
target: dev # change to "prod" for production build
|
||||
args:
|
||||
- APP_ENV=dev
|
||||
container_name: app-php
|
||||
restart: unless-stopped
|
||||
environment:
|
||||
# App base URL (used by some tools)
|
||||
DEFAULT_URI: ${DEFAULT_URI:-http://localhost:8000}
|
||||
APP_ENV: ${APP_ENV:-dev}
|
||||
APP_SECRET: ${APP_SECRET:-change_me}
|
||||
# Doctrine DATABASE_URL consumed by Symfony/Doctrine
|
||||
DATABASE_URL: ${DATABASE_URL:-postgresql://${POSTGRES_USER:-symfony}:${POSTGRES_PASSWORD:-symfony}@db:5432/${POSTGRES_DB:-symfony}?serverVersion=16&charset=utf8}
|
||||
volumes:
|
||||
# Mount only source and config; vendors are installed in-container
|
||||
- ./bin:/var/www/html/bin
|
||||
- ./config:/var/www/html/config
|
||||
- ./migrations:/var/www/html/migrations
|
||||
- ./public:/var/www/html/public
|
||||
- ./src:/var/www/html/src
|
||||
- ./var:/var/www/html/var
|
||||
# Keep composer manifests on host for version control
|
||||
- ./composer.json:/var/www/html/composer.json
|
||||
- ./composer.lock:/var/www/html/composer.lock
|
||||
- ./symfony.lock:/var/www/html/symfony.lock
|
||||
# Speed up composer installs by caching download artifacts
|
||||
- composer_cache:/tmp/composer
|
||||
healthcheck:
|
||||
test: ["CMD-SHELL", "php -v || exit 1"]
|
||||
interval: 10s
|
||||
timeout: 3s
|
||||
retries: 5
|
||||
depends_on:
|
||||
- db
|
||||
nginx:
|
||||
image: nginx:alpine
|
||||
container_name: nginx
|
||||
ports:
|
||||
- "8000:80"
|
||||
volumes:
|
||||
# Serve built assets and front controller from Symfony public dir
|
||||
- ./public:/var/www/html/public
|
||||
# Custom vhost with PHP FastCGI proxy
|
||||
- ./docker/nginx/default.conf:/etc/nginx/conf.d/default.conf
|
||||
depends_on:
|
||||
- php
|
||||
healthcheck:
|
||||
test: ["CMD", "curl", "-f", "http://localhost:80/healthz"]
|
||||
interval: 10s
|
||||
timeout: 3s
|
||||
retries: 5
|
||||
|
||||
db:
|
||||
image: postgres:16-alpine
|
||||
container_name: postgres
|
||||
restart: unless-stopped
|
||||
environment:
|
||||
POSTGRES_DB: ${POSTGRES_DB:-symfony}
|
||||
POSTGRES_USER: ${POSTGRES_USER:-symfony}
|
||||
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-symfony}
|
||||
ports:
|
||||
- 5432:5432
|
||||
volumes:
|
||||
- db_data:/var/lib/postgresql/data
|
||||
healthcheck:
|
||||
test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER:-symfony} -d ${POSTGRES_DB:-symfony}"]
|
||||
interval: 10s
|
||||
timeout: 5s
|
||||
retries: 10
|
||||
|
||||
pgadmin:
|
||||
image: dpage/pgadmin4
|
||||
container_name: pgadmin
|
||||
environment:
|
||||
PGADMIN_DEFAULT_EMAIL: ${PGADMIN_DEFAULT_EMAIL:-admin@example.com}
|
||||
PGADMIN_DEFAULT_PASSWORD: ${PGADMIN_DEFAULT_PASSWORD:-password}
|
||||
ports:
|
||||
- "8081:80"
|
||||
volumes:
|
||||
- pgadmin_data:/var/lib/pgadmin
|
||||
depends_on:
|
||||
- db
|
||||
|
||||
volumes:
|
||||
db_data:
|
||||
composer_cache:
|
||||
pgadmin_data:
|
||||
Reference in New Issue
Block a user