Skip to content

Commit

Permalink
Switched to docker for local and CI.
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexSkrypnyk authored Feb 5, 2018
1 parent e7f7a88 commit aa1f403
Show file tree
Hide file tree
Showing 23 changed files with 806 additions and 636 deletions.
377 changes: 131 additions & 246 deletions .circleci/config.yml

Large diffs are not rendered by default.

17 changes: 17 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
.circleci
.git
.idea
*.md
docker-compose*
screenshots
node_modules
vendor
docroot/sites/default/files

# Ignore Drupal directories generated by Composer.
drush/contrib/
docroot/core
docroot/modules/contrib
docroot/themes/contrib
docroot/profiles/contrib
docroot/libraries
3 changes: 3 additions & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
COMPOSE_FILE=docker-compose.yml:docker-compose.local.yml
MYSQL_HOST=mariadb
MYSQL_PORT=3306
21 changes: 15 additions & 6 deletions .gitignore.artefact
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,23 @@
*.out
*.log
node_modules
vendor
screenshots
.data
.vagrant
Vagrantfile
.beetbox
composer.lock
package-lock.json
.circleci/config.yml
.sass-cache
*.css.map
docker-compose*
Dockerfile.*
.env
docker/*
phpcs.xml
phpunit.xml
composer.json
composer.lock
package.json
package-lock.json
Gruntfile.js
.sass-lint.yml
.dockerignore
.eslintrc.json
behat.yml
27 changes: 27 additions & 0 deletions Dockerfile.builder
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
FROM amazeeio/php:7.1-cli-drupal

ENV WEBROOT=docroot \
COMPOSER_ALLOW_SUPERUSER=1 \
COMPOSER_CACHE_DIR=/tmp/.composer/cache \
MYSQL_HOST=mariadb

RUN apk update \
&& apk del nodejs nodejs-current yarn \
&& apk add nodejs-npm patch rsync --update-cache --repository http://dl-3.alpinelinux.org/alpine/v3.7/main/ \
&& rm -rf /var/cache/apk/*

ADD patches /app/patches
ADD scripts /app/scripts

COPY composer.json composer.lock /app/
COPY package.json package-lock.json Gruntfile.js /app/

RUN composer install --no-dev --optimize-autoloader --prefer-dist --ansi

RUN npm install

COPY . /app
COPY .data/db.sql /tmp/.data/db.sql

RUN npm run build
RUN rm -rf /app/node_modules
7 changes: 7 additions & 0 deletions Dockerfile.mariadb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
FROM amazeeio/centos7-mariadb10-drupal

USER root
COPY docker/server.cnf /etc/my.cnf.d/server.cnf
RUN fix-permissions /etc/my.cnf.d/

USER mysql
11 changes: 11 additions & 0 deletions Dockerfile.nginx
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
ARG CLI_IMAGE
FROM ${CLI_IMAGE:-builder} as builder

FROM amazeeio/nginx-drupal

ENV WEBROOT=docroot

COPY docker/drupal.conf /etc/nginx/conf.d/app.conf
RUN fix-permissions /etc/nginx

COPY --from=builder /app /app
6 changes: 6 additions & 0 deletions Dockerfile.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
ARG CLI_IMAGE
FROM ${CLI_IMAGE:-builder} as builder

FROM amazeeio/php:7.1-fpm

COPY --from=builder /app /app
64 changes: 31 additions & 33 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,47 +76,48 @@ Drupal 7 implementation of MYSITE
3. Copy `db.sql` to `.data/db.sql`
4. `composer build`
## Available commands
- `build` - build project.
- `rebuild` - cleanup code dependencies and rebuild site, skipping VM management.
- `rebuild-full` - cleanup code dependencies, remove VM and rebuild the site.
- `build-db` - re-import DB and run updates.
- `build-theme` - build theme assets. Supports watching: `composer build-theme -- watch`.
- `cleanup` - remove code dependencies, skipping VM management.
- `cleanup-full` - remove code dependencies and remove VM.
## Available composer commands
Run each command as `composer <command>`.
### Application
- `app:build` - start local development environment and build project.
- `app:rebuild` - re-build project, removing and re-installing dependencies.
- `app:rebuild-full` - cleanup code dependencies, remove VM and rebuild the site.
- `app:import-db` - re-import DB and run updates.
- `app:build-fed` - build theme assets. Supports watching: `composer build-theme -- watch`.
- `app:cleanup` - remove and re-install dependencies.
- `app:cleanup-full` - remove dependencies and docker images.
- `app:login` - open a web browser login into build application.
- `app:build-artefact` - build application artefact suitable for deployment in production environment.
### Docker
- `docker:start` - start environment.
- `docker:stop` - stop environment preserving data.
- `docker:restart` - restart environment.
- `docker:destroy` - destroy environment.
- `docker:pull` - pull latest images.
- `docker:cli` - run command in CLI container.
- `docker:logs` - show logs from docker compose run.
## Adding Drupal modules
`composer require drupal/module_name`
## Adding patches for drupal modules
1. Add `title` and `url` to patch on drupal.org to the `patches` array in `composer.json`.
1. Add `title` and `url` to patch on drupal.org to the `patches` array in `extra` section in `composer.json`.
```
"repositories": [
{
"type": "package",
"package": {
"name": "myorg/patches",
"version": "1.0.0",
"type": "metapackage",
"extra": {
"extra": {
"patches": {
"drupal/persistent_update": [
{
"title": "Add an ability to bypass all persistent updates",
"url": "https://www.drupal.org/files/issues/bypass-all-persistent-updates-2824493-3.patch"
"drupal/core": {
"Contextual links should not be added inside another link - https://www.drupal.org/node/2898875": "https://www.drupal.org/files/issues/contextual_links_should-2898875-3.patch"
}
]
}
}
}
}
}
]
```
2. `composer rebuild`
One caveat is that a removal of composer.lock may be required before step #2 as composer caches dependencies and patches may not be applied.
2. `composer update --lock`
## Coding standards
PHP and JS code linting uses [PHP_CodeSniffer](https://github.com/squizlabs/PHP_CodeSniffer) with Drupal rules from [Coder](https://www.drupal.org/project/coder) module and additional local overrides in `phpcs.xml.dist` and `.eslintrc`.
Expand All @@ -130,7 +131,7 @@ Behat configuration uses multiple extensions:
- [Behat Progress Fail Output Extension](https://github.com/integratedexperts/behat-format-progress-fail) - Behat output formatter to show progress as TAP and fail messages inline. Useful to get feedback about failed tests while continuing test run.
- `FeatureContext` - Site-specific context with custom step definitions.
## Automated builds (Continuous Integration)
## Automated builds (Cont inuous Integration)
In software engineering, continuous integration (CI) is the practice of merging all developer working copies to a shared mainline several times a day.
Before feature changes can be merged into a shared mainline, a complete build must run and pass all tests on CI server.
Expand All @@ -148,6 +149,3 @@ If the build has inconsistent results (build fails in CI but passes locally), tr
### Test artifacts
Test artifacts (screenshots etc.) are available under 'Artifacts' tab in Circle CI UI.
### All Selenium tests are suddenly broken
Chromedriver (a binary used by Selenium to control Chrome browser) version must follow Chrome version. Currently, Chrome version is set to stable, so when there is an update of the major Chrome version, Chromedriver version needs to be updated as well. The following link contains information about currently available Chromedriver versions: http://chromedriver.storage.googleapis.com
21 changes: 15 additions & 6 deletions behat.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@ default:
DMore\ChromeExtension\Behat\ServiceContainer\ChromeExtension: ~
Behat\MinkExtension:
goutte: ~
base_url: http://local.mysiteurl
base_url: http://nginx:8080
browser_name: chrome
sessions:
default:
chrome:
api_url: "http://local.mysiteurl:9222"
javascript_session: default
selenium2:
wd_host: "http://selenium:4444/wd/hub"
capabilities: { "browser": "chrome", "version": "*", "marionette": true }
javascript_session: selenium2
files_path: %paths.base%/tests/test_data
# Provides integration with Drupal APIs.
Drupal\DrupalExtension:
blackbox: ~
Expand All @@ -46,3 +46,12 @@ default:
purge: false
# Show explicit fail information and continue the test run.
IntegratedExperts\BehatFormatProgressFail\FormatExtension: ~

p0:
gherkin:
filters:
tags: "@p0&&~@skipped"
p1:
gherkin:
filters:
tags: "@p1&&~@skipped"
Loading

0 comments on commit aa1f403

Please sign in to comment.