diff --git a/.gitignore b/.gitignore index 54a84d9..270d91b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,6 @@ +.vagrant/ +*.log + /app/bootstrap.php.cache /app/config/parameters.yml /build/ diff --git a/.travis.yml b/.travis.yml index 8745ddb..aee265b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -38,7 +38,7 @@ before_install: # Create database, schema and fixtures install: - composer install -q - - cp app/config/parameters.yml.dist app/config/parameters.yml + - cp app/config/parameters.yml.test app/config/parameters.yml # Run script script: diff --git a/README.md b/README.md index ce4e86a..69ded04 100644 --- a/README.md +++ b/README.md @@ -30,3 +30,12 @@ if your dev installation is older than 2015-05-15 you will need to add the initi php app/console do:mi:version --add 20150515104913 ``` +development setup (vagrant) +--------------------------- +Prerequirements: Vagrant installed, Virtualbox installed, Ansible installed + +* ```vagrant up``` +* ```vagrant ssh``` +* ```cd /srv/www``` +* ```bin/console fo:us:cr``` (follow the steps) +* run https://mental.www/app_dev.php in browser and log in with your credentials \ No newline at end of file diff --git a/Vagrantfile b/Vagrantfile new file mode 100644 index 0000000..b77bc9e --- /dev/null +++ b/Vagrantfile @@ -0,0 +1,19 @@ +Vagrant.configure("2") do |config| + config.vm.box = "ubuntu/bionic64" + + unless Vagrant.has_plugin?("vagrant_hostupdater") + config.vm.hostname = "mental.www" + end + + config.vm.network "private_network", ip: "192.168.179.2" + config.vm.network "forwarded_port", guest: 80, host: 8888 + + config.vm.synced_folder ".", "/srv/www", :nfs => true + + config.vm.provision "shell", inline: "which python || sudo apt -y install python" + + config.vm.provision "ansible" do |ansible| + ansible.playbook = "ansible/playbook.yml" + end + +end diff --git a/ansible/playbook.retry b/ansible/playbook.retry new file mode 100644 index 0000000..4ad96d5 --- /dev/null +++ b/ansible/playbook.retry @@ -0,0 +1 @@ +default diff --git a/ansible/playbook.yml b/ansible/playbook.yml new file mode 100644 index 0000000..072e82a --- /dev/null +++ b/ansible/playbook.yml @@ -0,0 +1,12 @@ +- hosts: all + become: yes + vars_files: + - vars/main.yml + roles: + - { role: geerlingguy.nginx } + - { role: geerlingguy.mysql } + - { role: geerlingguy.php } + - { role: geerlingguy.composer } + - { role: ocha.yarn } + - { role: memcached } + - { role: initproject } diff --git a/ansible/requirements.yml b/ansible/requirements.yml new file mode 100644 index 0000000..1c94bb0 --- /dev/null +++ b/ansible/requirements.yml @@ -0,0 +1,6 @@ +- geerlingguy.mysql +- geerlingguy.nginx +- geerlingguy.php +- geerlingguy.php-versions +- ocha.yarn +- geerlingguy.composer diff --git a/ansible/roles/initproject/tasks/main.yaml b/ansible/roles/initproject/tasks/main.yaml new file mode 100644 index 0000000..c9b4f21 --- /dev/null +++ b/ansible/roles/initproject/tasks/main.yaml @@ -0,0 +1,14 @@ +--- +- composer: + command: install + working_dir: /srv/www/ + +- name: create database + command: bin/console do:da:cr --if-not-exists + args: + chdir: /srv/www/ + +- name: run migrations + command: bin/console --no-interaction do:mi:mi + args: + chdir: /srv/www/ diff --git a/ansible/roles/memcached/tasks/main.yaml b/ansible/roles/memcached/tasks/main.yaml new file mode 100644 index 0000000..4d46ab2 --- /dev/null +++ b/ansible/roles/memcached/tasks/main.yaml @@ -0,0 +1,4 @@ +--- +- name: install memcached + apt: + name: memcached \ No newline at end of file diff --git a/ansible/vars/main.yml b/ansible/vars/main.yml new file mode 100644 index 0000000..11658ac --- /dev/null +++ b/ansible/vars/main.yml @@ -0,0 +1,62 @@ +mysql_root_password: root + +mysql_databases: +- name: mental + encoding: utf8 + collation: utf8_general_ci + +mysql_users: +- name: root + host: "%" + password: root + priv: "mental.*:ALL" + +nginx_vhosts: +- listen: "443 ssl http2" + server_name: "mental.www" + root: "/srv/www/web" + index: "app_dev.php" + state: "present" + template: "{{ nginx_vhost_template }}" + filename: "mental.www.conf" + extra_parameters: | + location / { + try_files $uri /app.php$is_args$args; + } + location ~ ^/(app_dev|config)\.php(/|$) { + fastcgi_split_path_info ^(.+\.php)(/.*)$; + fastcgi_pass 127.0.0.1:9000; + fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name; + fastcgi_param DOCUMENT_ROOT $realpath_root; + include fastcgi_params; + } + location ~ \.php$ { + return 404; + } + ssl_certificate /etc/ssl/certs/ssl-cert-snakeoil.pem; + ssl_certificate_key /etc/ssl/private/ssl-cert-snakeoil.key; + ssl_protocols TLSv1.1 TLSv1.2; + ssl_ciphers HIGH:!aNULL:!MD5; + +php_packages_state: "latest" +php_webserver_daemon: "nginx" +php_version: "7.2" +php_default_version_debian: "7.2" +php_enable_php_fpm: true +php_memory_limit: "128M" +php_max_execution_time: "90" +php_upload_max_filesize: "256M" +php_packages: +- php +- php-fpm +- php-cli +- php-common +- php-gd +- php-mbstring +- php-pdo +- php-xml +- php-mysql +- php-apcu +- php-curl +- php-memcached +- php-zip diff --git a/app/config/parameters.yml.dist b/app/config/parameters.yml.dist index 83a2979..edc7236 100644 --- a/app/config/parameters.yml.dist +++ b/app/config/parameters.yml.dist @@ -2,10 +2,10 @@ parameters: database_driver: pdo_mysql database_host: 127.0.0.1 database_port: ~ - database_name: symfony + database_name: mental database_name_testing: symfony database_user: root - database_password: ~ + database_password: root database_platform: 5.6 mailer_transport: smtp diff --git a/app/config/parameters.yml.test b/app/config/parameters.yml.test new file mode 100644 index 0000000..229beba --- /dev/null +++ b/app/config/parameters.yml.test @@ -0,0 +1,23 @@ +parameters: + database_driver: pdo_mysql + database_host: 127.0.0.1 + database_port: ~ + database_name: mental + database_name_testing: symfony + database_user: root + database_password: ~ + database_platform: 5.6 + + mailer_transport: smtp + mailer_host: localhost + mailer_user: ~ + mailer_password: ~ + + locale: en + secret: Ohthaechoosheekohngov2iepaothae5ahd5ya9kie + + session_memcache_host: localhost + session_memcache_port: 11211 + session_memcache_prefix: mn_sess + session_memcache_expire: 604800 # 1 week + diff --git a/src/AppBundle/Entity/Entry.php b/src/AppBundle/Entity/Entry.php index 17576de..b33979f 100644 --- a/src/AppBundle/Entity/Entry.php +++ b/src/AppBundle/Entity/Entry.php @@ -26,7 +26,7 @@ class Entry extends AbstractEntity private $id; /** - * @ORM\Column(type="string", length=500) + * @ORM\Column(type="string", length=2048) * @Assert\Url */ private $url; diff --git a/web/app_dev.php b/web/app_dev.php index 8456754..9be457d 100644 --- a/web/app_dev.php +++ b/web/app_dev.php @@ -12,7 +12,7 @@ // Feel free to remove this, extend it, or make something more sophisticated. if (isset($_SERVER['HTTP_CLIENT_IP']) || isset($_SERVER['HTTP_X_FORWARDED_FOR']) - || !(in_array(@$_SERVER['REMOTE_ADDR'], ['127.0.0.1', 'fe80::1', '::1']) || php_sapi_name() === 'cli-server') + || !(in_array(@$_SERVER['REMOTE_ADDR'], ['192.168.179.1', '127.0.0.1', 'fe80::1', '::1']) || php_sapi_name() === 'cli-server') ) { header('HTTP/1.0 403 Forbidden'); exit('You are not allowed to access this file. Check '.basename(__FILE__).' for more information.');