Skip to content

Commit

Permalink
Merge pull request #128 from geokrety/master
Browse files Browse the repository at this point in the history
Deploy to production
  • Loading branch information
kumy committed Jul 12, 2018
2 parents 7b4e9c6 + 91d1259 commit 1be68fe
Show file tree
Hide file tree
Showing 205 changed files with 46,192 additions and 12,006 deletions.
9 changes: 9 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,19 @@
*.swo
.svn
.well-known
*.dont-push.*
.idea/
.project
.buildpath
.settings
.php_cs.cache
# generated
docker-compose-windows.yml
vars
docker-compose.dev.yml
git-version
.php_cs.cache
.project
vars/
# please use 'composer install' to generate vendor/
vendor/
41 changes: 25 additions & 16 deletions .php_cs
Original file line number Diff line number Diff line change
@@ -1,32 +1,41 @@
<?php

if (class_exists('PhpCsFixer\Finder')) { // PHP-CS-Fixer 2.x
if (class_exists('PhpCsFixer\Finder')) {
echo "PHP-CS-Fixer 2.x rules\n";
$finder = PhpCsFixer\Finder::create()
->exclude('szef/')
->exclude('templates/colorbox/')
->exclude('templates/compile/')
->exclude('templates/rating/')
->exclude('templates/jpgraph/')
->exclude('templates/libraries/')
->exclude('templates/htmlpurifier/')
->exclude('templates/sentry-php-master/')
->exclude('templates/piwik-php-tracker/')
->notPath('templates/GoogleMap.php')
->notPath('templates/PasswordHash.php')
->notPath('templates/JSMin.php')
->notPath('szef/smarty.php')
->in('website/')
->exclude('website/szef/')
->exclude('website/templates/colorbox/')
->exclude('website/templates/compile/')
->exclude('website/templates/rating/')
->exclude('website/templates/jpgraph/')
->exclude('website/templates/libraries/')
->exclude('website/templates/htmlpurifier/')
->exclude('website/templates/sentry-php-master/')
->exclude('website/templates/piwik-php-tracker/')
->notPath('website/templates/GoogleMap.php')
->notPath('website/templates/PasswordHash.php')
->notPath('website/templates/JSMin.php')
->notPath('website/szef/smarty.php')
->in(__DIR__)
;

// doc position_after_functions_and_oop_constructs: https://github.com/FriendsOfPHP/PHP-CS-Fixer/blob/4e91f495a7ece1f2566feba2f07cc5824d68ec0b/README.rst
return PhpCsFixer\Config::create()
->setRules(array(
'@Symfony' => true,
'no_closing_tag' => true,
'yoda_style' => false,
'braces' => [
'allow_single_line_closure' => true,
'position_after_functions_and_oop_constructs' => 'same',
'position_after_anonymous_constructs' => 'same',
'position_after_control_structures' => 'same'
]
))
->setFinder($finder)
;
} elseif (class_exists('Symfony\CS\Finder\DefaultFinder')) { // PHP-CS-Fixer 1.x
} elseif (class_exists('Symfony\CS\Finder\DefaultFinder')) {
echo "PHP-CS-Fixer 1.x rules\n";
$finder = Symfony\CS\Finder::create()
->exclude('szef')
->exclude('templates/colorbox')
Expand Down
5 changes: 4 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ addons:
- gettext

install:
- composer require --dev friendsofphp/php-cs-fixer
- cd website && composer install && cd ..
- composer install
- sudo curl -L https://raw.githubusercontent.com/smarty-gettext/smarty-gettext/master/tsmarty2c.php -o /usr/local/bin/tsmarty2c
- sudo chmod 0755 /usr/local/bin/tsmarty2c
- phpenv config-rm xdebug.ini || return 0
Expand All @@ -36,6 +37,8 @@ script:
#- scripts/phplint.sh website/ # Disabled see issue #69
# Check CS fixer
- vendor/bin/php-cs-fixer --no-interaction --dry-run --diff -v fix
# Unit tests with PHPUnit
- vendor/bin/phpunit

jobs:
include:
Expand Down
7 changes: 6 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,9 @@ cf. [autolinked-references-and-urls/](https://help.github.com/articles/autolinke
Each time you are pushing fresh commits on https://github.com/geokrety/geokrety-website, a new travis job is started onto [travis-ci.org/geokrety](https://travis-ci.org/geokrety/geokrety-website/).
Travis checks are defined into [.travis.yml](website/.travis.yml)

If you fork the project, then you will have to activate travis-ci builds for your own clone.
If you fork the project, then you will have to activate travis-ci builds for your own clone.


## Install

please cf. [INSTALL.md](INSTALL.md)
14 changes: 11 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,13 @@ RUN apt-get update \
libfreetype6-dev \
libjpeg62-turbo-dev \
libmcrypt-dev \
libpng12-dev \
libpng-dev \
graphicsmagick-imagemagick-compat \
ssmtp \
locales \
gettext \
vim \
curl git zip \
&& apt-get clean \
&& rm -r /var/lib/apt/lists/* \
\
Expand Down Expand Up @@ -48,14 +49,21 @@ ADD https://github.com/smarty-gettext/smarty-gettext/raw/master/function.locale.
# Install Smarty
RUN chmod a+r /usr/share/php/smarty/libs/plugins/block.t.php /usr/share/php/smarty/libs/plugins/function.locale.php

# Install Composer
RUN curl -sS https://getcomposer.org/installer | php \
&& chmod +x composer.phar && mv composer.phar /usr/local/bin/composer

# Install site
COPY website/ /var/www/html/

WORKDIR /var/www/html
RUN composer install --no-scripts

ARG GIT_COMMIT='unspecified'
RUN chown www-data \
/var/www/html/templates/compile/ \
RUN chown -R www-data /var/www/html/templates/compile/ \
/var/www/html/templates/htmlpurifier/library/HTMLPurifier/DefinitionCache/Serializer/ \
/var/www/html/templates/cache \
/var/www/html/vendor \
&& echo $GIT_COMMIT > /var/www/html/git-version

# to use it without docker-compose : docker run -it --rm --name geokrety -p 80:80 -v $(pwd)/website:/var/www/html/ geokrety
79 changes: 76 additions & 3 deletions INSTALL.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ Create your own PHP configuration:
* create a local geokrety server ([custom](Dockerfile) [apache+php5](https://hub.docker.com/_/php/), [mariadb](https://hub.docker.com/_/mariadb/), [adminer](https://hub.docker.com/_/adminer/))

````
./install.sh
./install.sh
````

* the script will output you server ip and how to connect to your geokrety instance.
Expand All @@ -56,11 +56,84 @@ Create your own PHP configuration:
### Update GeoKrety docker-machine content (website and configs)

````
./update.sh
./update.sh
````

### Update GeoKrety docker-machine one file

````
./update.sh onefile ruchy.php
````

### Update GeoKrety docker-machine content (scripts)

Requirements: having done git clone of [geokrety-scripts repository](https://github.com/geokrety/geokrety-scripts) into `../geokrety-scripts/`

````
./update.sh scripts
````

### Fix GeoKrety docker-machine directory/file rights (docker scp workaround)

````
./update.sh rights
````

### Uninstall GeoKrety docker-machine

````
./install.sh revert
````
````

# How to install contributors tools on Windows host

For out-of-install scope contributors details, please see also [CONTRIBUTING.md](CONTRIBUTING.md)

### Php 7

As php is for now only installed onto docker container, you will need to install it on windows too:

* download and install PHP7 from [windows.php.net](https://windows.php.net/download/)
* add php 7.2 installation directory to you path, example:

````
export PATH=$PATH:/C/tools/php7
php --version
````

### Use Composer

* download Composer-Setup.exe from [getcomposer.org](https://getcomposer.org/doc/00-intro.md)
* installation will ask you to confirm the php7 path

### Run Composer

* composer is able to manage php dependencies, and dependencies are described into `composer.json`
* go to geokrety-website root directory to run composer

````
composer install
````

This action will install the following tools/libraries:
* Php Coding Standard Fixer aka. [php-cs-fixer](https://github.com/FriendsOfPHP/PHP-CS-Fixer)
* [PHPUnit](https://phpunit.de/manual/6.5/fr/installation.html)

### Run Php Coding Standard Fixer

* to launch code standard fixer

````
vendor/bin/php-cs-fixer fix --diff -v
````

### Use PHPUnit

* to launch PHP OO unit tests:

````
vendor/bin/phpunit
````

PHPUnit configuration is located inside `phpunit.xml`.

15 changes: 15 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,21 @@
GIT_COMMIT := $(shell git rev-parse --short HEAD)


buildboly38:
docker-compose -f docker-compose.boly38.yml build --build-arg GIT_COMMIT=$(GIT_COMMIT) geokrety-boly38

startboly38: buildboly38
docker-compose -f docker-compose.boly38.yml --project-name=gk-boly38 up -d geokrety-boly38

stopboly38:
docker-compose -f docker-compose.boly38.yml --project-name=gk-boly38 down

updateboly38: buildboly38
docker-compose -f docker-compose.boly38.yml --project-name=gk-boly382 up -d geokrety-boly38
docker-compose -f docker-compose.boly38.yml --project-name=gk-boly38 up -d geokrety-boly38
docker-compose -f docker-compose.boly38.yml --project-name=gk-boly382 down


builddev:
docker-compose -f docker-compose.dev.yml build --build-arg GIT_COMMIT=$(GIT_COMMIT) geokrety-dev

Expand Down
14 changes: 14 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"config": {
"platform": {
"php": "5.6.32"
}
},
"require": {
"friendsofphp/php-cs-fixer": "v2.11.1",
"phpunit/phpunit": "5.7.27"
},
"autoload": {
"files": ["website/vendor/autoload.php"]
}
}
Loading

0 comments on commit 1be68fe

Please sign in to comment.