├── .gitignore ├── demo ├── site │ ├── Dockerfile │ ├── public │ │ └── newspaper.png │ └── templates │ │ └── index.html ├── docker-compose.yml └── README.md ├── Dockerfile ├── general.php └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | .idea 2 | *.iml 3 | -------------------------------------------------------------------------------- /demo/site/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM blackpepper/craftcms 2 | 3 | COPY public /var/www/web 4 | COPY templates /var/www/templates 5 | -------------------------------------------------------------------------------- /demo/site/public/newspaper.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BlackPepperSoftware/docker-craftcms/HEAD/demo/site/public/newspaper.png -------------------------------------------------------------------------------- /demo/docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: '2.4' 2 | 3 | services: 4 | 5 | site: 6 | build: site 7 | environment: 8 | DB_SERVER: database 9 | DB_USER: craft 10 | DB_PASSWORD: password 11 | DB_DATABASE: craft 12 | DB_DRIVER: mysql 13 | CRAFT_SITE_URL: http://localhost:8080/ 14 | links: 15 | - database 16 | ports: 17 | - 8080:80 18 | 19 | database: 20 | image: mariadb:10 21 | environment: 22 | MYSQL_ROOT_PASSWORD: password 23 | MYSQL_USER: craft 24 | MYSQL_PASSWORD: password 25 | MYSQL_DATABASE: craft 26 | ports: 27 | - 3306:3306 28 | -------------------------------------------------------------------------------- /demo/README.md: -------------------------------------------------------------------------------- 1 | # docker-craftcms demo 2 | 3 | This project demonstrates how to use `blackpepper/craftcms` with Docker Compose to run and customise Craft CMS. 4 | 5 | ## Running 6 | 7 | 1. `docker-compose up` 8 | 1. Visit http://localhost:8080/admin 9 | 1. [Run the Craft installer](https://docs.craftcms.com/v3/installation.html#step-6-run-the-setup-wizard) 10 | 1. View the site at http://localhost:8080/ 11 | 12 | ## Customisations 13 | 14 | The site's [Dockerfile](site/Dockerfile) overlays the following directories on top of the standard Craft installation: 15 | 16 | * [public](site/public) — web assets 17 | * [templates](site/templates) — Craft site templates 18 | 19 | In this demonstration we add a [newspaper.png](site/public/newspaper.png) web asset and reference it from the 20 | [index.html](site/templates/index.html) index template. You can see this image by visiting the site at 21 | http://localhost:8080/. -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM php:7.3-apache 2 | 3 | LABEL maintainer = "Mark Hobson " 4 | 5 | # Set craft installer and CMS versions 6 | ARG CMS_VERSION=3.6.10 7 | ARG CRAFT_VERSION=1.1.2 8 | 9 | WORKDIR /var/www 10 | 11 | RUN apt-get update \ 12 | && apt-get install -yq unzip libmcrypt-dev libmagickwand-dev libzip-dev wget mariadb-client-10.3 \ 13 | && docker-php-ext-install zip pdo_mysql \ 14 | && pecl install imagick mcrypt-1.0.2 \ 15 | && docker-php-ext-enable imagick mcrypt \ 16 | && rm -rf /var/lib/apt/lists/* 17 | 18 | # Enable .htaccess 19 | RUN a2enmod rewrite 20 | 21 | # Download and configure Craft 22 | RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer \ 23 | && rm -r /var/www/* \ 24 | && composer create-project craftcms/craft /var/www $CRAFT_VERSION \ 25 | && composer require -W -d /var/www craftcms/cms:$CMS_VERSION \ 26 | && chmod +x /var/www/craft \ 27 | && sed -i "s/html/web/" /etc/apache2/sites-available/000-default.conf \ 28 | && chown -R www-data:www-data /var/www/* /var/www/.[^.]* \ 29 | && echo "php_value memory_limit 256M" >> /var/www/web/.htaccess \ 30 | && service apache2 restart 31 | 32 | # Move our general config file into config directory 33 | ADD --chown=www-data:www-data general.php /var/www/config/ 34 | 35 | USER www-data 36 | 37 | # Set environment variables 38 | RUN truncate -s0 /var/www/.env 39 | ENV DB_DRIVER=mysql \ 40 | DB_SERVER=localhost \ 41 | DB_PORT=3306 \ 42 | DB_USER=root \ 43 | DB_PASSWORD="" \ 44 | DB_TABLE_PREFIX=craft \ 45 | DB_DATABASE="" 46 | 47 | # Set up security key 48 | RUN /var/www/craft setup/security-key 49 | 50 | USER root 51 | -------------------------------------------------------------------------------- /general.php: -------------------------------------------------------------------------------- 1 | [ 14 | 'allowUpdates' => (getenv('CRAFT_ALLOW_UPDATES') ?: 'true') === 'true', 15 | 16 | 'cooldownDuration' => (int) (getenv('CRAFT_COOLDOWN_DURATION') ?: '300'), 17 | 18 | // Control Panel trigger word 19 | 'cpTrigger' => 'admin', 20 | 21 | // Default Week Start Day (0 = Sunday, 1 = Monday...) 22 | 'defaultWeekStartDay' => 0, 23 | 24 | // Dev Mode (see https://craftcms.com/support/dev-mode) 25 | 'devMode' => (getenv('CRAFT_DEV_MODE') ?: 'true') === 'true', 26 | 27 | // Enable CSRF Protection (recommended) 28 | 'enableCsrfProtection' => true, 29 | 30 | 'enableTemplateCaching' => (getenv('CRAFT_ENABLE_TEMPLATE_CACHING') ?: 'true') === 'true', 31 | 32 | 'maxUploadFileSize' => (int) (getenv('CRAFT_MAX_UPLOAD_FILE_SIZE') ?: '16777216'), 33 | 34 | // Whether generated URLs should omit "index.php" 35 | 'omitScriptNameInUrls' => (getenv('CRAFT_OMIT_SCRIPT_NAME_IN_URLS') ?: 'false') === 'true', 36 | 37 | 'phpMaxMemoryLimit' => getenv('CRAFT_PHP_MAX_MEMORY_LIMIT') ?: '', 38 | 39 | // The secure key Craft will use for hashing and encrypting data 40 | 'securityKey' => getenv('SECURITY_KEY'), 41 | 42 | // Base site URL 43 | 'siteUrl' => getenv('CRAFT_SITE_URL') ?: null, 44 | 45 | 'transformGifs' => (getenv('CRAFT_TRANSFORM_GIFS') ?: 'true') === 'true', 46 | 47 | 'useCompressedJs' => (getenv('CRAFT_USE_COMPRESSED_JS') ?: 'true') === 'true', 48 | 49 | 'userSessionDuration' => (int) (getenv('CRAFT_USER_SESSION_DURATION') ?: '3600'), 50 | 51 | 'sendPoweredByHeader' => (getenv('CRAFT_SEND_POWERED_BY_HEADER') ?: 'true') === 'true' 52 | ], 53 | ]; 54 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # docker-craftcms 2 | 3 | Docker image for [Craft CMS](https://craftcms.com/). Available on Docker Hub as [blackpepper/craftcms](https://hub.docker.com/r/blackpepper/craftcms/). 4 | 5 | ## Usage 6 | 7 | First start a MySQL database for Craft: 8 | 9 | ```Shell 10 | docker run --name database \ 11 | -e MYSQL_ROOT_PASSWORD=password \ 12 | -e MYSQL_USER=craft \ 13 | -e MYSQL_PASSWORD=password \ 14 | -e MYSQL_DATABASE=craft \ 15 | -d mariadb:10 16 | ``` 17 | 18 | Then run Craft: 19 | 20 | ```Shell 21 | docker run --name craftcms \ 22 | -e DB_SERVER=database \ 23 | -e DB_USER=craft \ 24 | -e DB_PASSWORD=password \ 25 | -e DB_DATABASE=craft \ 26 | -e DB_DRIVER=mysql \ 27 | --link database \ 28 | -p 8080:80 \ 29 | -d blackpepper/craftcms 30 | ``` 31 | 32 | Visit http://localhost:8080/admin to create a site. 33 | 34 | ### Docker Compose 35 | 36 | Alternatively use Docker Compose: 37 | 38 | ```YAML 39 | version: '2.4' 40 | 41 | services: 42 | 43 | craftcms: 44 | image: blackpepper/craftcms 45 | environment: 46 | DB_SERVER: database 47 | DB_USER: craft 48 | DB_PASSWORD: password 49 | DB_DATABASE: craft 50 | DB_DRIVER: mysql 51 | links: 52 | - database 53 | ports: 54 | - 8080:80 55 | 56 | database: 57 | image: mariadb:10 58 | environment: 59 | MYSQL_ROOT_PASSWORD: password 60 | MYSQL_USER: craft 61 | MYSQL_PASSWORD: password 62 | MYSQL_DATABASE: craft 63 | ports: 64 | - 3306:3306 65 | ``` 66 | 67 | See the [demo](demo) project to see this in action. 68 | 69 | ## Tags 70 | 71 | The following Docker image tags are available: 72 | 73 | Craft Version | Tag 74 | --------------|---- 75 | 3 | [`latest`](https://github.com/BlackPepperSoftware/docker-craftcms/blob/master/Dockerfile) 76 | 2 | [`2`](https://github.com/BlackPepperSoftware/docker-craftcms/blob/2/Dockerfile) 77 | 78 | ## Configuration 79 | 80 | Use the following environment variables to configure Craft at runtime: 81 | 82 | Variable Name | Craft Setting 83 | --------------|-------------- 84 | `DB_DSN` | [`mysql:host=localhost;port=3306;dbname=craft`](https://docs.craftcms.com/v3/config/db-settings.html#dsn) 85 | `DB_USER` | [`user`](https://docs.craftcms.com/v3/config/db-settings.html#user) 86 | `DB_PASSWORD` | [`password`](https://docs.craftcms.com/v3/config/db-settings.html#password) 87 | `CRAFT_ALLOW_UPDATES` | [`allowUpdates`](https://docs.craftcms.com/v3/config/config-settings.html#allowupdates) 88 | `CRAFT_COOLDOWN_DURATION` | [`cooldownDuration`](https://docs.craftcms.com/v3/config/config-settings.html#cooldownduration) 89 | `CRAFT_DEV_MODE` | [`devMode`](https://docs.craftcms.com/v3/config/config-settings.html#devmode) 90 | `CRAFT_ENABLE_TEMPLATE_CACHING` | [`enableTemplateCaching`](https://docs.craftcms.com/v3/config/config-settings.html#enabletemplatecaching) 91 | `CRAFT_MAX_UPLOAD_FILE_SIZE` | [`maxUploadFileSize`](https://docs.craftcms.com/v3/config/config-settings.html#maxuploadfilesize) 92 | `CRAFT_OMIT_SCRIPT_NAME_IN_URLS` | [`omitScriptNameInUrls`](https://docs.craftcms.com/v3/config/config-settings.html#omitscriptnameinurls) 93 | `CRAFT_PHP_MAX_MEMORY_LIMIT` | [`phpMaxMemoryLimit`](https://docs.craftcms.com/v3/config/config-settings.html#phpmaxmemorylimit) 94 | `CRAFT_SITE_URL` | [`siteUrl`](https://docs.craftcms.com/v3/config/config-settings.html#siteurl) 95 | `CRAFT_TRANSFORM_GIFS` | [`transformGifs`](https://docs.craftcms.com/v3/config/config-settings.html#transformgifs) 96 | `CRAFT_USE_COMPRESSED_JS` | [`useCompressedJs`](https://docs.craftcms.com/v3/config/config-settings.html#usecompressedjs) 97 | `CRAFT_USER_SESSION_DURATION` | [`userSessionDuration`](https://docs.craftcms.com/v3/config/config-settings.html#usersessionduration) 98 | 99 | ## Customisation 100 | 101 | Use as a base image to customise Craft templates and public assets: 102 | 103 | ```Dockerfile 104 | FROM blackpepper/craftcms 105 | 106 | COPY public /var/www/web 107 | COPY templates /var/www/templates 108 | ``` 109 | 110 | ## Version 111 | 112 | This image aspires to track the latest build of Craft CMS 3. Use the following build arguments to customise the Craft CMS version at build time: 113 | 114 | Argument | Description 115 | ----------------|---------------------------------------------------------- 116 | `CMS_VERSION` | The version of Craft CMS to use, e.g. `3.6.5.1` 117 | `CRAFT_VERSION` | The version of the Craft CMS starter to use, e.g. `1.1.2` 118 | 119 | For example, to build an image for Craft CMS version 3.6.5.1: 120 | 121 | ```Shell 122 | docker build --build-arg CMS_VERSION=3.6.5.1 --build-arg CRAFT_VERSION=1.1.2 . 123 | ``` 124 | -------------------------------------------------------------------------------- /demo/site/templates/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Welcome to Craft CMS 7 | 8 | 9 | 175 | 176 | 177 |
178 | 227 |
228 | 229 | --------------------------------------------------------------------------------