Skip to content

Commit 3201744

Browse files
committed
Merge pull request #852 from ruflin/docker-build-file
Docker build and development environment
2 parents 812de1a + 7c99eaf commit 3201744

File tree

20 files changed

+564
-251
lines changed

20 files changed

+564
-251
lines changed

CHANGELOG.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@ All notable changes to this project will be documented in this file based on the
88
- Support for a custom connection timeout through a connectTimeout parameter. [#841](https://github.com/ruflin/Elastica/issues/841/)
99
- SignificantTerms Aggregation [#847](https://github.com/ruflin/Elastica/issues/847/)
1010
- Support for 'precision_threshold' and 'rehash' options for the Cardinality Aggregation [#851]
11-
11+
- Support for retrieving id node
1212

1313
### Improvements
1414
- Introduction of Changelog standard based on http://keepachangelog.com/. changes.txt moved to CHANGELOG.md [#844](https://github.com/ruflin/Elastica/issues/844/)
1515
- Make host for all tests dynamic to prepare it for a more dynamic test environment #846
16-
16+
- Node information is retrieved based on id instead of name as multiple nodes can have the same name.
1717

1818

1919

Dockerfile

+53
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
# PHP 6 Docker file with Composer installed
2+
FROM composer/composer
3+
4+
RUN apt-get update
5+
RUN apt-get upgrade -y
6+
RUN apt-get install -y nano
7+
RUN apt-get install -y cloc
8+
9+
# XSL and Graphviz for PhpDocumentor
10+
RUN apt-get install -y php5-xsl
11+
# TODO: Debian is putting the xsl extension in a different directory, should be in: /usr/local/lib/php/extensions/no-debug-non-zts-20131226
12+
RUN echo "extension=/usr/lib/php5/20131226/xsl.so" >> /usr/local/etc/php/conf.d/xsl.ini
13+
RUN apt-get install -y graphviz
14+
15+
16+
# Xdebug for coverage report
17+
RUN apt-get install -y php5-xdebug
18+
RUN echo "zend_extension=/usr/lib/php5/20131226/xdebug.so" >> /usr/local/etc/php/conf.d/xdebug.ini
19+
20+
# Memcache
21+
RUN apt-get install -y php5-memcache
22+
RUN echo "extension=/usr/lib/php5/20131226/memcache.so" >> /usr/local/etc/php/conf.d/memcache.ini
23+
24+
# Add composer bin to the environment
25+
ENV PATH=/root/composer/vendor/bin:$PATH
26+
27+
# Overcome github access limits. GITHUB_OAUTH_TOKEN environment variable must be set with private token
28+
RUN composer self-update
29+
30+
# Install development tools
31+
RUN composer global require "phpunit/phpunit"
32+
RUN composer global require "pdepend/pdepend"
33+
RUN composer global require "phpmd/phpmd"
34+
RUN composer global require "mayflower/php-codebrowser"
35+
RUN composer global require "sebastian/phpcpd"
36+
RUN composer global require "squizlabs/php_codesniffer"
37+
RUN composer global require "phploc/phploc"
38+
RUN composer global require "fabpot/php-cs-fixer"
39+
40+
41+
# Documentor dependencies
42+
RUN composer global require "phpdocumentor/template-zend"
43+
RUN composer global require "phpdocumentor/phpdocumentor"
44+
45+
# Install depdencies
46+
WORKDIR /app
47+
COPY composer.json /app/
48+
RUN composer install
49+
50+
# Guzzle is not included composer.json because of PHP 5.3
51+
RUN composer require "guzzlehttp/guzzle"
52+
53+
ENTRYPOINT []

Makefile

+106
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
#/bin/bash
2+
3+
BASEDIR = $(shell pwd)
4+
SOURCE = "${BASEDIR}/lib"
5+
IMAGE = "elastica"
6+
7+
8+
### Setups around project sources. These commands should run ###
9+
init: prepare
10+
composer install
11+
12+
prepare:
13+
mkdir -p ${BASEDIR}/build/api
14+
mkdir -p ${BASEDIR}/build/code-browser
15+
mkdir -p ${BASEDIR}/build/coverage
16+
mkdir -p ${BASEDIR}/build/logs
17+
mkdir -p ${BASEDIR}/build/docs
18+
mkdir -p ${BASEDIR}/build/pdepend
19+
20+
update: init
21+
22+
clean:
23+
rm -r -f ${BASEDIR}/build
24+
#rm ${BASEDIR}/cache.properties
25+
26+
27+
# Handling virtual environment
28+
29+
build:
30+
docker-compose build
31+
32+
setup: build
33+
docker-compose scale elasticsearch=3
34+
35+
start:
36+
docker-compose up
37+
38+
stop:
39+
docker-compose stop
40+
41+
destroy: clean
42+
docker-compose kill
43+
docker-compose rm
44+
45+
# Runs commands inside virtual environemnt. Example usage inside docker: make run RUN="make phpunit"
46+
run:
47+
docker-compose run elastica $(RUN)
48+
49+
50+
### Quality checks / development tools ###
51+
52+
checkstyle:
53+
phpcs --standard=PSR2 ${SOURCE}
54+
55+
checkstyle-ci: prepare
56+
phpcs --report=checkstyle --report-file=${BASEDIR}/build/logs/checkstyle.xml --standard=PSR2 ${SOURCE} > /dev/null
57+
58+
code-browser: prepare
59+
phpcb --log ${BASEDIR}/build/logs --source ${SOURCE} --output ${BASEDIR}/build/code-browser
60+
61+
# Copy paste detector
62+
cpd: prepare
63+
phpcpd --log-pmd ${BASEDIR}/build/logs/pmd-cpd.xml ${SOURCE}
64+
65+
messdetector: prepare
66+
phpmd ${SOURCE} text codesize,unusedcode,naming,design ${BASEDIR}/build/phpmd.xml
67+
68+
messdetector-ci: prepare
69+
phpmd ${SOURCE} xml codesize,unusedcode,naming,design --reportfile ${BASEDIR}/build/logs/pmd.xml
70+
71+
dependencies: prepare
72+
pdepend --jdepend-xml=${BASEDIR}/build/logs/jdepend.xml \
73+
--jdepend-chart=${BASEDIR}/build/pdepend/dependencies.svg \
74+
--overview-pyramid=${BASEDIR}/build/pdepend/overview-pyramid.svg \
75+
${SOURCE}
76+
77+
phpunit: prepare
78+
phpunit -c test/phpunit-travis.xml
79+
80+
doc: prepare
81+
phpdoc run -d lib/ -t build/docs
82+
83+
# TODO: Command needs to be updated with Elastica standard
84+
lint-fixing:
85+
php-cs-fixer fix ./lib
86+
87+
lint:
88+
php -lf ${SOURCE} **/*.php
89+
php -lf ${BASEDIR}/test **/*.php
90+
91+
92+
loc:
93+
cloc --by-file --xml --exclude-dir=build -out=build/cloc.xml .
94+
95+
phploc:
96+
phploc --log-csv $(BASEDIR)/build/logs/phploc.csv $(SOURCE)
97+
98+
99+
100+
# Visualise repo
101+
gource:
102+
gource --log-format git \
103+
--seconds-per-day 0.1 \
104+
--title 'Elastica (https://github.com/ruflin/Elastica)' \
105+
--user-scale 1 \
106+
--max-user-speed 50

ansible/roles/elasticsearch/templates/config-0.yml

-1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,5 @@ http.port: 9200
66
transport.tcp.port: 9300
77
thrift.port: 9500
88
memcached.port: 11211
9-
node.name: "Silver Fox"
109

1110
{% endblock %}

ansible/roles/elasticsearch/templates/config-1.yml

-1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,5 @@ http.port: 9201
66
transport.tcp.port: 9301
77
thrift.port: 9501
88
memcached.port: 11212
9-
node.name: "Skywalker"
109

1110
{% endblock %}

ansible/roles/elasticsearch/templates/config-default.yml

+3
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ network.host: "127.0.0.1"
2626
# Without this, travis builds will be failed with OutOfMemory error
2727
processors: 1
2828

29+
# All nodes will be called Elastica
30+
node.name: Elastica
31+
2932
{% endblock %}
3033

3134
{% block config %}

0 commit comments

Comments
 (0)