diff --git a/.env.default b/.env.default
index 3e2131e00..209a57e28 100644
--- a/.env.default
+++ b/.env.default
@@ -1,13 +1,16 @@
COMPOSE_FILE=./docker/docker-compose.yml:./docker/docker-compose.override.yml
COMPOSE_PROJECT_NAME=projectname
PROFILE_NAME=sdd
-MODULES= default_content
-THEME_NAME=projectname_theme
-SITE_NAME=Site name
+MODULES=default_content
+THEME_NAME=
+SITE_NAME=Example
SITE_MAIL=admin@example.com
PROJECT_INSTALL=
-PHP_VERSION=7
IMAGE_PHP=skilldlabs/php:72-fpm
+IMAGE_NGINX=skilldlabs/nginx:1.14.1
IMAGE_FRONT=skilldlabs/frontend:zen
+MAIN_DOMAIN_NAME=docker.localhost
DB_URL=sqlite:///dev/shm/d8.sqlite
-MYSQL_BASE_PATH=/dev/shm
+#DB_URL=mysql://d8:d8@mysql/d8
+DB_DATA_DIR=/dev/shm
+#DB_DATA_DIR=../mysql #Please include path to this folder to your .gitignore
diff --git a/.gitignore b/.gitignore
index 94e53cec4..8f80c9921 100644
--- a/.gitignore
+++ b/.gitignore
@@ -5,24 +5,14 @@ nbproject
.settings
.project
config/sync/.htaccess
-config/sync/README.txt
docker/docker-compose.override.yml
node_modules
vendor
-web/.csslintrc
-web/.editorconfig
-web/.eslintignore
-web/.eslintrc.json
-web/.gitattributes
-web/.htaccess
-web/autoload.php
+web/*.*
web/core/
-web/index.php
web/libraries/
web/modules/contrib/
web/profiles/contrib/config_installer/
-web/robots.txt
web/sites/
web/themes/contrib/
-web/update.php
-web/web.config
+mysql/
diff --git a/Makefile b/Makefile
index 0f2a44b18..5cdf538a2 100644
--- a/Makefile
+++ b/Makefile
@@ -1,14 +1,19 @@
# Add utility functions and scripts to the container
include scripts/makefile/*.mk
-.PHONY: all up down cex cim prepare install si exec info phpcs phpcbf drush
+.PHONY: all provision si exec exec0 down clean dev info phpcs phpcbf drush check
+.DEFAULT_GOAL := help
-# Read project name from .env file
+# https://stackoverflow.com/a/6273809/1826109
+%:
+ @:
+
+# Prepare enviroment variables from defaults.
$(shell false | cp -i \.env.default \.env 2>/dev/null)
$(shell false | cp -i \.\/docker\/docker-compose\.override\.yml\.default \.\/docker\/docker-compose\.override\.yml 2>/dev/null)
include .env
-# Get local values only once.
+# Get user/group id to manage permissions between host and containers.
LOCAL_UID := $(shell id -u)
LOCAL_GID := $(shell id -g)
@@ -16,202 +21,129 @@ LOCAL_GID := $(shell id -g)
CUID ?= $(LOCAL_UID)
CGID ?= $(LOCAL_GID)
+# Define network name.
COMPOSE_NET_NAME := $(COMPOSE_PROJECT_NAME)_front
-MYSQL_DATADIR := $(MYSQL_BASE_PATH)/$(COMPOSE_PROJECT_NAME)_mysql
-
-php = docker-compose exec -T --user $(CUID):$(CGID) php time ${1}
-php-0 = docker-compose exec -T php time ${1}
-front = docker run --rm -u $(CUID):$(CGID) -v $(shell pwd)/web/themes/$(THEME_NAME):/work $(IMAGE_FRONT) ${1}
+# Define mysql storage folder.
+MYSQL_DATADIR := $(DB_DATA_DIR)/$(COMPOSE_PROJECT_NAME)_mysql
+
+# Execute php container as regular user.
+php = docker-compose exec -T --user $(CUID):$(CGID) php ${1}
+# Execute php container as root user.
+php-0 = docker-compose exec -T php ${1}
+# Function for code sniffer images.
+phpcsexec = docker run --rm \
+ -v $(shell pwd)/web/profiles/$(PROFILE_NAME):/work/profile \
+ -v $(shell pwd)/web/modules/custom:/work/modules \
+ -v $(shell pwd)/web/themes/custom:/work/themes \
+ skilldlabs/docker-phpcs-drupal ${1} -s --colors \
+ --standard=Drupal,DrupalPractice \
+ --extensions=php,module,inc,install,profile,theme,yml,txt,md,js \
+ --ignore=*.css,libraries/*,dist/*,styleguide/* \
+ .
## Full site install from the scratch
-all: | include prepare install si info
+all: | provision composer si info
-include:
+## Provision enviroment
+provision:
+# Check if enviroment variables has been defined.
ifeq ($(strip $(COMPOSE_PROJECT_NAME)),projectname)
-#todo: ask user to make a project name and mv folders.
-$(error Project name can not be default, please edit ".env" and set COMPOSE_PROJECT_NAME variable.)
+ $(info Project name can not be default, please enter project name.)
+ $(eval COMPOSE_PROJECT_NAME = $(strip $(shell read -p "Project name: " REPLY;echo -n $$REPLY)))
+ $(shell sed -i -e '/COMPOSE_PROJECT_NAME=/ s/=.*/=$(COMPOSE_PROJECT_NAME)/' .env)
+ $(info Please review your project settings and run `make all` again.)
+ exit 1
endif
-
-prepare:
+ifeq ($(shell docker-compose config --services | grep mysql),mysql)
mkdir -p $(MYSQL_DATADIR)
+endif
make -s down
- make -s up
+ @echo "Updating containers..."
+ docker-compose pull
+ @echo "Build and run containers..."
+ docker-compose up -d --remove-orphans
$(call php-0, apk add --no-cache --repository http://dl-cdn.alpinelinux.org/alpine/edge/community graphicsmagick)
$(call php-0, kill -USR2 1)
$(call php, composer global require -o --update-no-dev --no-suggest "hirak/prestissimo:^0.3")
-install:
+composer:
$(call php, composer install --prefer-dist -o --no-dev)
$(call php, composer drupal-scaffold)
+ $(call php, composer create-required-files)
+# Uncomment this string to build front separately. See scripts/makefile/front.mk
+# make -s front
-## Reinstall site
+## Install drupal.
si:
- $(call php-0, chmod +w web/sites/default)
-ifneq ("$(wildcard web/sites/default/settings.php)","")
- $(call php-0, rm -f web/sites/default/settings.php)
-endif
@echo "Installing from: $(PROJECT_INSTALL)"
ifeq ($(PROJECT_INSTALL), config)
$(call php, drush si config_installer --db-url=$(DB_URL) --account-pass=admin -y config_installer_sync_configure_form.sync_directory=../config/sync)
else
$(call php, drush si $(PROFILE_NAME) --db-url=$(DB_URL) --account-pass=admin -y --site-name="$(SITE_NAME)" --site-mail="$(SITE_MAIL)" install_configure_form.site_default_country=FR install_configure_form.date_default_timezone=Europe/Paris)
endif
- #$(call php, drush en $(MODULES) -y)
- #$(call php, drush pmu $(MODULES) -y)
- #make -s locale-update
- #make -s cim
- #make -s update-alias
- #make -s _local-settings
- make -s info
-
-## Update locale
-locale-update:
- $(call php, drush locale-check)
- $(call php, drush locale-update)
-
-_local-settings:
- @echo "Turn on settings.local"
- $(call php, chmod +w web/sites/default)
- $(call php, cp settings/settings.local.php web/sites/default/settings.local.php)
- $(call php-0, sed -i "/settings.local.php';/s/# //g" web/sites/default/settings.php)
-
-## Execute config export to config/sync directory
-cex:
- $(call php, drush cex -y)
-ifneq ($(PROJECT_INSTALL), config)
- rm -rf config/sync/*
- cp -R web/$(shell docker-compose exec -T --user $(CUID):$(CGID) php drush ev 'echo substr(\Drupal::service("config.storage.sync")->getFilePath("drush"), 0, -10);')/* config/sync
+ifneq ($(strip $(MODULES)),)
+ $(call php, drush en $(MODULES) -y)
+ $(call php, drush pmu $(MODULES) -y)
endif
-## Execute config import from config/sync directory
-cim:
- $(call php, drush cr)
- $(call php, drush cim -y)
-
-update-alias:
- $(call php, drush pag canonical_entities:node update)
- $(call php, drush cr)
-
## Project's containers information
info:
-ifeq ($(shell docker inspect --format="{{ .State.Running }}" $(COMPOSE_PROJECT_NAME)_web 2> /dev/null),true)
- @echo Project http://$(shell docker inspect --format='{{(index .NetworkSettings.Networks "$(COMPOSE_NET_NAME)").IPAddress}}' $(COMPOSE_PROJECT_NAME)_web)
-endif
-ifeq ($(shell docker inspect --format="{{ .State.Running }}" $(COMPOSE_PROJECT_NAME)_mail 2> /dev/null),true)
- @echo Mailhog http://$(shell docker inspect --format='{{(index .NetworkSettings.Networks "$(COMPOSE_NET_NAME)").IPAddress}}' $(COMPOSE_PROJECT_NAME)_mail):8025
-endif
-ifeq ($(shell docker inspect --format="{{ .State.Running }}" $(COMPOSE_PROJECT_NAME)_adminer 2> /dev/null),true)
- @echo Adminer http://$(shell docker inspect --format='{{(index .NetworkSettings.Networks "$(COMPOSE_NET_NAME)").IPAddress}}' $(COMPOSE_PROJECT_NAME)_adminer)
-endif
+ $(info Containers for "$(COMPOSE_PROJECT_NAME)" info:)
+ $(eval CONTAINERS = $(shell docker ps -f name=$(COMPOSE_PROJECT_NAME) --format "{{ .ID }}"))
+ $(foreach CONTAINER, $(CONTAINERS),$(info $(shell printf '%-19s \n' $(shell docker inspect --format='{{.NetworkSettings.Networks.$(COMPOSE_NET_NAME).IPAddress}} {{range $$p, $$conf := .NetworkSettings.Ports}}{{$$p}}{{end}} {{.Name}}' $(CONTAINER) | rev | sed "s/pct\//,pct:/g" | sed "s/,//" | rev | awk '{ print $0}')) ))
+ @echo "$(RESULT)"
-chown:
-# Use this goal to set permissions in docker container
- $(call php-0, /bin/sh -c "chown $(CUID):$(CGID) /var/www/html/web -R")
-# Need this to fix files folder
- $(call php-0, /bin/sh -c "chown www-data: /var/www/html/web/sites/default/files -R")
-
-## Run shell in PHP container as CUID:CGID user
+## Run shell in PHP container as regular user
exec:
docker-compose exec --user $(CUID):$(CGID) php ash
-## Run shel in PHP container as root
+## Run shell in PHP container as root
exec0:
docker-compose exec php ash
-up: net
- @echo "Updating containers..."
- docker-compose pull
- @echo "Build and run containers..."
- docker-compose up -d --remove-orphans
-
down:
@echo "Removing network & containers for $(COMPOSE_PROJECT_NAME)"
@docker-compose down -v --remove-orphans --rmi local
+DIRS = web/core web/libraries web/modules/contrib web/profiles/contrib web/sites web/themes/contrib vendor
+
## Totally remove project build folder, docker containers and network
-clean: DIRS := core libraries modules/contrib profiles/contrib sites themes/contrib
-clean: info down
- @for i in $(DIRS); do if [ -d "web/$$i" ]; then echo "Removing web/$$i..."; docker run --rm -v $(shell pwd):/mnt $(IMAGE_PHP) sh -c "rm -rf /mnt/web/$$i"; fi; done
- @if [ -d $(MYSQL_DATADIR) ]; then echo "Removing mysql data $(MYSQL_DATADIR)..."; docker run --rm -v $(MYSQL_BASE_PATH):/mnt/2rm $(IMAGE_PHP) sh -c "rm -rf /mnt/2rm/$(COMPOSE_PROJECT_NAME)_mysql"; fi
-
-net:
-ifeq ($(shell docker network ls -q -f Name=$(COMPOSE_NET_NAME)),)
- docker network create $(COMPOSE_NET_NAME)
-endif
-ifeq ($(shell grep -c -F 'IPRANGE=' .env), 0)
-# @echo Define IP range $(net-range)
- @printf "\nIPRANGE=%s\n" $(shell docker network inspect $(COMPOSE_NET_NAME) --format '{{(index .IPAM.Config 0).Subnet}}') >> .env
-else
-# @if [ '$(IPRANGE)' != '$(shell docker network inspect $(COMPOSE_NET_NAME) --format '{{(index .IPAM.Config 0).Subnet}}')' ]; then echo "Replace IP range $(IPRANGE)"; sed -i "s#IPRANGE=.*#IPRANGE=$(shell docker network inspect $(COMPOSE_NET_NAME) --format '{{(index .IPAM.Config 0).Subnet}}')#" .env; fi;
+clean: info
+ @for i in $(DIRS); do if [ -d "$$i" ]; then echo "Removing $$i..."; docker run --rm -v $(shell pwd):/mnt $(IMAGE_PHP) sh -c "rm -rf /mnt/$$i"; fi; done
+ $(eval SCAFFOLD = $(shell docker-compose exec -T --user $(CUID):$(CGID) php composer run-script list-scaffold-files | grep -P '^(?!>)'))
+ @for i in $(SCAFFOLD); do if [ -e "web/$$i" ]; then echo "Removing web/$$i..."; rm -rf web/$$i; fi; done
+ make -s down
+ifeq ($(shell docker-compose config --services | grep mysql),mysql)
+ @if [ -d $(MYSQL_DATADIR) ]; then echo "Removing mysql data $(MYSQL_DATADIR) ..."; docker run --rm -v $(shell pwd):/mnt/2rm $(IMAGE_PHP) sh -c "rm -rf /mnt/2rm/$(DB_DATA_DIR)"; fi
endif
-# grep -q -F 'IPRANGE=' .env || printf "\nIPRANGE=$(shell docker network inspect $(COMPOSE_NET_NAME) --format '{{(index .IPAM.Config 0).Subnet}}')" >> .env
-
-front:
- @echo "Building front tasks..."
- docker pull $(IMAGE_FRONT)
- $(call front, bower install)
- $(call front)
- $(call php-0, rm -rf web/themes/$(THEME_NAME)/node_modules)
-
-lint:
- @echo "Running linters..."
- $(call front, gulp lint)
- $(call php-0, rm -rf web/themes/$(THEME_NAME)/node_modules)
+## Enable development mode and disable caching.
dev:
@echo "Dev tasks..."
$(call php, composer install --prefer-dist -o)
- $(call php-0, chmod +w web/sites/default)
- $(call php, cp web/sites/default/default.services.yml web/sites/default/services.yml)
- $(call php, sed -i -e 's/debug: false/debug: true/g' web/sites/default/services.yml)
- $(call php, cp web/sites/example.settings.local.php web/sites/default/settings.local.php)
- $(call php, drush -y config-set system.performance css.preprocess 0)
- $(call php, drush -y config-set system.performance js.preprocess 0)
- $(call php, drush en devel devel_generate webform_devel kint -y)
- $(call php, drush pm-uninstall dynamic_page_cache page_cache -y)
- $(call php, drush cr)
-
+ @$(call php-0, chmod +w web/sites/default)
+ @$(call php, cp web/sites/default/default.services.yml web/sites/default/services.yml)
+ @$(call php, sed -i -e 's/debug: false/debug: true/g' web/sites/default/services.yml)
+ @$(call php, cp web/sites/example.settings.local.php web/sites/default/settings.local.php)
+ @echo "Including settings.local.php."
+ @$(call php-0, sed -i "/settings.local.php';/s/# //g" web/sites/default/settings.php)
+ @$(call php, drush -y -q config-set system.performance css.preprocess 0)
+ @$(call php, drush -y -q config-set system.performance js.preprocess 0)
+ @echo "Enabling devel module."
+ @$(call php, drush -y -q en devel devel_generate kint)
+ @echo "Disabling caches."
+ @$(call php, drush -y -q pm-uninstall dynamic_page_cache page_cache)
+ @$(call php, drush cr)
+
+## Run drush command in PHP container. To pass arguments use double dash: "make drush dl devel -- -y"
drush:
- $(call php, drush $(filter-out $@,$(MAKECMDGOALS)))
-
-# https://stackoverflow.com/a/6273809/1826109
-%:
- @:
+ $(call php, $(filter-out "$@",$(MAKECMDGOALS)))
+ $(info "To pass arguments use double dash: "make drush dl devel -- -y"")
## Check codebase with phpcs sniffers to make sure it conforms https://www.drupal.org/docs/develop/standards
phpcs:
- docker run --rm \
- -v $(shell pwd)/web/profiles/$(PROFILE_NAME):/work/profile \
- -v $(shell pwd)/web/modules/custom:/work/modules \
- -v $(shell pwd)/web/themes/$(THEME_NAME):/work/themes \
- skilldlabs/docker-phpcs-drupal phpcs -s --colors \
- --standard=Drupal,DrupalPractice \
- --extensions=php,module,inc,install,profile,theme,yml \
- --ignore=*.css,*.md,*.js .
- docker run --rm \
- -v $(shell pwd)/web/profiles/$(PROFILE_NAME):/work/profile \
- -v $(shell pwd)/web/modules/custom:/work/modules \
- -v $(shell pwd)/web/themes/$(THEME_NAME):/work/themes \
- skilldlabs/docker-phpcs-drupal phpcs -s --colors \
- --standard=Drupal,DrupalPractice \
- --extensions=js \
- --ignore=*.css,*.md,libraries/*,styleguide/* .
+ @$(call phpcsexec, phpcs)
## Fix codebase according to Drupal standards https://www.drupal.org/docs/develop/standards
phpcbf:
- docker run --rm \
- -v $(shell pwd)/web/profiles/$(PROFILE_NAME):/work/profile \
- -v $(shell pwd)/web/modules/custom:/work/modules \
- -v $(shell pwd)/web/themes/$(THEME_NAME):/work/themes \
- skilldlabs/docker-phpcs-drupal phpcbf -s --colors \
- --standard=Drupal,DrupalPractice \
- --extensions=php,module,inc,install,profile,theme,yml,txt,md \
- --ignore=*.css,*.md,*.js .
- docker run --rm \
- -v $(shell pwd)/web/profiles/$(PROFILE_NAME):/work/profile \
- -v $(shell pwd)/web/modules/custom:/work/modules \
- -v $(shell pwd)/web/themes/$(THEME_NAME):/work/themes \
- skilldlabs/docker-phpcs-drupal phpcbf -s --colors \
- --standard=Drupal,DrupalPractice \
- --extensions=js \
- --ignore=*.css,*.md,libraries/*,styleguide/* .
+ @$(call phpcsexec, phpcbf)
diff --git a/README.md b/README.md
index 7a50d5606..fd0f6259f 100644
--- a/README.md
+++ b/README.md
@@ -1,61 +1,129 @@
-# skilld-docker-container
+# Skilld docker container
---
* [Overview](#overview)
-* [Instructions](#instructions)
+* [What is this?](#what-is-this)
+* [What is this not?](#what-is-this-not)
+* [Quickstart](#quickstart)
+ + [Used variables](#used-variables)
+ + [Persistent Mysql](#persistent-mysql)
+ + [Network](#network)
* [Usage](#usage)
+ + [Additional goals](#additional-goals)
+* [Support](#support)
+* [Drush commands](#drush-commands)
+* [Troubleshooting](#troubleshooting)
+* [License](#license)
-## Overview
-
-
-## Instructions
-
-Supported PHP versions: 7.x and 5.6.x.
-1\. Install docker for Linux, Mac OS X or Windows. __For Mac and Windows make sure you're installing native docker app version 1.12, not docker toolbox.__
-
-For Linux install docker compose
-
-2\. Copy __\.env\.default__ to __\.env__
+## Overview
- 2\.1\. Set _COMPOSE_PROJECT_NAME_, _PROFILE_NAME_, _THEME_NAME_ variables with values you need
+**Skilld docker container** is a developer starterkit for your Drupal project.
+
+## What is this?
+
+* This is a developer starterkit which can be used for local drupal development or/and integration into your CI/CD processes.
+
+## What is this not?
+
+* This is not `ready to use tool`, tools list you can find in this google doc
+* Another quick solution https://gist.github.com/andypost/f8e359f2e80cb7d4737350189f009646
+
+
+## Quickstart
+
+* Install docker for Linux, Mac, Windows
+ * Check post-installation steps for Linux
+* Install docker compose
+
+* Copy **.env.default** to **.env**, more information about enviroment file can be found docs.docker.com
+* Copy **docker-compose.override.yml.default** to **docker-compose.override.yml**, update parts you want to overwrite.
+* Run `make all`
+
+
+#### Used variables
+
+| Variable name | Description | Default value |
+| --------------- | ----------------------- | ------------- |
+| COMPOSE_FILE | Path to a Compose file(s) | `./docker/docker-compose.yml:./docker/docker-compose.override.yml` |
+| COMPOSE_PROJECT_NAME | Your project name | - |
+| PROFILE_NAME | Profile used for site install | sdd |
+| MODULES | Additional modules to enable after site install | |
+| THEME_NAME | Theme name used for frontend | - |
+| SITE_NAME | Site name | - |
+| SITE_MAIL | Site e-mail address | admin@example.com |
+| PROJECT_INSTALL | Way to install site - from straight or existing config | - |
+| IMAGE_PHP | Php image to use | `skilldlabs/php:72-fpm` |
+| IMAGE_NGINX | Image to use for nginx container | `skilldlabs/nginx:1.14.1` |
+| IMAGE_FRONT | Image to use for front tasks | `skilldlabs/frontend:zen` |
+| MAIN_DOMAIN_NAME | Domain name used for traefik | `docker.localhost` |
+| DB_URL | Url to connect to database | `sqlite:///dev/shm/d8.sqlite` |
+| DB_DATA_DIR | Full path to database storage | `/dev/shm` |
+
+
+#### Persistent Mysql
+
+* By default sqlite storage used, which is created inside php container, if you need persistent data to be saved:
+ * Update `docker-compose.override.yml`, set
+ ```yaml
+ php:
+ depends_on:
+ - mysql
+ ```
+ and update mysql container part
+ ```yaml
+ mysql:
+ image: percona:5.7.22
+ ...
+ ```
+ * Update `.env` file, and set `DB_URL=mysql://d8:d8@mysql/d8`
+
+#### Network
+
+* Every time project built, it take new available IP address, if you want to have persistent IP, uncomment lines from `docker-compose.override.yml`
+```yaml
+networks:
+ front:
+ driver: bridge
+ ipam:
+ driver: default
+ config:
+ - subnet: "172.18.0.5"
+```
- 2\.2\. Change _IMAGE_PHP_ in case you need another one
+## Usage
-3\. Copy __docker-compose\.override\.yml\.default__ to __docker-compose\.override\.yml__
+* `make` - Show this info.
+* `make all` - Full project install from the scratch.
+* `make clean` - Totally remove project build folder, files, docker containers and network.
+* `make si` - Install/reinstall site.
+* `make info` - Show project services IP addresses.
+* `make exec` - `docker exec` into php container.
+* `make exec0` - `docker exec` into php container as root.
+* `make dev` - Devel + kint setup, and config for Twig debug mode, disable aggregation.
+* `make drush [command]` - execute drush command.
+* `make phpcs` - Check codebase with `phpcs` sniffers to make sure it conforms https://www.drupal.org/docs/develop/standards.
+* `make phpcbf` - Fix codebase according to Drupal standards https://www.drupal.org/docs/develop/standards.
+* `make front` - Builds frontend tasks.
+* `make lint` - Runs frontend linters.
- This file is used to overwrite container settings and/or add your own. See https://docs.docker.com/compose/extends/#/understanding-multiple-compose-files for details.
+#### Additional goals
-4\. Prepare your new Drupal site
+* If you need to add your custom/specific project goal, create new file in `scripts/makefile/myfile.mk` and describe goal inside. Example can be found at `scripts/makefile/backup.mk`
- 4\.1\. Check _composer.json_ contents
+## Support
- 4\.1\.1\. Use `make exec` & `composer require` to add required extensions & libraries
+* This project is supported by © Skilld SAS
- 4\.2\. Optionally add custom theme to _web/themes/_
+## Drush commands
- 4\.2\.1\. Uncomment `make -s front` line to allow build of the theme
+* You can run any drush command `make drush [command -- -argument]`
- 4\.3\. Optionally add you custom modules to _web/modules/custom_
+## Troubleshooting
-5\. Run `make`
+* Use our issue queue, which is public, to search or add new issues.
-## Usage
+## License
-* `make` - Install project.
-* `make clean` - totally remove project build folder, docker containers and network.
-* `make reinstall` - rebuild & reinstall site.
-* `make si` - reinstall site.
-* `make info` - Show project services IP addresses.
-* `make chown` - Change permissions inside container. Use it in case you can not access files in _build_. folder from your machine.
-* `make exec` - docker exec into php container.
-* `make exec0` - docker exec into php container as root.
-* `make dev` - Devel + kint setup, and config for Twig debug mode, disable aggregation.
-* `make drush [command]` - execute drush command.
-* `make phpcs` - check codebase with `phpcs` sniffers to make sure it conforms https://www.drupal.org/docs/develop/standards.
-* `make phpcbf` - fix codebase according to Drupal standards https://www.drupal.org/docs/develop/standards.
-* `make cex` - executes config export to `config/sync` directory.
-* `make cim` - executes config import from `config/sync` directory.
-* `make front` - builds frontend tasks
-* `make lint` - runs frontend linters
+This project is licensed under the MIT open source license.
diff --git a/composer.json b/composer.json
index b3687da2e..6150df3ab 100644
--- a/composer.json
+++ b/composer.json
@@ -2,7 +2,7 @@
"name": "skilld-labs/drupal-project",
"description": "Project template for Drupal 8 projects with composer",
"type": "project",
- "license": "GPL-2.0+",
+ "license": "MIT",
"authors": [
{
"name": "",
@@ -14,56 +14,40 @@
"type": "composer",
"url": "https://packages.drupal.org/8"
},
- {
- "type": "package",
- "package": {
- "name": "ckeditor/colorbutton",
- "version": "4.6.1",
- "type": "drupal-library",
- "dist": {
- "url": "http://download.ckeditor.com/colorbutton/releases/colorbutton_4.6.1.zip",
- "type": "zip"
- }
- }
- },
{
"type": "package",
"package": {
"name": "ckeditor/panelbutton",
- "version": "4.6.1",
+ "version": "4.10.1",
"type": "drupal-library",
"dist": {
- "url": "http://download.ckeditor.com/panelbutton/releases/panelbutton_4.6.1.zip",
+ "url": "https://download.ckeditor.com/panelbutton/releases/panelbutton_4.10.1.zip",
"type": "zip"
}
}
}
],
"require": {
- "ckeditor/colorbutton": "^4.6",
- "ckeditor/panelbutton": "^4.6",
+ "ckeditor/panelbutton": "^4.10",
"composer/installers": "^1.2",
"cweagans/composer-patches": "^1.6.5",
"drupal-composer/drupal-scaffold": "^2.5",
"drupal/admin_toolbar": "^1",
- "drupal/colorbutton": "^1",
"drupal/components": "^1",
"drupal/config_installer": "^1",
- "drupal/core": "^8.6.3",
+ "drupal/core": "^8.6.7",
"drupal/default_content": "^1",
- "drupal/ds": "^3",
"drupal/file_entity": "^2",
"drupal/panelbutton": "^1",
"drupal/styleguide": "^1",
"drupal/swiftmailer": "^1",
"drupal/token": "^1",
- "neitanod/forceutf8": "2.0.*",
- "webflo/drupal-finder": "^1.0.0",
+ "webflo/drupal-finder": "^1.1",
"webmozart/path-util": "^2.3",
- "wikimedia/composer-merge-plugin": "^1.4"
+ "wikimedia/composer-merge-plugin": "^1.4",
+ "zaporylie/composer-drupal-optimizations": "^1.0"
},
"require-dev": {
- "drupal/devel": "^1.2"
},
"conflict": {
"drupal/drupal": "*"
@@ -80,17 +64,15 @@
},
"scripts": {
"drupal-scaffold": "DrupalComposer\\DrupalScaffold\\Plugin::scaffold",
+ "create-required-files": "SkilldDrupal\\composer\\ScriptHandler::createRequiredFiles",
+ "list-scaffold-files": [
+ "SkilldDrupal\\composer\\ScriptHandler::listScaffoldFiles"
+ ],
"pre-install-cmd": [
- "DrupalProject\\composer\\ScriptHandler::checkComposerVersion"
+ "SkilldDrupal\\composer\\ScriptHandler::checkComposerVersion"
],
"pre-update-cmd": [
- "DrupalProject\\composer\\ScriptHandler::checkComposerVersion"
- ],
- "post-install-cmd": [
- "DrupalProject\\composer\\ScriptHandler::createRequiredFiles"
- ],
- "post-update-cmd": [
- "DrupalProject\\composer\\ScriptHandler::createRequiredFiles"
+ "SkilldDrupal\\composer\\ScriptHandler::checkComposerVersion"
]
},
"extra": {
@@ -102,6 +84,12 @@
"web/themes/contrib/{$name}": ["type:drupal-theme"],
"drush/contrib/{$name}": ["type:drupal-drush"]
},
+ "drupal-scaffold": {
+ "initial": {
+ ".editorconfig": "../.editorconfig",
+ ".gitattributes": "../.gitattributes"
+ }
+ },
"composer-exit-on-patch-failure": true,
"patches": {
"drupal/core": {
diff --git a/docker/docker-compose.override.yml.default b/docker/docker-compose.override.yml.default
index 5451b9f2c..18694e0e3 100644
--- a/docker/docker-compose.override.yml.default
+++ b/docker/docker-compose.override.yml.default
@@ -5,19 +5,12 @@ services:
# Override base service.
php:
volumes:
- - "./90-mail.ini:/etc/php${PHP_VERSION}/conf.d/90-mail.ini:z"
+ - "./90-mail.ini:/etc/php7/conf.d/90-mail.ini:z"
+# depends_on:
+# - mysql
# Uncomment next line if you need PHP XDebug.
# command: php-fpm7 -F -d zend_extension=xdebug.so
-# Use local folder to not lose data on container crash.
-# CAUTION: Don't use this section on development machine because container
-# working speed will be decreased.
-# mysql:
-# volumes:
-# - ../../mysql:/var/lib/mysql:Z
-# On for linux machines use ramfs, make sure to create the directory first.
-# - ${MYSQL_BASE_PATH}/${COMPOSE_PROJECT_NAME}_mysql:/var/lib/mysql:Z
-
# adminer:
# image: dockette/adminer:mysql-php7
# container_name: "${COMPOSE_PROJECT_NAME}_adminer"
@@ -28,12 +21,32 @@ services:
# networks:
# - front
+
+# mysql:
+# image: percona:5.7.22
+# container_name: "${COMPOSE_PROJECT_NAME}_mysql"
+# volumes:
+# - ${DB_DATA_DIR}/${COMPOSE_PROJECT_NAME}_mysql:/var/lib/mysql:Z
+# environment:
+# MYSQL_DATABASE: d8
+# MYSQL_USER: d8
+# MYSQL_PASSWORD: d8
+# MYSQL_ROOT_PASSWORD: d8root
+# restart: always
+# networks:
+# - front
+
mailhog:
image: skilldlabs/mailhog
container_name: "${COMPOSE_PROJECT_NAME}_mail"
restart: always
networks:
- front
+ labels:
+ - 'traefik.enable=true'
+ - 'traefik.backend=${MAIN_DOMAIN_NAME}_mail'
+ - 'traefik.port=8025'
+ - 'traefik.frontend.rule=Host:mail.${MAIN_DOMAIN_NAME}'
nginx:
# Uncomment for MacOS.
@@ -42,3 +55,15 @@ services:
# Mount local folder with ssl keys.
# volumes:
# - ./nginx/ssl:/etc/nginx/ssl:Z
+ labels:
+ - 'traefik.enable=true'
+ - 'traefik.backend=${MAIN_DOMAIN_NAME}_web'
+ - 'traefik.port=80'
+ - 'traefik.frontend.rule=Host:${MAIN_DOMAIN_NAME}'
+#networks:
+# front:
+# driver: bridge
+# ipam:
+# driver: default
+# config:
+# - subnet: "${IPRANGE}"
diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml
index f37ceff5c..d2d00c615 100644
--- a/docker/docker-compose.yml
+++ b/docker/docker-compose.yml
@@ -5,8 +5,6 @@ services:
php:
image: ${IMAGE_PHP}
container_name: "${COMPOSE_PROJECT_NAME}_php"
-# depends_on:
-# - mysql
volumes:
- ../:/var/www/html:z
- ../drush/.drushrc.php:/home/www-data/.drushrc.php:z
@@ -15,7 +13,7 @@ services:
- front
nginx:
- image: skilldlabs/nginx:1.14.1
+ image: ${IMAGE_NGINX}
container_name: "${COMPOSE_PROJECT_NAME}_web"
depends_on:
- php
@@ -25,24 +23,6 @@ services:
networks:
- front
-# mysql:
-# image: percona:5.7
-# container_name: "${COMPOSE_PROJECT_NAME}_mysql"
-# volumes:
-# - /dev/shm/${COMPOSE_PROJECT_NAME}_mysql:/var/lib/mysql:Z
-# environment:
-# MYSQL_DATABASE: d8
-# MYSQL_USER: d8
-# MYSQL_PASSWORD: d8
-# MYSQL_ROOT_PASSWORD: d8root
-# restart: always
-# networks:
-# - front
-
networks:
front:
driver: bridge
- ipam:
- driver: default
- config:
- - subnet: "${IPRANGE}"
diff --git a/scripts/composer/ScriptHandler.php b/scripts/composer/ScriptHandler.php
index a75e4d34e..1f9404317 100644
--- a/scripts/composer/ScriptHandler.php
+++ b/scripts/composer/ScriptHandler.php
@@ -2,10 +2,10 @@
/**
* @file
- * Contains \DrupalProject\composer\ScriptHandler.
+ * Contains \SkilldDrupal\composer\ScriptHandler.
*/
-namespace DrupalProject\composer;
+namespace SkilldDrupal\composer;
use Composer\Script\Event;
use Composer\Semver\Comparator;
@@ -13,8 +13,44 @@
use Symfony\Component\Filesystem\Filesystem;
use Webmozart\PathUtil\Path;
+/**
+ * Class ScriptHandler
+ *
+ * @package SkilldDrupal\composer
+ */
class ScriptHandler {
+ /**
+ * @param \Composer\Script\Event $event
+ */
+ public static function listScaffoldFiles(Event $event) {
+ $files = [
+ '.csslintrc',
+ '.editorconfig',
+ '.eslintignore',
+ '.eslintrc.json',
+ '.gitattributes',
+ '.ht.router.php',
+ '.htaccess',
+ 'index.php',
+ 'robots.txt',
+ 'sites/default/default.settings.php',
+ 'sites/default/default.services.yml',
+ 'sites/development.services.yml',
+ 'sites/example.settings.local.php',
+ 'sites/example.sites.php',
+ 'update.php',
+ 'web.config',
+ ];
+ $event->getIO()->write("\r\n".implode(' ',$files));
+ }
+
+
+ /**
+ * @param \Composer\Script\Event $event
+ *
+ * @throws \Exception
+ */
public static function createRequiredFiles(Event $event) {
$fs = new Filesystem();
$drupalFinder = new DrupalFinder();
@@ -29,9 +65,9 @@ public static function createRequiredFiles(Event $event) {
// Required for unit testing
foreach ($dirs as $dir) {
- if (!$fs->exists($drupalRoot . '/'. $dir)) {
- $fs->mkdir($drupalRoot . '/'. $dir);
- $fs->touch($drupalRoot . '/'. $dir . '/.gitkeep');
+ if (!$fs->exists($drupalRoot . '/' . $dir)) {
+ $fs->mkdir($drupalRoot . '/' . $dir);
+ $fs->touch($drupalRoot . '/' . $dir . '/.gitkeep');
}
}
@@ -48,15 +84,20 @@ public static function createRequiredFiles(Event $event) {
];
drupal_rewrite_settings($settings, $drupalRoot . '/sites/default/settings.php');
$fs->chmod($drupalRoot . '/sites/default/settings.php', 0666);
- $event->getIO()->write("Create a sites/default/settings.php file with chmod 0666");
+ $event->getIO()
+ ->write("Create a sites/default/settings.php file with chmod 0666");
}
// Create the files directory with chmod 0777
if (!$fs->exists($drupalRoot . '/sites/default/files')) {
$oldmask = umask(0);
- $fs->mkdir($drupalRoot . '/sites/default/files', 0777);
+ $fs->mkdir($drupalRoot . '/sites/default/files', 0775);
umask($oldmask);
- $event->getIO()->write("Create a sites/default/files directory with chmod 0777");
+ $event->getIO()
+ ->write("Create a sites/default/files directory with chmod 0775");
+ }
+ else {
+ $fs->chmod($drupalRoot . '/sites/default/files', 0775);
}
}
diff --git a/scripts/makefile/backup.mk b/scripts/makefile/backup.mk
new file mode 100644
index 000000000..96737a3c2
--- /dev/null
+++ b/scripts/makefile/backup.mk
@@ -0,0 +1,11 @@
+## Make backup from current state
+mysql_dump_name = $(COMPOSE_PROJECT_NAME).sql
+files_dir = web/sites/default/files
+datestamp=$(shell echo `date +'%Y-%m-%d'`)
+backup_name = $(COMPOSE_PROJECT_NAME)-$(datestamp).tar.gz
+
+backup:
+ rm -f $(backup_name)
+ $(call php, drush sql-dump --database=default --result-file=../$(mysql_dump_name))
+ tar -czvf $(backup_name) $(files_dir) $(mysql_dump_name) --exclude=$(files_dir)/translations --exclude=$(files_dir)/js --exclude=$(files_dir)/css --exclude=$(files_dir)/styles --exclude=$(files_dir)/php
+ rm $(mysql_dump_name)
\ No newline at end of file
diff --git a/scripts/makefile/front.mk b/scripts/makefile/front.mk
new file mode 100644
index 000000000..dc68af3c6
--- /dev/null
+++ b/scripts/makefile/front.mk
@@ -0,0 +1,15 @@
+# Execute front container function.
+front = docker run --rm -u $(CUID):$(CGID) -v $(shell pwd)/web/themes/custom/$(THEME_NAME):/work $(IMAGE_FRONT) ${1}
+
+## Build front tasks.
+front:
+ @echo "Building front tasks..."
+ docker pull $(IMAGE_FRONT)
+ $(call front, bower install)
+ $(call front)
+ $(call php-0, rm -rf web/themes/custom/$(THEME_NAME)/node_modules)
+
+lint:
+ @echo "Running linters..."
+ $(call front, gulp lint)
+ $(call php-0, rm -rf web/themes/custom/$(THEME_NAME)/node_modules)
diff --git a/scripts/makefile/help.mk b/scripts/makefile/help.mk
index 1340f9bfe..c474b3f52 100644
--- a/scripts/makefile/help.mk
+++ b/scripts/makefile/help.mk
@@ -1,15 +1,20 @@
TARGET_MAX_CHAR_NUM=25
## Show help
+RESET=\x1b[0m
+GREEN=\x1b[32;01m
+RED=\x1b[31;01m
+YELLOW=\x1b[33;01m
+
help:
@echo ''
@echo 'Usage:'
- @echo ' ${YELLOW}make${RESET} ${GREEN}${RESET}'
+ @echo -e ' ${YELLOW}make${RESET} ${GREEN}${RESET}'
@echo ''
@echo 'Targets:'
@awk '/^[a-zA-Z\-\_0-9]+:/ { \
helpMessage = match(lastLine, /^## (.*)/); \
if (helpMessage) { \
- helpCommand = substr($$1, 0, index($$1, ":")-1); \
+ helpCommand = substr($$1, 0, index($$1, ":")); \
helpMessage = substr(lastLine, RSTART + 3, RLENGTH); \
printf " ${YELLOW}%-$(TARGET_MAX_CHAR_NUM)s${RESET} ${GREEN}%s${RESET}\n", helpCommand, helpMessage; \
} \
diff --git a/settings/settings.dev.php b/settings/settings.dev.php
new file mode 100644
index 000000000..4a40a1318
--- /dev/null
+++ b/settings/settings.dev.php
@@ -0,0 +1,131 @@
+