Grav CMS: Lightweight Flat-File CMS

06-12-2024 - 1 minute, 47 seconds -
documentation grav docker cms

Introduction

Grav is a fast, modern, and flexible flat-file content management system (CMS) that eliminates the need for a traditional database. It is ideal for users seeking a lightweight and modular approach to building websites. This guide walks you through deploying Grav using Docker and configuring it for a simple and efficient content workflow.


Prerequisites

  1. Docker and Docker Compose installed on your server.
  2. A basic understanding of flat-file CMS and Markdown.
  3. Credentials for accessing the Grav Admin Panel.

Steps to Set Up Grav

1. Download the Docker Compose File

Use the following docker-compose.yml file for deploying Grav:

services:
  grav:
    image: linuxserver/grav:latest
    container_name: grav
    environment:
      - TZ=Etc/UTC
    volumes:
      - ./data:/config
    ports:
      - 3018:80
    restart: unless-stopped

2. Start the Grav Service

Run the following commands to download the necessary images and start Grav:

docker-compose pull
docker-compose up -d

This will start Grav on port 3018. Access it via http://localhost:3018.

3. Access the Admin Panel

  1. Navigate to the admin interface:
    http://localhost:3018/admin
  2. Log in with the admin credentials you configured. Replace placeholders in your environment file as needed.

4. Mount External Data for Configuration

Use the following volume setup to persist Grav data:

volumes:
  - ./data:/config

This ensures all content and configuration changes are preserved across container restarts.


Extended Configuration

Changing Content Locations

If you want to host your Grav content on a custom directory (e.g., /var/www/html):

volumes:
  - ./html:/var/www/html/

Make sure this path matches your server’s directory structure.

Accessing System Configuration

Navigate to the Grav system configuration page:

http://localhost:3018/admin/config/system

Here you can adjust caching, file uploads, and other system-level settings.

Managing Posts

Create and edit posts directly via the admin panel or by uploading Markdown files to the /pages directory:

http://localhost:3018/posts/post-2

Updating Grav

To update Grav, pull the latest Docker image:

docker-compose pull
docker-compose up -d

Resources and References


Conclusion

This guide provides a complete setup for deploying Grav CMS using Docker. By leveraging Docker volumes and the Grav Admin Panel, you can quickly configure and manage your flat-file CMS environment. Grav’s lightweight and modular nature makes it an excellent choice for dynamic yet resource-efficient websites.