From 9b2fa50740442f21718ac5c5694cbc14b7716562 Mon Sep 17 00:00:00 2001 From: Marwolf Date: Fri, 6 Jul 2018 12:59:16 -0400 Subject: [PATCH] Major changes --- .gitignore | 20 ++++---- Makefile | 82 +++++++++++++-------------------- docker-compose.yml | 17 +++---- etc/nginx/default.conf | 4 +- etc/nginx/default.template.conf | 4 +- web/app/composer.json.dist | 24 ---------- web/app/phpunit.xml.dist | 31 ------------- web/app/src/Foo.php | 11 ----- web/app/test/FooTest.php | 15 ------ web/app/test/bootstrap.php | 8 ---- web/public/index.php | 15 ------ 11 files changed, 50 insertions(+), 181 deletions(-) delete mode 100644 web/app/composer.json.dist delete mode 100644 web/app/phpunit.xml.dist delete mode 100644 web/app/src/Foo.php delete mode 100644 web/app/test/FooTest.php delete mode 100644 web/app/test/bootstrap.php delete mode 100644 web/public/index.php diff --git a/.gitignore b/.gitignore index 7fbb785..e655bf4 100644 --- a/.gitignore +++ b/.gitignore @@ -2,18 +2,11 @@ .*.swp .DS_Store -# Application -web/app/composer.json -web/app/composer.lock -web/app/vendor/ -web/app/doc/ -web/app/report/ -data/ +# Website +Open-RSC-Website -# PHPStorm -.idea/**/workspace.xml -.idea/**/tasks.xml -.idea/dictionaries +# Game +Open-RSC # Netbeans nbproject/ @@ -22,4 +15,7 @@ nbproject/ /nbproject/private/private.properties # SSL Certs -etc/ssl/ \ No newline at end of file +etc/ssl/ + +# Database +data diff --git a/Makefile b/Makefile index 86b5d3c..d3f08ef 100644 --- a/Makefile +++ b/Makefile @@ -10,48 +10,34 @@ help: @echo "usage: make COMMAND" @echo "" @echo "Commands:" - @echo " apidoc Generate documentation of API" - @echo " code-sniff Check the API with PHP Code Sniffer (PSR2)" - @echo " clean Clean directories for reset" - @echo " composer-up Update PHP dependencies with composer" - @echo " docker-start Create and start containers" - @echo " docker-stop Stop and clear all services" - @echo " gen-certs Generate SSL certificates" + @echo " pull Get the latest GitHub repos" + @echo " start Create and start containers" + @echo " stop Stop all services" + @echo " restart Restart containers" @echo " logs Follow log output" - @echo " mysql-dump Create backup of all databases" - @echo " mysql-restore Restore backup of all databases" - @echo " phpmd Analyse the API with PHP Mess Detector" - @echo " test Test application" + @echo " import Import all databases from the GitHub repos" + @echo " dump Create backup of all local databases" + @echo " restore Restore backup of all local databases" -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 +start: init docker-compose up -d -docker-stop: +stop: @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: @docker run --rm -v $(shell pwd)/etc/ssl:/certificates -e "SERVER=$(NGINX_HOST)" jacoelho/generate-certificate @@ -59,25 +45,21 @@ gen-certs: logs: @docker-compose logs -f -mysql-dump: +dump: @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 @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 -phpmd: - @docker-compose exec -T php \ - ./app/vendor/bin/phpmd \ - ./app/src \ - text cleancode,codesize,controversial,design,naming,unusedcode - -test: code-sniff - @docker-compose exec -T php ./app/vendor/bin/phpunit --colors=always --configuration ./app/ - @make resetOwner +import: + @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 + @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 + @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 + @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 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 \ No newline at end of file +.PHONY: clean test code-sniff init diff --git a/docker-compose.yml b/docker-compose.yml index b30cd57..32d3586 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -5,11 +5,11 @@ services: volumes: - "./etc/nginx/default.conf:/etc/nginx/conf.d/default.conf" - "./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" ports: - - "8000:80" - - "3000:443" + - "80:80" + - "443:443" environment: - 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;'" @@ -22,12 +22,7 @@ services: restart: always volumes: - "./etc/php/php.ini:/usr/local/etc/php/conf.d/php.ini" - - "./web:/var/www/html" - composer: - image: "composer" - volumes: - - "./web/app:/app" - command: install + - "./Open-RSC-Website:/var/www/html/public" myadmin: image: phpmyadmin/phpmyadmin container_name: phpmyadmin @@ -51,6 +46,6 @@ services: - MYSQL_USER=${MYSQL_USER} - MYSQL_PASSWORD=${MYSQL_PASSWORD} ports: - - "8989:3306" + - "3306:3306" volumes: - - "./data/db/mysql:/var/lib/mysql" \ No newline at end of file + - "./data/db/mysql:/var/lib/mysql" diff --git a/etc/nginx/default.conf b/etc/nginx/default.conf index 1088f8f..aaf83ab 100644 --- a/etc/nginx/default.conf +++ b/etc/nginx/default.conf @@ -21,7 +21,7 @@ server { } } -# server { +# server { #SSL configuration below # server_name localhost; # listen 443 ssl; @@ -45,4 +45,4 @@ server { # fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; # fastcgi_param PATH_INFO $fastcgi_path_info; # } -# } \ No newline at end of file +# } diff --git a/etc/nginx/default.template.conf b/etc/nginx/default.template.conf index 2a48589..4eaa0bf 100644 --- a/etc/nginx/default.template.conf +++ b/etc/nginx/default.template.conf @@ -21,7 +21,7 @@ server { } } -# server { +# server { #SSL configuration below # server_name ${NGINX_HOST}; # listen 443 ssl; @@ -45,4 +45,4 @@ server { # fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; # fastcgi_param PATH_INFO $fastcgi_path_info; # } -# } \ No newline at end of file +# } diff --git a/web/app/composer.json.dist b/web/app/composer.json.dist deleted file mode 100644 index 276080e..0000000 --- a/web/app/composer.json.dist +++ /dev/null @@ -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 -} \ No newline at end of file diff --git a/web/app/phpunit.xml.dist b/web/app/phpunit.xml.dist deleted file mode 100644 index 57e9bf1..0000000 --- a/web/app/phpunit.xml.dist +++ /dev/null @@ -1,31 +0,0 @@ - - - - - - ./test/ - - - - - - ./src - - ./vendor - - - - - - - - - - - - - diff --git a/web/app/src/Foo.php b/web/app/src/Foo.php deleted file mode 100644 index f94d679..0000000 --- a/web/app/src/Foo.php +++ /dev/null @@ -1,11 +0,0 @@ -assertEquals($foo->getName(), 'Nginx PHP MySQL'); - } -} diff --git a/web/app/test/bootstrap.php b/web/app/test/bootstrap.php deleted file mode 100644 index 5106c0e..0000000 --- a/web/app/test/bootstrap.php +++ /dev/null @@ -1,8 +0,0 @@ - - - - - Docker <?php echo $foo->getName(); ?> - - -

Docker getName(); ?>

- -