Craft CMS
Flexible content management with custom fields and matrix blocks.
Overview
Craft CMS is a flexible, developer-friendly content management system built on the Yii PHP framework, designed to give content creators and developers unprecedented control over digital experiences. Unlike rigid, template-based CMS platforms, Craft focuses on structured content with custom fields, matrix blocks for complex layouts, and element relationships that make content truly reusable across different contexts. This stack combines Craft CMS with PostgreSQL and Redis to create a robust, scalable content platform that can handle everything from simple blogs to complex multi-site enterprise deployments.
This configuration leverages PostgreSQL's advanced JSON support and ACID compliance to store Craft's flexible content structures while maintaining data integrity across complex field relationships and matrix blocks. Redis provides high-performance session storage and caching, dramatically improving response times for content queries and reducing database load during traffic spikes. The combination allows Craft to scale beyond basic MySQL setups while providing enterprise-grade reliability.
This stack is ideal for agencies managing multiple client sites, content-heavy applications requiring custom field architectures, and developers who need a CMS that adapts to their data model rather than forcing predetermined structures. The PostgreSQL foundation makes it particularly valuable for applications requiring complex content relationships, multi-language support, or integration with existing enterprise PostgreSQL infrastructure.
Key Features
- Matrix fields with PostgreSQL JSON storage for complex, nested content blocks
- Element relationship queries optimized by PostgreSQL's advanced indexing
- Redis-powered session management for improved multi-user editing performance
- Custom field types stored efficiently in PostgreSQL's flexible schema system
- Content localization using PostgreSQL's full-text search capabilities
- Redis caching for template rendering and database query optimization
- Asset transformation pipeline with metadata stored in PostgreSQL
- GraphQL API powered by PostgreSQL's JSON querying capabilities
Common Use Cases
- 1Multi-site agency platforms requiring shared content libraries and templates
- 2Enterprise content hubs with complex approval workflows and user permissions
- 3E-commerce sites needing flexible product catalogs with custom attributes
- 4News and publishing platforms with structured article relationships
- 5Portfolio websites requiring custom project categorization and filtering
- 6Corporate intranets with document management and employee directories
- 7Event management platforms with recurring schedules and venue relationships
Prerequisites
- Docker and Docker Compose installed with minimum 2GB RAM available
- Composer installed locally for initial Craft project creation
- Basic understanding of Craft CMS field types and templating with Twig
- Environment variables configured: DB_PASSWORD and SECURITY_KEY
- Port 8080 available for web access
- PostgreSQL knowledge helpful for advanced content queries and optimization
For development & testing. Review security settings, change default credentials, and test thoroughly before production use. See Terms
docker-compose.yml
docker-compose.yml
1services: 2 craft: 3 image: craftcms/cli:latest4 container_name: craft5 restart: unless-stopped6 environment: 7 CRAFT_DB_DRIVER: pgsql8 CRAFT_DB_SERVER: postgres9 CRAFT_DB_DATABASE: craft10 CRAFT_DB_USER: craft11 CRAFT_DB_PASSWORD: ${DB_PASSWORD}12 CRAFT_SECURITY_KEY: ${SECURITY_KEY}13 volumes: 14 - ./craft:/app15 ports: 16 - "8080:8080"17 depends_on: 18 - postgres19 - redis20 networks: 21 - craft-network2223 postgres: 24 image: postgres:16-alpine25 container_name: craft-postgres26 environment: 27 POSTGRES_USER: craft28 POSTGRES_PASSWORD: ${DB_PASSWORD}29 POSTGRES_DB: craft30 volumes: 31 - postgres_data:/var/lib/postgresql/data32 networks: 33 - craft-network3435 redis: 36 image: redis:alpine37 container_name: craft-redis38 networks: 39 - craft-network4041volumes: 42 postgres_data: 4344networks: 45 craft-network: 46 driver: bridge.env Template
.env
1DB_PASSWORD=changeme2SECURITY_KEY=your-security-keyUsage Notes
- 1Docs: https://craftcms.com/docs/
- 2Create project first: composer create-project craftcms/craft
- 3Access at http://localhost:8080, admin at /admin
- 4Matrix fields: nested, repeatable content blocks
- 5Element types: entries, categories, users, assets, globals
- 6Free Solo license; Pro adds GraphQL, multi-site features
Individual Services(3 services)
Copy individual services to mix and match with your existing compose files.
craft
craft:
image: craftcms/cli:latest
container_name: craft
restart: unless-stopped
environment:
CRAFT_DB_DRIVER: pgsql
CRAFT_DB_SERVER: postgres
CRAFT_DB_DATABASE: craft
CRAFT_DB_USER: craft
CRAFT_DB_PASSWORD: ${DB_PASSWORD}
CRAFT_SECURITY_KEY: ${SECURITY_KEY}
volumes:
- ./craft:/app
ports:
- "8080:8080"
depends_on:
- postgres
- redis
networks:
- craft-network
postgres
postgres:
image: postgres:16-alpine
container_name: craft-postgres
environment:
POSTGRES_USER: craft
POSTGRES_PASSWORD: ${DB_PASSWORD}
POSTGRES_DB: craft
volumes:
- postgres_data:/var/lib/postgresql/data
networks:
- craft-network
redis
redis:
image: redis:alpine
container_name: craft-redis
networks:
- craft-network
Quick Start
terminal
1# 1. Create the compose file2cat > docker-compose.yml << 'EOF'3services:4 craft:5 image: craftcms/cli:latest6 container_name: craft7 restart: unless-stopped8 environment:9 CRAFT_DB_DRIVER: pgsql10 CRAFT_DB_SERVER: postgres11 CRAFT_DB_DATABASE: craft12 CRAFT_DB_USER: craft13 CRAFT_DB_PASSWORD: ${DB_PASSWORD}14 CRAFT_SECURITY_KEY: ${SECURITY_KEY}15 volumes:16 - ./craft:/app17 ports:18 - "8080:8080"19 depends_on:20 - postgres21 - redis22 networks:23 - craft-network2425 postgres:26 image: postgres:16-alpine27 container_name: craft-postgres28 environment:29 POSTGRES_USER: craft30 POSTGRES_PASSWORD: ${DB_PASSWORD}31 POSTGRES_DB: craft32 volumes:33 - postgres_data:/var/lib/postgresql/data34 networks:35 - craft-network3637 redis:38 image: redis:alpine39 container_name: craft-redis40 networks:41 - craft-network4243volumes:44 postgres_data:4546networks:47 craft-network:48 driver: bridge49EOF5051# 2. Create the .env file52cat > .env << 'EOF'53DB_PASSWORD=changeme54SECURITY_KEY=your-security-key55EOF5657# 3. Start the services58docker compose up -d5960# 4. View logs61docker compose logs -fOne-Liner
Run this command to download and set up the recipe in one step:
terminal
1curl -fsSL https://docker.recipes/api/recipes/craft-cms/run | bashTroubleshooting
- Craft installation error 'could not connect to database': Verify DB_PASSWORD matches in both craft and postgres services
- Matrix field data not saving: Check PostgreSQL max_allowed_packet size and JSON field limits in database configuration
- Session timeout issues during content editing: Ensure Redis container is running and accessible on craft-network
- Asset uploads failing: Verify ./craft directory permissions and volume mount is writable by container user
- GraphQL queries timing out: Enable PostgreSQL query optimization and add appropriate indexes for content relationships
- Craft security key errors: Ensure SECURITY_KEY environment variable is set and consistent across container restarts
Community Notes
Loading...
Loading notes...
Download Recipe Kit
Get all files in a ready-to-deploy package
Includes docker-compose.yml, .env template, README, and license
Ad Space
Shortcuts: C CopyF FavoriteD Download