├── machine ├── application │ ├── app-php │ │ ├── .gitignore │ │ ├── public │ │ │ ├── phpinfo.php │ │ │ ├── index.html │ │ │ └── index.php │ │ ├── composer.json │ │ ├── healthcheck.php │ │ └── composer.lock │ └── app-node │ │ ├── .gitignore │ │ ├── package.json │ │ ├── app.js │ │ └── package-lock.json ├── ansible │ ├── roles │ │ ├── server │ │ │ ├── files │ │ │ │ └── cachefilesd │ │ │ ├── templates │ │ │ │ └── timezone.j2 │ │ │ ├── defaults │ │ │ │ └── main.yml │ │ │ ├── handlers │ │ │ │ └── main.yml │ │ │ └── tasks │ │ │ │ ├── cachefilesd.yml │ │ │ │ └── main.yml │ │ ├── xdebug │ │ │ ├── defaults │ │ │ │ └── main.yml │ │ │ └── tasks │ │ │ │ └── main.yml │ │ ├── app-node │ │ │ ├── meta │ │ │ │ └── main.yml │ │ │ ├── tasks │ │ │ │ ├── main.yml │ │ │ │ ├── dependencies.yml │ │ │ │ └── systemd-service.yml │ │ │ ├── handlers │ │ │ │ └── main.yml │ │ │ └── templates │ │ │ │ └── app-node.service.j2 │ │ ├── app-php │ │ │ ├── tasks │ │ │ │ ├── main.yml │ │ │ │ ├── dependencies.yml │ │ │ │ └── nginx-site.yml │ │ │ ├── meta │ │ │ │ └── main.yml │ │ │ ├── handlers │ │ │ │ └── main.yml │ │ │ └── templates │ │ │ │ └── nginx.default.j2 │ │ ├── nginx │ │ │ ├── handlers │ │ │ │ └── main.yml │ │ │ └── tasks │ │ │ │ └── main.yml │ │ ├── redis │ │ │ ├── handlers │ │ │ │ └── main.yml │ │ │ ├── tasks │ │ │ │ ├── setup.yml │ │ │ │ └── main.yml │ │ │ ├── defaults │ │ │ │ └── main.yml │ │ │ └── templates │ │ │ │ └── redis.conf.j2 │ │ ├── composer │ │ │ ├── templates │ │ │ │ └── auth.json.j2 │ │ │ └── tasks │ │ │ │ └── main.yml │ │ ├── mysql │ │ │ ├── handlers │ │ │ │ └── main.yml │ │ │ ├── templates │ │ │ │ └── mysqld.conf.j2 │ │ │ └── tasks │ │ │ │ ├── dump-import.yml │ │ │ │ └── main.yml │ │ ├── mongodb │ │ │ ├── handlers │ │ │ │ └── main.yml │ │ │ ├── templates │ │ │ │ └── mongod.conf.j2 │ │ │ └── tasks │ │ │ │ ├── main.yml │ │ │ │ └── dump-import.yml │ │ ├── nodejs │ │ │ ├── templates │ │ │ │ └── npm.sh.j2 │ │ │ ├── tasks │ │ │ │ ├── yarn.yml │ │ │ │ ├── setup.yml │ │ │ │ └── main.yml │ │ │ └── defaults │ │ │ │ └── main.yml │ │ └── php │ │ │ ├── handlers │ │ │ └── main.yml │ │ │ ├── tasks │ │ │ ├── configure.yml │ │ │ ├── php-cli.yml │ │ │ ├── main.yml │ │ │ └── php-fpm.yml │ │ │ └── defaults │ │ │ └── main.yml │ ├── inventory │ │ ├── hosts │ │ └── ansible.cfg │ ├── vars │ │ ├── locals.yml.dist │ │ └── globals.yml │ ├── playbook.yml │ └── files │ │ ├── authorized_keys │ │ └── ansible.sh └── dump │ ├── mongodb │ ├── example_collection_1.json │ └── example_collection_2.json │ └── mysql.sql ├── .gitignore ├── .editorconfig ├── Vagrantfile └── README.md /machine/application/app-php/.gitignore: -------------------------------------------------------------------------------- 1 | vendor 2 | -------------------------------------------------------------------------------- /machine/ansible/roles/server/files/cachefilesd: -------------------------------------------------------------------------------- 1 | RUN=yes 2 | -------------------------------------------------------------------------------- /machine/application/app-node/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | -------------------------------------------------------------------------------- /machine/ansible/inventory/hosts: -------------------------------------------------------------------------------- 1 | [vagrant] 2 | 10.10.10.10 3 | -------------------------------------------------------------------------------- /machine/application/app-php/public/phpinfo.php: -------------------------------------------------------------------------------- 1 | 2 | 3 |
4 | 5 |${err}`);
64 | })
65 | .finally(() => {
66 | response.end();
67 | mySqlClient.end();
68 | redisClient.end(true);
69 | mongoDb.close();
70 | });
71 | });
72 |
73 | server.listen(PORT, (err) => {
74 | if (err) {
75 | console.error('Something bad happened: %o', err)
76 | } else {
77 | console.info(`Server is listening on %d`, PORT)
78 | }
79 | });
80 |
--------------------------------------------------------------------------------
/Vagrantfile:
--------------------------------------------------------------------------------
1 | require 'yaml'
2 | VAGRANTFILE_API_VERSION = "2"
3 |
4 | # If you want to use 'nfs' synchronization on Linux systems
5 | # Ubuntu: apt-get -y install nfs-kernel-server nfs-common
6 | # CentOS: yum -y install nfs-utils nfs-utils-lib
7 | # Mac OS X: it should be already pre-installed
8 |
9 | # The host name (you should also change it in the machine/ansible/vars/globals.yml)
10 | HOSTNAME = 'phanbox.local'
11 | ALIASES = %w(www.phanbox.local api.phanbox.local)
12 |
13 | # Allocate hardware resources for the virtual machine
14 | CPU = 4
15 | RAM = 4096
16 |
17 | # I don't think you want to change it...
18 | # In case you do change it you also need change it in "machine/ansible/inventory"
19 | IP_ADDRESS = '10.10.10.10'
20 |
21 | # Check to determine whether we're on a windows or linux/os-x host,
22 | # later on we use this to launch ansible in the supported way
23 | # source: https://stackoverflow.com/questions/2108727/which-in-ruby-checking-if-program-exists-in-path-from-ruby
24 | def which(cmd)
25 | exts = ENV['PATHEXT'] ? ENV['PATHEXT'].split(';') : ['']
26 |
27 | ENV['PATH'].split(File::PATH_SEPARATOR).each do |path|
28 | exts.each { |ext|
29 | exe = File.join(path, "#{cmd}#{ext}")
30 | return exe if File.executable? exe
31 | }
32 | end
33 |
34 | return nil
35 | end
36 |
37 | Vagrant.require_version '>= 1.8.5'
38 | Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
39 | # We cannot use can canonical ubuntu/xenial64 as it doesn't provided vagrant user
40 | # despite to vagrant convention that the default user is named always "vagrant"
41 | # https://bugs.launchpad.net/cloud-images/+bug/1569237
42 | config.vm.box = 'bento/ubuntu-16.04'
43 | config.vm.box_version = '2.3.5'
44 | config.vm.hostname = HOSTNAME
45 | config.vm.network :private_network, :ip => IP_ADDRESS
46 |
47 | #config.ssh.insert_key = false
48 | config.ssh.forward_agent = true
49 |
50 | # Prevent TTY Errors (copied from laravel/homestead: "homestead.rb" file)... By default this is "bash -l"
51 | config.ssh.shell = "bash -c 'BASH_ENV=/etc/profile exec bash'"
52 |
53 | # Setup directories synchronization mode
54 | if Vagrant::Util::Platform.windows?
55 | sync_options = {
56 | :mount_options => ["dmode=775", "fmode=775"],
57 | :owner => 'vagrant',
58 | :group => 'vagrant'
59 | }
60 | else
61 | sync_options = {
62 | :nfs => { :mount_options => ["dmode=775", "fmode=775", "actimeo=2", "lookupcache=non", "rw", "vers=3", "tcp", "fsc"] }
63 | }
64 | end
65 |
66 | config.vm.synced_folder "./machine/", "/vagrant/", sync_options
67 |
68 | # Configure VirtualBox provider
69 | config.vm.provider :virtualbox do |vb|
70 | vb.name = HOSTNAME
71 |
72 | vb.customize ["modifyvm", :id, "--cpus", CPU]
73 | vb.customize ["modifyvm", :id, "--memory", RAM]
74 | vb.customize ["modifyvm", :id, "--ioapic", "on"]
75 | vb.customize ["modifyvm", :id, "--cableconnected1", "on"]
76 | vb.customize ["modifyvm", :id, "--natdnshostresolver1", "on"]
77 | vb.customize ["modifyvm", :id, "--natdnsproxy1", "on"]
78 | vb.customize ["modifyvm", :id, "--nictype1", "virtio"]
79 | vb.customize ["modifyvm", :id, "--nictype2", "virtio"]
80 | vb.customize ["guestproperty", "set", :id, "/VirtualBox/GuestAdd/VBoxService/--timesync-set-threshold", 10000]
81 | vb.customize ["guestproperty", "set", :id, "/VirtualBox/GuestAdd/VBoxService/--timesync-interval", 5000]
82 | end
83 |
84 | # Update "hosts" file for host/guest machines
85 | if Vagrant.has_plugin? 'vagrant-hostmanager'
86 | config.hostmanager.enabled = true
87 | config.hostmanager.manage_host = true
88 | config.hostmanager.manage_guest = true
89 | config.hostmanager.ignore_private_ip = false
90 | config.hostmanager.include_offline = true
91 |
92 | if ALIASES.any?
93 | config.hostmanager.aliases = ALIASES
94 | end
95 | end
96 |
97 | # Run Host Manager provision
98 | config.vm.provision :hostmanager
99 |
100 | # If ansible is in your path it will provision from your HOST machine
101 | # If ansible is not found in the path it will be instaled in the VM and provisioned from there
102 | if which('ansible-playbook')
103 | config.vm.provision "ansible" do |ansible|
104 | ansible.playbook = "machine/ansible/playbook.yml"
105 | ansible.inventory_path = "machine/ansible/inventory/hosts"
106 | ansible.limit = 'all'
107 | end
108 | else
109 | config.vm.provision :shell, path: "machine/ansible/files/ansible.sh"
110 | end
111 |
112 | # Parse ansible variables to extract the name of node.js application service
113 | ansible_vars_path = "#{File.dirname(__FILE__)}/machine/ansible/vars/globals.yml"
114 | ansible_vars = YAML.load_file(ansible_vars_path)
115 |
116 | if ansible_vars.has_key?('app_node') and ansible_vars['app_node'].has_key?('service_name')
117 | # Automatically start node.js application when vagrant launched
118 | app_node_service = ansible_vars['app_node']['service_name']
119 | config.vm.provision "shell", run: "always", inline: "systemctl restart #{app_node_service}"
120 | end
121 |
122 | # Always make sure cachefilesd is running
123 | config.vm.provision "shell", run: "always", inline: "systemctl start cachefilesd"
124 | end
125 |
--------------------------------------------------------------------------------
/machine/ansible/roles/php/tasks/php-fpm.yml:
--------------------------------------------------------------------------------
1 | ---
2 | - name: Set permissions on socket - owner
3 | lineinfile: "dest=/etc/php/7.1/fpm/pool.d/www.conf state=present regexp='^;?listen.owner' line='listen.owner = www-data'"
4 |
5 | - name: Set permissions on socket - group
6 | lineinfile: "dest=/etc/php/7.1/fpm/pool.d/www.conf state=present regexp='^;?listen.group' line='listen.group = www-data'"
7 |
8 | - name: Set permissions on socket - mode
9 | lineinfile: "dest=/etc/php/7.1/fpm/pool.d/www.conf state=present regexp='^;?listen.mode' line='listen.mode = 0660'"
10 | notify: restart php7-fpm
11 |
12 | - name: Ensure timezone is set in fpm php.ini
13 | lineinfile: dest=/etc/php/7.1/fpm/php.ini
14 | regexp='date.timezone ='
15 | line='date.timezone = {{ php_timezone }}'
16 |
17 | - name: Enabling opcache
18 | lineinfile: dest=/etc/php/7.1/fpm/php.ini
19 | regexp='^#?opcache.enable='
20 | line='opcache.enable=1'
21 |
22 | - name: Opcache - changing revalidate frequency to 0
23 | lineinfile: dest=/etc/php/7.1/fpm/php.ini
24 | regexp='opcache.revalidate_freq='
25 | line='opcache.revalidate_freq=0'
26 | tags: [ development ]
27 |
28 | - name: Set session.cookie_httponly to `true`
29 | lineinfile: dest=/etc/php/7.1/fpm/php.ini
30 | regexp='session.cookie_httponly(\s)?='
31 | line='session.cookie_httponly=1'
32 | notify: restart php7-fpm
33 |
34 | - name: Enable session strict mode
35 | lineinfile: dest=/etc/php/7.1/fpm/php.ini
36 | regexp='session.use_strict_mode(\s)?='
37 | line='session.use_strict_mode = 1'
38 | notify: restart php7-fpm
39 |
40 | - name: Set allow_url_fopen
41 | lineinfile: dest=/etc/php/7.1/fpm/php.ini
42 | regexp='allow_url_fopen(\s)?='
43 | line='allow_url_fopen = {{ php_allow_url_fopen }}'
44 | notify: restart php7-fpm
45 |
46 | - name: Change soap.wsdl_cache_dir to new directory
47 | lineinfile: dest=/etc/php/7.1/fpm/php.ini
48 | regexp='soap.wsdl_cache_dir(\s)?='
49 | line='soap.wsdl_cache_dir=/php/cache/wsdl'
50 | notify: restart php7-fpm
51 |
52 | - name: Change upload_tmp_dir path
53 | lineinfile: dest=/etc/php/7.1/fpm/php.ini
54 | regexp='upload_tmp_dir(\s)?='
55 | line='upload_tmp_dir=/php/cache/upload_tmp'
56 | notify: restart php7-fpm
57 |
58 | - name: Exclude potentially harmfull php functions
59 | lineinfile: dest=/etc/php/7.1/fpm/php.ini
60 | regexp='disable_functions(\s)?='
61 | line='disable_functions=exec,passthru,shell_exec,system,proc_open,popen'
62 | notify: restart php7-fpm
63 |
64 | - name: Set post_max_size
65 | lineinfile: dest=/etc/php/7.1/fpm/php.ini
66 | regexp='post_max_size(\s)?='
67 | line='post_max_size = {{ php_post_max_size }}'
68 | notify: restart php7-fpm
69 |
70 | - name: Set upload_max_filesize
71 | lineinfile: dest=/etc/php/7.1/fpm/php.ini
72 | regexp='upload_max_filesize(\s)?='
73 | line='upload_max_filesize = {{ php_upload_max_filesize }}'
74 | create=yes
75 | notify: restart php7-fpm
76 |
77 | - name: Set memory_limit
78 | lineinfile: dest=/etc/php/7.1/fpm/php.ini
79 | regexp='memory_limit(\s)?='
80 | line='memory_limit = {{ php_memory_limit }}'
81 | notify: restart php7-fpm
82 |
83 | - name: Set max_execution_time
84 | lineinfile: dest=/etc/php/7.1/fpm/php.ini
85 | regexp='max_execution_time(\s)?='
86 | line='max_execution_time = {{ php_max_execution_time }}'
87 | notify: restart php7-fpm
88 |
89 | - name: enabling opcache
90 | lineinfile: dest=/etc/php/7.1/fpm/php.ini
91 | regexp='opcache.enable='
92 | line='opcache.enable={{ php_opcache_enable }}'
93 | insertafter="^[opcache]"
94 | notify: restart php7-fpm
95 |
96 | - name: opcache - changing revalidate frequency
97 | lineinfile: dest=/etc/php/7.1/fpm/php.ini
98 | regexp='opcache.revalidate_freq='
99 | line='opcache.revalidate_freq={{ php_opcache_revalidate_freq }}'
100 | insertafter="^[opcache]"
101 | notify: restart php7-fpm
102 |
103 | - name: opcache - changing validate timestamps
104 | lineinfile: dest=/etc/php/7.1/fpm/php.ini
105 | regexp='opcache.validate_timestamps='
106 | line='opcache.validate_timestamps={{ php_opcache_opcache_validate_timestamps }}'
107 | insertafter="^[opcache]"
108 | notify: restart php7-fpm
109 |
110 | - name: opcache - changing max accelerated files
111 | lineinfile: dest=/etc/php/7.1/fpm/php.ini
112 | regexp='opcache.max_accelerated_files='
113 | line='opcache.max_accelerated_files={{ php_opcache_max_accelerated_files }}'
114 | insertafter="^[opcache]"
115 | notify: restart php7-fpm
116 |
117 | - name: opcache - memory consumption
118 | lineinfile: dest=/etc/php/7.1/fpm/php.ini
119 | regexp='opcache.memory_consumption='
120 | line='opcache.memory_consumption={{ php_opcache_memory_consumption }}'
121 | insertafter="^[opcache]"
122 | notify: restart php7-fpm
123 |
124 | - name: opcache - interned strings buffer
125 | lineinfile: dest=/etc/php/7.1/fpm/php.ini
126 | regexp='opcache.interned_strings_buffer='
127 | line='opcache.interned_strings_buffer={{ php_opcache_interned_strings_buffer }}'
128 | insertafter="^[opcache]"
129 | notify: restart php7-fpm
130 |
131 | - name: opcache - fast shutdown
132 | lineinfile: dest=/etc/php/7.1/fpm/php.ini
133 | regexp='opcache.fast_shutdown='
134 | line='opcache.fast_shutdown={{ php_opcache_fast_shutdown }}'
135 | insertafter="^[opcache]"
136 | notify: restart php7-fpm
137 |
--------------------------------------------------------------------------------
/machine/application/app-node/package-lock.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "phanbox-app-node",
3 | "version": "1.0.0",
4 | "lockfileVersion": 1,
5 | "dependencies": {
6 | "bignumber.js": {
7 | "version": "3.1.2",
8 | "resolved": "https://registry.npmjs.org/bignumber.js/-/bignumber.js-3.1.2.tgz",
9 | "integrity": "sha1-8725mtUmihX8HwvtL7AY4mk/4jY="
10 | },
11 | "bluebird": {
12 | "version": "3.5.0",
13 | "resolved": "https://registry.npmjs.org/bluebird/-/bluebird-3.5.0.tgz",
14 | "integrity": "sha1-eRQg1/VR7qKJdFOop3ZT+WYG1nw="
15 | },
16 | "bson": {
17 | "version": "1.0.4",
18 | "resolved": "https://registry.npmjs.org/bson/-/bson-1.0.4.tgz",
19 | "integrity": "sha1-k8ENOeqltYQVy8QFLz5T5WKwtyw="
20 | },
21 | "buffer-shims": {
22 | "version": "1.0.0",
23 | "resolved": "https://registry.npmjs.org/buffer-shims/-/buffer-shims-1.0.0.tgz",
24 | "integrity": "sha1-mXjOMXOIxkmth5MCjDR37wRKi1E="
25 | },
26 | "core-util-is": {
27 | "version": "1.0.2",
28 | "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz",
29 | "integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac="
30 | },
31 | "double-ended-queue": {
32 | "version": "2.1.0-0",
33 | "resolved": "https://registry.npmjs.org/double-ended-queue/-/double-ended-queue-2.1.0-0.tgz",
34 | "integrity": "sha1-ED01J/0xUo9AGIEwyEHv3XgmTlw="
35 | },
36 | "es6-promise": {
37 | "version": "3.2.1",
38 | "resolved": "https://registry.npmjs.org/es6-promise/-/es6-promise-3.2.1.tgz",
39 | "integrity": "sha1-7FYjOGgDKQkgcXDDlEjiREndH8Q="
40 | },
41 | "inherits": {
42 | "version": "2.0.3",
43 | "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz",
44 | "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4="
45 | },
46 | "isarray": {
47 | "version": "0.0.1",
48 | "resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz",
49 | "integrity": "sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8="
50 | },
51 | "moment": {
52 | "version": "2.18.1",
53 | "resolved": "https://registry.npmjs.org/moment/-/moment-2.18.1.tgz",
54 | "integrity": "sha1-w2GT3Tzhwu7SrbfIAtu8d6gbHA8="
55 | },
56 | "mongodb": {
57 | "version": "2.2.29",
58 | "resolved": "https://registry.npmjs.org/mongodb/-/mongodb-2.2.29.tgz",
59 | "integrity": "sha512-MrQvIsN6zN80I4hdFo8w46w51cIqD2FJBGsUfApX9GmjXA1aCclEAJbOHaQWjCtabeWq57S3ECzqEKg/9bdBhA==",
60 | "dependencies": {
61 | "isarray": {
62 | "version": "1.0.0",
63 | "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz",
64 | "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE="
65 | },
66 | "readable-stream": {
67 | "version": "2.2.7",
68 | "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.2.7.tgz",
69 | "integrity": "sha1-BwV6y+JGeyIELTb5jFrVBwVOlbE="
70 | },
71 | "string_decoder": {
72 | "version": "1.0.2",
73 | "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.0.2.tgz",
74 | "integrity": "sha1-sp4fThEl+pehA4K4pTNze3SR4Xk="
75 | }
76 | }
77 | },
78 | "mongodb-core": {
79 | "version": "2.1.13",
80 | "resolved": "https://registry.npmjs.org/mongodb-core/-/mongodb-core-2.1.13.tgz",
81 | "integrity": "sha512-mbcvqLLZwVcpTrsfBDY3hRNk2SDNJWOvKKxFJSc0pnUBhYojymBc/L0THfQsWwKJrkb2nIXSjfFll1mG/I5OqQ=="
82 | },
83 | "mysql": {
84 | "version": "2.13.0",
85 | "resolved": "https://registry.npmjs.org/mysql/-/mysql-2.13.0.tgz",
86 | "integrity": "sha1-mY8fjKRuLj3XFJzpgkE2U5hqrkc="
87 | },
88 | "process-nextick-args": {
89 | "version": "1.0.7",
90 | "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-1.0.7.tgz",
91 | "integrity": "sha1-FQ4gt1ZZCtP5EJPyWk8q2L/zC6M="
92 | },
93 | "readable-stream": {
94 | "version": "1.1.14",
95 | "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.1.14.tgz",
96 | "integrity": "sha1-fPTFTvZI44EwhMY23SB54WbAgdk="
97 | },
98 | "redis": {
99 | "version": "2.7.1",
100 | "resolved": "https://registry.npmjs.org/redis/-/redis-2.7.1.tgz",
101 | "integrity": "sha1-fVb3h1uYsgQQtxU58dh47Vjr9Go="
102 | },
103 | "redis-commands": {
104 | "version": "1.3.1",
105 | "resolved": "https://registry.npmjs.org/redis-commands/-/redis-commands-1.3.1.tgz",
106 | "integrity": "sha1-gdgm9F+pyLIBH0zXoP5ZfSQdRCs="
107 | },
108 | "redis-parser": {
109 | "version": "2.6.0",
110 | "resolved": "https://registry.npmjs.org/redis-parser/-/redis-parser-2.6.0.tgz",
111 | "integrity": "sha1-Uu0J2srBCPGmMcB+m2mUHnoZUEs="
112 | },
113 | "require_optional": {
114 | "version": "1.0.1",
115 | "resolved": "https://registry.npmjs.org/require_optional/-/require_optional-1.0.1.tgz",
116 | "integrity": "sha512-qhM/y57enGWHAe3v/NcwML6a3/vfESLe/sGM2dII+gEO0BpKRUkWZow/tyloNqJyN6kXSl3RyyM8Ll5D/sJP8g=="
117 | },
118 | "resolve-from": {
119 | "version": "2.0.0",
120 | "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-2.0.0.tgz",
121 | "integrity": "sha1-lICrIOlP+h2egKgEx+oUdhGWa1c="
122 | },
123 | "safe-buffer": {
124 | "version": "5.0.1",
125 | "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.0.1.tgz",
126 | "integrity": "sha1-0mPKVGls2KMGtcplUekt5XkY++c="
127 | },
128 | "semver": {
129 | "version": "5.3.0",
130 | "resolved": "https://registry.npmjs.org/semver/-/semver-5.3.0.tgz",
131 | "integrity": "sha1-myzl094C0XxgEq0yaqa00M9U+U8="
132 | },
133 | "sqlstring": {
134 | "version": "2.2.0",
135 | "resolved": "https://registry.npmjs.org/sqlstring/-/sqlstring-2.2.0.tgz",
136 | "integrity": "sha1-wxNcTqirzX5+50GklmqJHYak8ZE="
137 | },
138 | "string_decoder": {
139 | "version": "0.10.31",
140 | "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz",
141 | "integrity": "sha1-YuIDvEF2bGwoyfyEMB2rHFMQ+pQ="
142 | },
143 | "util-deprecate": {
144 | "version": "1.0.2",
145 | "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz",
146 | "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8="
147 | }
148 | }
149 | }
150 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Phanbox - the basic vagrant machine for Node.js and PHP applications
2 |
3 | ### Installation
4 |
5 | * Install [Virtual Box](https://www.virtualbox.org/wiki/Downloads) (>= 5.0 version)
6 | * Install [Vagrant](https://www.vagrantup.com/downloads.html) (>=1.8.5 version)
7 | * Install [Vagrant Host Manager plugin](https://github.com/devopsgroup-io/vagrant-hostmanager) (`vagrant plugin install vagrant-hostmanager`)
8 | * Install [Vagrant Virtual Box guest additions plugin](https://github.com/dotless-de/vagrant-vbguest) (`vagrant plugin install vagrant-vbguest`)
9 | * If your application has too many composer dependencies and github asks for authorization then you need to copy `./ansible/vars/locals.yml.dist` to `./ansible/vars/locals.yml` and put there your GitHub token.
10 | * Run `vagrant up`
11 | * Wait until provisioning is finished...
12 | * If you have Linux or Mac OS X then you'd better perform `vagrant reload` after provisioning is finished to get maximum performance of your vagrant machine
13 |
14 | ### Regular usage:
15 |
16 | * Stop machine: `vagrant suspend` or `vagrant halt` (the later one is the complete shut down)
17 | * Start machine: `vagrant up`
18 | * Reload machine: `vagrant reload`
19 | * Re-provision machine: `vagrant provision` (if any ansible provisioning configurations were changed or updated)
20 |
21 | #### Test virtual hosts:
22 |
23 | * [http://[www].phanbox.local](http://phanbox.local) - PHP application home page (index.php). It also contains healthcheck logic to verify that PHP app is successfully connected to MySQL, MongoDB and Redis.
24 | * [http://phanbox.local/phpinfo.php](http://phanbox.local/phpinfo.php) - PHP info page
25 | * [http://phanbox.local/index.html](http://phanbox.local/index.html) - Static HTML page served by NGINX
26 | * [http://phanbox.local:3000](http://phanbox.local:3000) - Node.js application home page. It also contains healthcheck logic to verify that Node.js app is successfully connected to MySQL, MongoDB and Redis.
27 |
28 | ### What does the box consist of?
29 |
30 | The box is provisioned using [Ansible](https://www.ansible.com/) tool.
31 | The local host directory `./machine` is mounted to `/vagrant` directory inside vagrant machine
32 | The ansible playbook, roles, tasks and other resources are residing in `machine/ansible` directory, while the application specific code - inside `machine/application`.
33 | The provisioned vagrant machine has following items:
34 |
35 | * Ubuntu Xenial64 (16.04 LTS)
36 | * PHP application
37 | - PHP-FPM 7.1
38 | - Nginx
39 | - xDebug
40 | - Composer
41 | - Application root: `machine/application/app-php`
42 | - Document root: `machine/application/app-php/public`
43 | - Environment (APP_ENV): 'development'
44 | * Node.js application
45 | - Node.js 8.x
46 | - npm 5.x
47 | - yarn
48 | - nodemon, gulp, grunt (installed globally)
49 | - Application root: `machine/application/app-node`
50 | - The application is run using `npm start` command
51 | - Port: 3000
52 | - Environment (NODE_ENV): 'development'
53 | - Daemonized with Systemd service i.e. when you are inside vagrant machine you may start/stop/restart it with `sudo service app-node start/stop/restart` command
54 | * MySQL Percona 5.7
55 | * MongoDB 3.4
56 | * Redis 3.x
57 | * [NFS + Cachefilesd](http://chase-seibert.github.io/blog/2014/03/09/vagrant-cachefilesd.html) - for Linux and Mac OS X NFS folder synchronization is enabled
58 |
59 | It may be easily extended and modified with a little knowledge of Ansible.
60 |
61 | #### Vagrant machine default settings (could be changed in Vagrantfile)
62 |
63 | - Hostname: **phanbox.local**
64 | - Allocated CPUs: **4** (cores)
65 | - Allocated Memory: **4096** (MB)
66 | - IP address: **10.10.10.10**
67 |
68 | #### PHP Application
69 |
70 | If you do not need PHP application:
71 |
72 | - Go to `machine/ansible/playbook.yml` and delete **app-php** role from the list
73 | - Go to `machine/ansible/vars/globals.yml` and delete **app_php** section
74 |
75 | If you want to customize it then you may take a look at **app_php** section to modify application/document roots, server name.
76 | It is pretty basic application and you may want to add provisioning logic to it. It is failrly easy to do if you have a little knowledge of Ansible.
77 | All you need is to go to the `machine/ansible/roles/app-php` and add there whatever tasks and logic you need.
78 |
79 | - See machine/ansible/vars/globals.yml
80 |
81 | #### Node.js Application
82 |
83 | If you do not need Node.js application then:
84 |
85 | - Go to `machine/ansible/playbook.yml` and delete **app-node** role from the list
86 | - Go to `machine/ansible/vars/globals.yml` and delete **app_node** section
87 |
88 | To run Node.js application automatically there is systemd service created which is started automatically when vagrant machine is launched.
89 | If you want to interact with the service the you shoud do:
90 |
91 | - `vagrant ssh`
92 | - `sudo service app-node restart` - will restart the node.js app
93 | - `sudo service app-node stop` - will stop the node.js app (for example, you want to run it manually instead)
94 | - `sudo service app-node start` - will start the sevice again
95 | - service logs may be found at `/var/log/app-node.log`
96 |
97 | If you want to customize it then you may take a look at **app_node** section to modify application root, port, systemd service name, environment.
98 | It is pretty basic application and you may want to add provisioning logic to it. It is failrly easy to do if you have a little knowledge of Ansible.
99 | All you need is to go to the `machine/ansible/roles/app-node` and add there whatever tasks and logic you need.
100 |
101 | #### MySQL
102 |
103 | If you do not need MySQL for your application:
104 |
105 | - Go to `machine/ansible/playbook.yml` and delete **mysql** role from the list
106 | - Go to `machine/ansible/vars/globals.yml` and delete **mysql** section
107 |
108 | The default parameters for mysql server:
109 |
110 | - User: **app**
111 | - Password: **app**
112 | - Database: **app**
113 | - ROOT PASSWORD: **password**
114 | - Database dump file (will be imported only once during the first provisioning): `machine/dump/mysql.sql`
115 |
116 | If you want to customize these parameters see `machine/ansible/vars/globals.yml` **mysql** section
117 |
118 | #### MongoDB
119 |
120 | If you do not need MongoDB for your application:
121 |
122 | - Go to `machine/ansible/playbook.yml` and delete **mongodb** role from the list
123 | - Go to `machine/ansible/vars/globals.yml` and delete **mongodb** section
124 |
125 | The default parameters for MongoDB server:
126 |
127 | - User: **app**
128 | - Password: **app**
129 | - Database: **app**
130 | - ROOT PASSWORD: **password**
131 | - Database dump directory (will be imported only once during the first provisioning): `machine/dump/mongodb` -
132 | this directory should contain 1 file per MongoDB collection where the file name is a collection name (with omitted .json extension)
133 | - If your MongoDB dump was exported without [--jsonArray flag](https://docs.mongodb.com/manual/reference/program/mongoexport/#cmdoption-jsonarray) then you should set `dump_array_mode: true` in `machine/ansible/vars/globals.yml` file.
134 |
135 | If you want to customize these parameters see `machine/ansible/vars/globals.yml` **mysql** section
136 |
--------------------------------------------------------------------------------
/machine/application/app-php/composer.lock:
--------------------------------------------------------------------------------
1 | {
2 | "_readme": [
3 | "This file locks the dependencies of your project to a known state",
4 | "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
5 | "This file is @generated automatically"
6 | ],
7 | "content-hash": "48c7bf5f3a6f2f228f984faa7fbaa9ae",
8 | "packages": [
9 | {
10 | "name": "mongodb/mongodb",
11 | "version": "1.1.2",
12 | "source": {
13 | "type": "git",
14 | "url": "https://github.com/mongodb/mongo-php-library.git",
15 | "reference": "a307dd60e71e1291c60927ea4f3a1905146063f5"
16 | },
17 | "dist": {
18 | "type": "zip",
19 | "url": "https://api.github.com/repos/mongodb/mongo-php-library/zipball/a307dd60e71e1291c60927ea4f3a1905146063f5",
20 | "reference": "a307dd60e71e1291c60927ea4f3a1905146063f5",
21 | "shasum": ""
22 | },
23 | "require": {
24 | "ext-mongodb": "^1.2.0",
25 | "php": ">=5.4"
26 | },
27 | "require-dev": {
28 | "phpunit/phpunit": "^4.8"
29 | },
30 | "type": "library",
31 | "autoload": {
32 | "psr-4": {
33 | "MongoDB\\": "src/"
34 | },
35 | "files": [
36 | "src/functions.php"
37 | ]
38 | },
39 | "notification-url": "https://packagist.org/downloads/",
40 | "license": [
41 | "Apache-2.0"
42 | ],
43 | "authors": [
44 | {
45 | "name": "Jeremy Mikola",
46 | "email": "jmikola@gmail.com"
47 | },
48 | {
49 | "name": "Hannes Magnusson",
50 | "email": "bjori@mongodb.com"
51 | },
52 | {
53 | "name": "Derick Rethans",
54 | "email": "github@derickrethans.nl"
55 | }
56 | ],
57 | "description": "MongoDB driver library",
58 | "homepage": "https://jira.mongodb.org/browse/PHPLIB",
59 | "keywords": [
60 | "database",
61 | "driver",
62 | "mongodb",
63 | "persistence"
64 | ],
65 | "time": "2017-02-16T18:40:32+00:00"
66 | },
67 | {
68 | "name": "nesbot/carbon",
69 | "version": "1.22.1",
70 | "source": {
71 | "type": "git",
72 | "url": "https://github.com/briannesbitt/Carbon.git",
73 | "reference": "7cdf42c0b1cc763ab7e4c33c47a24e27c66bfccc"
74 | },
75 | "dist": {
76 | "type": "zip",
77 | "url": "https://api.github.com/repos/briannesbitt/Carbon/zipball/7cdf42c0b1cc763ab7e4c33c47a24e27c66bfccc",
78 | "reference": "7cdf42c0b1cc763ab7e4c33c47a24e27c66bfccc",
79 | "shasum": ""
80 | },
81 | "require": {
82 | "php": ">=5.3.0",
83 | "symfony/translation": "~2.6 || ~3.0"
84 | },
85 | "require-dev": {
86 | "friendsofphp/php-cs-fixer": "~2",
87 | "phpunit/phpunit": "~4.0 || ~5.0"
88 | },
89 | "type": "library",
90 | "extra": {
91 | "branch-alias": {
92 | "dev-master": "1.23-dev"
93 | }
94 | },
95 | "autoload": {
96 | "psr-4": {
97 | "Carbon\\": "src/Carbon/"
98 | }
99 | },
100 | "notification-url": "https://packagist.org/downloads/",
101 | "license": [
102 | "MIT"
103 | ],
104 | "authors": [
105 | {
106 | "name": "Brian Nesbitt",
107 | "email": "brian@nesbot.com",
108 | "homepage": "http://nesbot.com"
109 | }
110 | ],
111 | "description": "A simple API extension for DateTime.",
112 | "homepage": "http://carbon.nesbot.com",
113 | "keywords": [
114 | "date",
115 | "datetime",
116 | "time"
117 | ],
118 | "time": "2017-01-16T07:55:07+00:00"
119 | },
120 | {
121 | "name": "symfony/polyfill-mbstring",
122 | "version": "v1.4.0",
123 | "source": {
124 | "type": "git",
125 | "url": "https://github.com/symfony/polyfill-mbstring.git",
126 | "reference": "f29dca382a6485c3cbe6379f0c61230167681937"
127 | },
128 | "dist": {
129 | "type": "zip",
130 | "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/f29dca382a6485c3cbe6379f0c61230167681937",
131 | "reference": "f29dca382a6485c3cbe6379f0c61230167681937",
132 | "shasum": ""
133 | },
134 | "require": {
135 | "php": ">=5.3.3"
136 | },
137 | "suggest": {
138 | "ext-mbstring": "For best performance"
139 | },
140 | "type": "library",
141 | "extra": {
142 | "branch-alias": {
143 | "dev-master": "1.4-dev"
144 | }
145 | },
146 | "autoload": {
147 | "psr-4": {
148 | "Symfony\\Polyfill\\Mbstring\\": ""
149 | },
150 | "files": [
151 | "bootstrap.php"
152 | ]
153 | },
154 | "notification-url": "https://packagist.org/downloads/",
155 | "license": [
156 | "MIT"
157 | ],
158 | "authors": [
159 | {
160 | "name": "Nicolas Grekas",
161 | "email": "p@tchwork.com"
162 | },
163 | {
164 | "name": "Symfony Community",
165 | "homepage": "https://symfony.com/contributors"
166 | }
167 | ],
168 | "description": "Symfony polyfill for the Mbstring extension",
169 | "homepage": "https://symfony.com",
170 | "keywords": [
171 | "compatibility",
172 | "mbstring",
173 | "polyfill",
174 | "portable",
175 | "shim"
176 | ],
177 | "time": "2017-06-09T14:24:12+00:00"
178 | },
179 | {
180 | "name": "symfony/translation",
181 | "version": "v3.3.2",
182 | "source": {
183 | "type": "git",
184 | "url": "https://github.com/symfony/translation.git",
185 | "reference": "dc3b2a0c6cfff60327ba1c043a82092735397543"
186 | },
187 | "dist": {
188 | "type": "zip",
189 | "url": "https://api.github.com/repos/symfony/translation/zipball/dc3b2a0c6cfff60327ba1c043a82092735397543",
190 | "reference": "dc3b2a0c6cfff60327ba1c043a82092735397543",
191 | "shasum": ""
192 | },
193 | "require": {
194 | "php": ">=5.5.9",
195 | "symfony/polyfill-mbstring": "~1.0"
196 | },
197 | "conflict": {
198 | "symfony/config": "<2.8",
199 | "symfony/yaml": "<3.3"
200 | },
201 | "require-dev": {
202 | "psr/log": "~1.0",
203 | "symfony/config": "~2.8|~3.0",
204 | "symfony/intl": "^2.8.18|^3.2.5",
205 | "symfony/yaml": "~3.3"
206 | },
207 | "suggest": {
208 | "psr/log": "To use logging capability in translator",
209 | "symfony/config": "",
210 | "symfony/yaml": ""
211 | },
212 | "type": "library",
213 | "extra": {
214 | "branch-alias": {
215 | "dev-master": "3.3-dev"
216 | }
217 | },
218 | "autoload": {
219 | "psr-4": {
220 | "Symfony\\Component\\Translation\\": ""
221 | },
222 | "exclude-from-classmap": [
223 | "/Tests/"
224 | ]
225 | },
226 | "notification-url": "https://packagist.org/downloads/",
227 | "license": [
228 | "MIT"
229 | ],
230 | "authors": [
231 | {
232 | "name": "Fabien Potencier",
233 | "email": "fabien@symfony.com"
234 | },
235 | {
236 | "name": "Symfony Community",
237 | "homepage": "https://symfony.com/contributors"
238 | }
239 | ],
240 | "description": "Symfony Translation Component",
241 | "homepage": "https://symfony.com",
242 | "time": "2017-05-22T07:42:36+00:00"
243 | }
244 | ],
245 | "packages-dev": [],
246 | "aliases": [],
247 | "minimum-stability": "stable",
248 | "stability-flags": [],
249 | "prefer-stable": false,
250 | "prefer-lowest": false,
251 | "platform": {
252 | "php": "^7.1"
253 | },
254 | "platform-dev": []
255 | }
256 |
--------------------------------------------------------------------------------