Major changes

This commit is contained in:
Marwolf
2018-07-06 12:59:16 -04:00
parent f73daed67b
commit 9b2fa50740
11 changed files with 50 additions and 181 deletions

20
.gitignore vendored
View File

@@ -2,18 +2,11 @@
.*.swp .*.swp
.DS_Store .DS_Store
# Application # Website
web/app/composer.json Open-RSC-Website
web/app/composer.lock
web/app/vendor/
web/app/doc/
web/app/report/
data/
# PHPStorm # Game
.idea/**/workspace.xml Open-RSC
.idea/**/tasks.xml
.idea/dictionaries
# Netbeans # Netbeans
nbproject/ nbproject/
@@ -22,4 +15,7 @@ nbproject/
/nbproject/private/private.properties /nbproject/private/private.properties
# SSL Certs # SSL Certs
etc/ssl/ etc/ssl/
# Database
data

View File

@@ -10,48 +10,34 @@ help:
@echo "usage: make COMMAND" @echo "usage: make COMMAND"
@echo "" @echo ""
@echo "Commands:" @echo "Commands:"
@echo " apidoc Generate documentation of API" @echo " pull Get the latest GitHub repos"
@echo " code-sniff Check the API with PHP Code Sniffer (PSR2)" @echo " start Create and start containers"
@echo " clean Clean directories for reset" @echo " stop Stop all services"
@echo " composer-up Update PHP dependencies with composer" @echo " restart Restart containers"
@echo " docker-start Create and start containers"
@echo " docker-stop Stop and clear all services"
@echo " gen-certs Generate SSL certificates"
@echo " logs Follow log output" @echo " logs Follow log output"
@echo " mysql-dump Create backup of all databases" @echo " import Import all databases from the GitHub repos"
@echo " mysql-restore Restore backup of all databases" @echo " dump Create backup of all local databases"
@echo " phpmd Analyse the API with PHP Mess Detector" @echo " restore Restore backup of all local databases"
@echo " test Test application"
init: start: init
@$(shell cp -n $(shell pwd)/web/app/composer.json.dist $(shell pwd)/web/app/composer.json 2> /dev/null)
apidoc:
@docker-compose exec -T php php -d memory_limit=256M -d xdebug.profiler_enable=0 ./app/vendor/bin/apigen generate app/src --destination app/doc
@make resetOwner
clean:
@rm -Rf data/db/mysql/*
@rm -Rf $(MYSQL_DUMPS_DIR)/*
@rm -Rf web/app/vendor
@rm -Rf web/app/composer.lock
@rm -Rf web/app/doc
@rm -Rf web/app/report
@rm -Rf etc/ssl/*
code-sniff:
@echo "Checking the standard code..."
@docker-compose exec -T php ./app/vendor/bin/phpcs -v --standard=PSR2 app/src
composer-up:
@docker run --rm -v $(shell pwd)/web/app:/app composer update
docker-start: init
docker-compose up -d docker-compose up -d
docker-stop: stop:
@docker-compose down -v @docker-compose down -v
@make clean
restart:
@docker-compose down -v
docker-compose up -d
pull:
@$(shell git clone https://github.com/Marwolf/Open-RSC-Website.git)
cd Open-RSC-Website
git pull
cd ..
@$(shell git clone https://github.com/Marwolf/Open-RSC)
cd Open-RSC
git pull
cd ..
gen-certs: gen-certs:
@docker run --rm -v $(shell pwd)/etc/ssl:/certificates -e "SERVER=$(NGINX_HOST)" jacoelho/generate-certificate @docker run --rm -v $(shell pwd)/etc/ssl:/certificates -e "SERVER=$(NGINX_HOST)" jacoelho/generate-certificate
@@ -59,25 +45,21 @@ gen-certs:
logs: logs:
@docker-compose logs -f @docker-compose logs -f
mysql-dump: dump:
@mkdir -p $(MYSQL_DUMPS_DIR) @mkdir -p $(MYSQL_DUMPS_DIR)
@docker exec $(shell docker-compose ps -q mysqldb) mysqldump --all-databases -u"$(MYSQL_ROOT_USER)" -p"$(MYSQL_ROOT_PASSWORD)" > $(MYSQL_DUMPS_DIR)/db.sql 2>/dev/null @docker exec $(shell docker-compose ps -q mysqldb) mysqldump --all-databases -u"$(MYSQL_ROOT_USER)" -p"$(MYSQL_ROOT_PASSWORD)" > $(MYSQL_DUMPS_DIR)/db.sql 2>/dev/null
@make resetOwner @make resetOwner
mysql-restore: restore:
@docker exec -i $(shell docker-compose ps -q mysqldb) mysql -u"$(MYSQL_ROOT_USER)" -p"$(MYSQL_ROOT_PASSWORD)" < $(MYSQL_DUMPS_DIR)/db.sql 2>/dev/null @docker exec -i $(shell docker-compose ps -q mysqldb) mysql -u"$(MYSQL_ROOT_USER)" -p"$(MYSQL_ROOT_PASSWORD)" < $(MYSQL_DUMPS_DIR)/db.sql 2>/dev/null
phpmd: import:
@docker-compose exec -T php \ @docker exec -i $(shell docker-compose ps -q mysqldb) mysql -u"$(MYSQL_ROOT_USER)" -p"$(MYSQL_ROOT_PASSWORD)" < Open-RSC/Databases/openrsc_config.sql 2>/dev/null
./app/vendor/bin/phpmd \ @docker exec -i $(shell docker-compose ps -q mysqldb) mysql -u"$(MYSQL_ROOT_USER)" -p"$(MYSQL_ROOT_PASSWORD)" < Open-RSC/Databases/openrsc_logs.sql 2>/dev/null
./app/src \ @docker exec -i $(shell docker-compose ps -q mysqldb) mysql -u"$(MYSQL_ROOT_USER)" -p"$(MYSQL_ROOT_PASSWORD)" < Open-RSC/Databases/openrsc.sql 2>/dev/null
text cleancode,codesize,controversial,design,naming,unusedcode @docker exec -i $(shell docker-compose ps -q mysqldb) mysql -u"$(MYSQL_ROOT_USER)" -p"$(MYSQL_ROOT_PASSWORD)" < Open-RSC-Website/openrsc_forum.sql 2>/dev/null
test: code-sniff
@docker-compose exec -T php ./app/vendor/bin/phpunit --colors=always --configuration ./app/
@make resetOwner
resetOwner: resetOwner:
@$(shell chown -Rf $(SUDO_USER):$(shell id -g -n $(SUDO_USER)) $(MYSQL_DUMPS_DIR) "$(shell pwd)/etc/ssl" "$(shell pwd)/web/app" 2> /dev/null) @$(shell chown -Rf $(SUDO_USER):$(shell id -g -n $(SUDO_USER)) $(MYSQL_DUMPS_DIR) "$(shell pwd)/etc/ssl" 2> /dev/null)
.PHONY: clean test code-sniff init .PHONY: clean test code-sniff init

View File

@@ -5,11 +5,11 @@ services:
volumes: volumes:
- "./etc/nginx/default.conf:/etc/nginx/conf.d/default.conf" - "./etc/nginx/default.conf:/etc/nginx/conf.d/default.conf"
- "./etc/ssl:/etc/ssl" - "./etc/ssl:/etc/ssl"
- "./web:/var/www/html" - "./Open-RSC-Website:/var/www/html/public"
- "./etc/nginx/default.template.conf:/etc/nginx/conf.d/default.template" - "./etc/nginx/default.template.conf:/etc/nginx/conf.d/default.template"
ports: ports:
- "8000:80" - "80:80"
- "3000:443" - "443:443"
environment: environment:
- NGINX_HOST=${NGINX_HOST} - NGINX_HOST=${NGINX_HOST}
command: /bin/sh -c "envsubst '$$NGINX_HOST' < /etc/nginx/conf.d/default.template > /etc/nginx/conf.d/default.conf && nginx -g 'daemon off;'" command: /bin/sh -c "envsubst '$$NGINX_HOST' < /etc/nginx/conf.d/default.template > /etc/nginx/conf.d/default.conf && nginx -g 'daemon off;'"
@@ -22,12 +22,7 @@ services:
restart: always restart: always
volumes: volumes:
- "./etc/php/php.ini:/usr/local/etc/php/conf.d/php.ini" - "./etc/php/php.ini:/usr/local/etc/php/conf.d/php.ini"
- "./web:/var/www/html" - "./Open-RSC-Website:/var/www/html/public"
composer:
image: "composer"
volumes:
- "./web/app:/app"
command: install
myadmin: myadmin:
image: phpmyadmin/phpmyadmin image: phpmyadmin/phpmyadmin
container_name: phpmyadmin container_name: phpmyadmin
@@ -51,6 +46,6 @@ services:
- MYSQL_USER=${MYSQL_USER} - MYSQL_USER=${MYSQL_USER}
- MYSQL_PASSWORD=${MYSQL_PASSWORD} - MYSQL_PASSWORD=${MYSQL_PASSWORD}
ports: ports:
- "8989:3306" - "3306:3306"
volumes: volumes:
- "./data/db/mysql:/var/lib/mysql" - "./data/db/mysql:/var/lib/mysql"

View File

@@ -21,7 +21,7 @@ server {
} }
} }
# server { # server { #SSL configuration below
# server_name localhost; # server_name localhost;
# listen 443 ssl; # listen 443 ssl;
@@ -45,4 +45,4 @@ server {
# fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; # fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
# fastcgi_param PATH_INFO $fastcgi_path_info; # fastcgi_param PATH_INFO $fastcgi_path_info;
# } # }
# } # }

View File

@@ -21,7 +21,7 @@ server {
} }
} }
# server { # server { #SSL configuration below
# server_name ${NGINX_HOST}; # server_name ${NGINX_HOST};
# listen 443 ssl; # listen 443 ssl;
@@ -45,4 +45,4 @@ server {
# fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; # fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
# fastcgi_param PATH_INFO $fastcgi_path_info; # fastcgi_param PATH_INFO $fastcgi_path_info;
# } # }
# } # }

View File

@@ -1,24 +0,0 @@
{
"require": {
},
"require-dev": {
"apigen/apigen": "dev-master",
"phpmd/phpmd": "@stable",
"phpunit/phpunit": "^7.0",
"roave/better-reflection": "dev-master#c87d856",
"squizlabs/php_codesniffer": "3.*"
},
"autoload": {
"psr-4": {
"App\\Acme\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"AppTest\\Acme\\": "test/"
}
},
"minimum-stability": "stable",
"prefer-stable": true
}

View File

@@ -1,31 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="./vendor/phpunit/phpunit/phpunit.xsd"
bootstrap="test/bootstrap.php"
colors="true">
<testsuites>
<testsuite name="PHP Test suite">
<directory>./test/</directory>
</testsuite>
</testsuites>
<filter>
<whitelist addUncoveredFilesFromWhitelist="false">
<directory suffix=".php">./src</directory>
<exclude>
<directory suffix=".php">./vendor</directory>
</exclude>
</whitelist>
</filter>
<php>
<ini name="date.timezone" value="UTC"/>
</php>
<logging>
<log type="coverage-html" target="./report/phpunit" charset="UTF-8" yui="true" highlight="true"/>
<log type="coverage-text" target="php://stdout" showUncoveredFiles="false"/>
</logging>
</phpunit>

View File

@@ -1,11 +0,0 @@
<?php
namespace App\Acme;
class Foo
{
public function getName()
{
return 'Nginx PHP MySQL';
}
}

View File

@@ -1,15 +0,0 @@
<?php
namespace AppTest\Acme;
use App\Acme\Foo;
use PHPUnit\Framework\TestCase;
class FooTest extends TestCase
{
public function testGetName()
{
$foo = new Foo();
$this->assertEquals($foo->getName(), 'Nginx PHP MySQL');
}
}

View File

@@ -1,8 +0,0 @@
<?php
error_reporting(E_ALL | E_STRICT);
/**
* Setup autoloading
*/
require __DIR__ . '/../vendor/autoload.php';

View File

@@ -1,15 +0,0 @@
<?php
include '../app/vendor/autoload.php';
$foo = new App\Acme\Foo();
?><!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Docker <?php echo $foo->getName(); ?></title>
</head>
<body>
<h1>Docker <?php echo $foo->getName(); ?></h1>
</body>
</html>