docker.recipes

Statamic

intermediate

Laravel-based flat-file CMS with optional database.

Overview

Statamic is a modern flat-file content management system built on the Laravel framework, designed to provide the developer experience of a traditional CMS without the overhead of database management. Originally created by Jack McDade and Jason Varga, Statamic stores content in human-readable YAML and Markdown files, making it version-controllable and easily portable while offering the full power of Laravel's ecosystem including Blade templates, Eloquent ORM, and extensive package support. This configuration pairs Statamic with Redis to create a high-performance content management stack that leverages Redis's sub-millisecond response times for caching, session storage, and queue management. Redis acts as Statamic's cache driver and session store, dramatically improving page load times and enabling efficient handling of concurrent users while maintaining the simplicity of flat-file content storage. This stack is ideal for agencies managing multiple client sites, developers building content-heavy applications, and organizations requiring version-controlled content workflows. The combination of Statamic's flat-file architecture with Redis caching provides the editorial flexibility of a headless CMS while maintaining traditional templating capabilities, making it perfect for marketing sites, documentation platforms, and custom web applications that need both performance and content management sophistication.

Key Features

  • Antlers templating engine with Laravel Blade integration for flexible content presentation
  • Git-based content workflow with YAML front-matter and Markdown body storage
  • Redis-powered caching system reducing database queries and improving response times
  • Collection-based content architecture supporting custom taxonomies and relationships
  • Live Preview functionality allowing real-time content editing without publishing
  • Multi-site management capabilities from a single Statamic installation
  • Asset pipeline with automatic image transformations and CDN integration
  • Form builder with spam protection and email notifications

Common Use Cases

  • 1Agency websites requiring client-friendly editing with developer-controlled deployment workflows
  • 2Marketing sites needing fast page loads with frequently updated campaign content
  • 3Documentation platforms where content versioning and collaboration are essential
  • 4E-commerce sites using Statamic's commerce add-on with Redis session management
  • 5Multi-language corporate websites leveraging Statamic's localization features
  • 6Portfolio sites for creative professionals requiring custom content structures
  • 7News and blog platforms needing editorial workflows and content scheduling

Prerequisites

  • Docker and Docker Compose installed with at least 1GB available RAM for optimal Redis performance
  • PHP and Composer knowledge for Statamic project creation and customization
  • Generated APP_KEY from Laravel (use php artisan key:generate command)
  • Port 8080 available on host system for Statamic web interface access
  • Basic understanding of YAML and Markdown for content structure management
  • Familiarity with Laravel concepts like middleware, service providers, and Eloquent models

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 statamic:
3 build: .
4 container_name: statamic
5 restart: unless-stopped
6 environment:
7 APP_KEY: ${APP_KEY}
8 REDIS_HOST: redis
9 volumes:
10 - statamic_storage:/var/www/html/storage
11 ports:
12 - "8080:80"
13 depends_on:
14 - redis
15 networks:
16 - statamic-network
17
18 redis:
19 image: redis:alpine
20 container_name: statamic-redis
21 volumes:
22 - redis_data:/data
23 networks:
24 - statamic-network
25
26volumes:
27 statamic_storage:
28 redis_data:
29
30networks:
31 statamic-network:
32 driver: bridge

.env Template

.env
1APP_KEY=base64:your-key-here

Usage Notes

  1. 1Docs: https://statamic.dev/
  2. 2Create project: composer create-project statamic/statamic
  3. 3Access control panel at /cp - create first user via CLI
  4. 4Flat-file by default, optional database for scaling
  5. 5Built on Laravel: Blade templates, Eloquent, full ecosystem
  6. 6Generate APP_KEY: php artisan key:generate

Individual Services(2 services)

Copy individual services to mix and match with your existing compose files.

statamic
statamic:
  build: .
  container_name: statamic
  restart: unless-stopped
  environment:
    APP_KEY: ${APP_KEY}
    REDIS_HOST: redis
  volumes:
    - statamic_storage:/var/www/html/storage
  ports:
    - "8080:80"
  depends_on:
    - redis
  networks:
    - statamic-network
redis
redis:
  image: redis:alpine
  container_name: statamic-redis
  volumes:
    - redis_data:/data
  networks:
    - statamic-network

Quick Start

terminal
1# 1. Create the compose file
2cat > docker-compose.yml << 'EOF'
3services:
4 statamic:
5 build: .
6 container_name: statamic
7 restart: unless-stopped
8 environment:
9 APP_KEY: ${APP_KEY}
10 REDIS_HOST: redis
11 volumes:
12 - statamic_storage:/var/www/html/storage
13 ports:
14 - "8080:80"
15 depends_on:
16 - redis
17 networks:
18 - statamic-network
19
20 redis:
21 image: redis:alpine
22 container_name: statamic-redis
23 volumes:
24 - redis_data:/data
25 networks:
26 - statamic-network
27
28volumes:
29 statamic_storage:
30 redis_data:
31
32networks:
33 statamic-network:
34 driver: bridge
35EOF
36
37# 2. Create the .env file
38cat > .env << 'EOF'
39APP_KEY=base64:your-key-here
40EOF
41
42# 3. Start the services
43docker compose up -d
44
45# 4. View logs
46docker compose logs -f

One-Liner

Run this command to download and set up the recipe in one step:

terminal
1curl -fsSL https://docker.recipes/api/recipes/statamic/run | bash

Troubleshooting

  • RuntimeException: No application encryption key specified: Generate APP_KEY using php artisan key:generate and add to environment variables
  • Statamic control panel shows 404 error: Create first user via php artisan make:user command and ensure /cp route is accessible
  • Redis connection refused error: Verify redis container is running and REDIS_HOST environment variable matches service name
  • File permission errors on content updates: Ensure statamic_storage volume has proper write permissions for web server user
  • Slow page loads despite Redis caching: Check Redis memory usage with docker exec statamic-redis redis-cli info memory and increase container resources if needed
  • Asset compilation failures: Verify Node.js dependencies are installed in Statamic container for frontend asset processing

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

Components

statamicredis

Tags

#statamic#laravel#flat-file#php

Category

CMS & Blogging
Ad Space