{"id":19305170,"url":"https://github.com/hussainweb/docker-drupal-base","last_synced_at":"2026-05-09T07:40:45.895Z","repository":{"id":47697769,"uuid":"229133335","full_name":"hussainweb/docker-drupal-base","owner":"hussainweb","description":"Docker image to run your Drupal projects","archived":false,"fork":false,"pushed_at":"2024-06-24T12:02:54.000Z","size":63,"stargazers_count":1,"open_issues_count":1,"forks_count":2,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-01-06T00:23:10.104Z","etag":null,"topics":["apache","docker","drupal","php"],"latest_commit_sha":null,"homepage":"https://hub.docker.com/r/hussainweb/drupal-base","language":"Dockerfile","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hussainweb.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-12-19T20:27:49.000Z","updated_at":"2024-06-24T12:02:51.000Z","dependencies_parsed_at":"2023-11-29T21:29:54.092Z","dependency_job_id":"dfe592d1-ab3a-4909-bd0b-fcdf3fbf1e7d","html_url":"https://github.com/hussainweb/docker-drupal-base","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hussainweb%2Fdocker-drupal-base","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hussainweb%2Fdocker-drupal-base/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hussainweb%2Fdocker-drupal-base/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hussainweb%2Fdocker-drupal-base/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hussainweb","download_url":"https://codeload.github.com/hussainweb/docker-drupal-base/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240404931,"owners_count":19796097,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["apache","docker","drupal","php"],"created_at":"2024-11-09T23:35:13.039Z","updated_at":"2026-05-09T07:40:45.888Z","avatar_url":"https://github.com/hussainweb.png","language":"Dockerfile","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Drupal Base Image for Docker\n\nThis image provides a basic runtime for Drupal projects. It's designed for CI but is also suitable for local development environments using `docker-compose`. This image is similar to the [official Drupal image](https://hub.docker.com/_/drupal) but does not include the Drupal core files, allowing you to mount your own codebase.\n\n## Image Variants\n\nThis repository contains two main variants of the Drupal base image:\n\n- `apache-bookworm`: Based on Debian Bookworm with Apache.\n- `fpm-alpine`: Based on Alpine Linux with PHP-FPM.\n- `frankenphp-trixie`: Based on Debian Trixie with FrankenPHP (experimental).\n\nChoose the image that best fits your needs. The Apache image is a good choice for a simple, all-in-one container, while the FPM image is ideal for use with a separate web server like Nginx.\n\n## Supported PHP Versions\n\nThis image supports the following PHP versions:\n\n- PHP 8.2\n- PHP 8.3\n- PHP 8.4\n- PHP 8.5 (latest)\n\nEach version is available in all variants (apache-bookworm, apache-trixie, fpm-alpine, frankenphp-trixie).\n\n### Available Tags\n\n- `php8.5`, `latest` - PHP 8.5 with Apache on Debian Trixie\n- `php8.5-apache-trixie` - PHP 8.5 with Apache on Debian Trixie\n- `php8.5-apache-bookworm` - PHP 8.5 with Apache on Debian Bookworm\n- `php8.5-alpine`, `php8.5-fpm-alpine`, `latest-alpine` - PHP 8.5 FPM on Alpine Linux\n- `php8.4`, `php8.3`, `php8.2` - Older PHP versions with Apache on Debian Trixie\n- `php8.4-alpine`, `php8.3-alpine`, `php8.2-alpine` - Older PHP versions FPM on Alpine Linux\n- `php8.5-frankenphp-trixie`, `php8.4-frankenphp-trixie` - FrankenPHP on Debian Trixie\n\nAll images support both `linux/amd64` and `linux/arm64` architectures.\n\n## Usage\n\n### Apache\n\nThe Apache image is straightforward to use. Mount your Drupal codebase to `/var/www/html` in the container.\n\nHere is an example `docker-compose.yml` snippet:\n\n```yaml\nservices:\n  drupal:\n    image: hussainweb/drupal-base:php8.5\n    volumes:\n      - ./path/to/your/drupal/root:/var/www/html\n    ports:\n      - \"8080:80\"\n    restart: always\n```\n\n### FPM-Alpine\n\nThe FPM-Alpine image requires a separate web server. The following example uses Nginx.\n\nHere is an example `docker-compose.yml` snippet:\n\n```yaml\nservices:\n  drupal:\n    image: hussainweb/drupal-base:php8.5-alpine\n    volumes:\n      - ./path/to/your/drupal/root:/var/www/html\n    restart: always\n\n  nginx:\n    image: nginx:latest\n    ports:\n      - \"8080:80\"\n    volumes:\n      - ./path/to/your/drupal/root:/var/www/html\n      - ./nginx.conf:/etc/nginx/conf.d/default.conf\n    depends_on:\n      - drupal\n    restart: always\n```\n\n#### Nginx Configuration\n\nYou will need an `nginx.conf` file in your project root. Here is a production-ready example:\n\n```nginx\nserver {\n    listen 80 default_server;\n    server_name localhost _;\n    root /var/www/html/web;\n    index index.php index.html index.htm;\n\n    # Security headers\n    add_header X-Frame-Options \"SAMEORIGIN\" always;\n    add_header X-Content-Type-Options \"nosniff\" always;\n    add_header X-XSS-Protection \"1; mode=block\" always;\n    add_header Referrer-Policy \"no-referrer-when-downgrade\" always;\n\n    # Deny access to hidden files\n    location ~ /\\. {\n        deny all;\n        access_log off;\n        log_not_found off;\n    }\n\n    # Deny access to sensitive files\n    location ~* \\.(engine|inc|info|install|make|module|profile|test|po|sh|.*sql|theme|tpl(\\.php)?|xtmpl|svn|git|bzr|hg|CVS)(~|\\.sw[op]|\\.bak|\\.orig|\\.save)?$ {\n        deny all;\n    }\n\n    # Deny access to backup files\n    location ~ ~$ {\n        deny all;\n        access_log off;\n        log_not_found off;\n    }\n\n    # Theme and frontend assets\n    location ~* ^/(themes|core)/.*\\.(css|js|svg|png|jpg|jpeg|gif|ico|woff|woff2|ttf|eot)$ {\n        access_log off;\n    }\n\n    # Handle PHP files\n    location ~ \\.php$ {\n        try_files $uri =404;\n        fastcgi_split_path_info ^(.+\\.php)(/.+)$;\n        fastcgi_pass drupal:9000;\n        fastcgi_index index.php;\n        include fastcgi_params;\n        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;\n        fastcgi_param PATH_INFO $fastcgi_path_info;\n        fastcgi_param HTTP_PROXY \"\";\n        fastcgi_read_timeout 300;\n    }\n\n    # Health check endpoint\n    location /health {\n        access_log off;\n        return 200 \"healthy\\n\";\n        add_header Content-Type text/plain;\n    }\n\n    # Handle Drupal clean URLs\n    location / {\n        try_files $uri $uri/ /index.php?$query_string;\n    }\n\n    # Drupal aggregate CSS/JS paths (multisite-safe)\n    # Required since Drupal 10.1 as aggregate files are created on first request.\n    # See https://www.drupal.org/node/3301716\n    location ~* ^/sites/[^/]+/files/(css|js)/ {\n        try_files $uri /index.php?$query_string;\n        expires 1y;\n        add_header Cache-Control \"public, immutable\";\n        access_log off;\n    }\n\n    # Image styles (must go through Drupal if missing)\n    location ~* ^/sites/[^/]+/files/styles/ {\n        try_files $uri /index.php?$query_string;\n        expires 1y;\n        add_header Cache-Control \"public, immutable\";\n        access_log off;\n    }\n\n    # All other static assets\n    location ~* \\.(png|jpg|jpeg|gif|ico|svg|woff|woff2|ttf|eot)$ {\n        expires 1y;\n        add_header Cache-Control \"public, immutable\";\n        access_log off;\n    }\n\n    # Cache HTML files\n    location ~* \\.html$ {\n        expires 1h;\n        add_header Cache-Control \"public\";\n    }\n\n    # Deny access to sensitive directories\n    location ~* ^/(sites/.*/private/|sites/.*/tmp/) {\n        deny all;\n    }\n}\n```\n\n**Note:** Adjust `root` path based on your Drupal installation structure. If your Drupal files are directly in the mounted directory, use `/var/www/html`. If you have a `web` subdirectory (as in Composer-based installs), use `/var/www/html/web`.\n\n**Important:** For image style generation and CSS/JS aggregation to work properly, the Drupal source code must be available in **both** the Nginx and PHP-FPM containers. When Nginx receives a request for a missing image style or aggregate file, it passes the request to Drupal, which generates the file. Nginx then needs filesystem access to serve the generated file on subsequent requests.\n\n- **Using volumes:** Mount your Drupal codebase to both containers (as shown in the docker-compose example above).\n- **Using a custom Dockerfile:** If you copy files into the PHP-FPM image instead of mounting them, you must also build a custom Nginx image that contains the same static files (themes, modules, and the `sites/*/files` directory if pre-populated).\n\n### FrankenPHP\n\nThe FrankenPHP image uses Caddy as the web server with FrankenPHP for PHP execution. It is configured to serve the Drupal site from `/app/web`.\n\nHere is an example `docker-compose.yml` snippet:\n\n```yaml\nservices:\n  drupal:\n    image: hussainweb/drupal-base:php8.5-frankenphp-trixie\n    volumes:\n      - ./path/to/your/drupal/root:/app\n    ports:\n      - \"8080:80\"\n    restart: always\n```\n\n**Note:** Mount your entire Drupal project root to `/app`. The image expects Drupal's `index.php` to be in `/app/web`.\n\n#### Default Caddyfile\n\nThe image includes a default Caddyfile optimized for Drupal:\n\n```caddyfile\n{\n    frankenphp\n    order php_server before file_server\n}\n\n:80 {\n    encode zstd gzip\n    root * /app/web\n    php_server\n    file_server\n}\n```\n\n#### Custom Caddyfile\n\nTo customize the Caddy configuration, mount your own Caddyfile:\n\n```yaml\nservices:\n  drupal:\n    image: hussainweb/drupal-base:php8.5-frankenphp-trixie\n    volumes:\n      - ./path/to/your/drupal/root:/app\n      - ./Caddyfile:/etc/frankenphp/Caddyfile\n    ports:\n      - \"8080:80\"\n    restart: always\n```\n\nHere is an example custom Caddyfile with additional security and caching:\n\n```caddyfile\n{\n    frankenphp\n    order php_server before file_server\n}\n\n:80 {\n    encode zstd gzip\n    root * /app/web\n\n    # Security: deny access to sensitive files\n    @sensitive {\n        path *.engine *.inc *.install *.module *.profile *.po *.sh *.sql *.theme *.twig *.xtmpl *.yml *.yaml\n        path /composer.json /composer.lock /web.config\n        path /.* /vendor/*\n    }\n    respond @sensitive 403\n\n    # Cache static assets\n    @static {\n        path *.css *.js *.png *.jpg *.jpeg *.gif *.ico *.svg *.woff *.woff2 *.ttf *.eot\n    }\n    header @static Cache-Control \"public, max-age=31536000, immutable\"\n\n    php_server\n    file_server\n}\n```\n\n#### Enabling HTTPS with FrankenPHP\n\nFrankenPHP supports automatic HTTPS. To enable it, update your Caddyfile:\n\n```caddyfile\n{\n    frankenphp\n    order php_server before file_server\n}\n\nyour-domain.com {\n    encode zstd gzip\n    root * /app/web\n    php_server\n    file_server\n}\n```\n\nAnd expose port 443 in your `docker-compose.yml`:\n\n```yaml\nservices:\n  drupal:\n    image: hussainweb/drupal-base:php8.5-frankenphp-trixie\n    volumes:\n      - ./path/to/your/drupal/root:/app\n      - ./Caddyfile:/etc/frankenphp/Caddyfile\n      - caddy_data:/data\n    ports:\n      - \"80:80\"\n      - \"443:443\"\n    restart: always\n\nvolumes:\n  caddy_data:\n```\n\nCaddy will automatically obtain and renew TLS certificates from Let's Encrypt.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhussainweb%2Fdocker-drupal-base","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhussainweb%2Fdocker-drupal-base","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhussainweb%2Fdocker-drupal-base/lists"}