21
1
Fork 0
mirror of https://github.com/Evolix/chexpire.git synced 2024-04-28 23:10:49 +02:00
chexpire/INSTALL.md

101 lines
4.4 KiB
Markdown
Raw Permalink Normal View History

2018-05-24 13:46:20 +02:00
# Installation
2018-06-09 13:29:39 +02:00
## Requirements
Chexpire requires :
* Ruby 2.5.1 and Bundler
* NodeJS and Yarn
* MySQL or MariaDB
We are usually running Chexpire on typical POSIX servers like :
2018-06-09 13:29:39 +02:00
- Linux Debian 9, Ruby 2.5.1, NodeJS 8.11 and MariaDB 10.1
- macOS High Sierra, Ruby 2.5.1, NodeJS 10.2.1 and MariaDB 10.2
It probably works on any system that supports Ruby >2.3, NodeJS >6 and MySQL >5.5. Feel free to report any unexpected incompatibilities.
2018-06-09 13:29:39 +02:00
If you are familiar with Ansible, you can use our [Ansible roles](http://forge.evolix.org/projects/ansible-roles) to easily install the requirements : rbenv, mysql, nodejs. Add this to your playbook :
2018-06-09 13:29:39 +02:00
```
[…]
roles:
- mysql
- { role: rbenv, username: "{{ ansible_user }}", rbenv_ruby_version: "2.5.1" }
- { role: nodejs, nodejs_install_yarn: yes }
[…]
```
> NB: the Rbenv `username` variable points to the user that you want to install Rbenv for. If you use this user for the SSH connection of Ansible, you can leave the `{{ ansible_user }}` value.
2018-06-09 13:29:39 +02:00
If you want to do manual installations, you can use our Wiki documentations for [Rbenv](https://github.com/rbenv/rbenv/#installation), [NodeJS](https://wiki.evolix.org/HowtoNodeJS#installation), [Yarn](https://wiki.evolix.org/HowtoNodeJS#yarn) and [MariaDB](https://wiki.evolix.org/HowtoMySQL#installation).
2018-06-09 13:29:39 +02:00
## Dependencies
Execute `# bundle install` to install Ruby gems (including Rails itself).
Execute `# yarn install` to install Javascript/NodeJS packages.
Depending on what is already installed on your OS or not, you might need to install a few system packages to be able to have everything working.
### libsodium
To use elliptic curve SSH keys, we need to have `libsodium` and its headers.
* on Debian : `# apt install libsodium-dev`.
* on macOS with Homebrew : `# brew install libsodium`.
2018-06-09 13:29:39 +02:00
## Rails configuration
After cloning this repository, you have to create and edit a few files from example or defaults files, for your local development configuration :
2018-05-24 13:46:20 +02:00
- `config/database.yml`
- `config/secrets.yml`
- `config/chexpire.yml` : set at least the `mailer_default_from` and `host` variables. See other configuration overridable in `config/chexpire.defaults.yml`.
Theses files will be ignored by git.
2018-05-24 13:46:20 +02:00
2018-06-09 13:29:39 +02:00
## Database
2018-06-09 13:29:39 +02:00
You need databases for development and tests. You can create them like this (once connected to you MySQL server) :
2018-06-09 13:29:39 +02:00
```
MariaDB [none]> CREATE DATABASE `chexpire_development`;
MariaDB [none]> CREATE DATABASE `chexpire_test`;
```
2018-06-09 13:29:39 +02:00
If you don't want to use the default `root` MySQL user with no password, you can create users :
```
MariaDB [none]> GRANT ALL PRIVILEGES ON `chexpire_development`.* TO `chexpire_development`@localhost IDENTIFIED BY 'MY_PASSWORD_FOR_DEV';
MariaDB [none]> GRANT ALL PRIVILEGES ON `chexpire_test`.* TO `chexpire_test`@localhost IDENTIFIED BY 'MY_PASSWORD_FOR_TEST';
MariaDB [none]> FLUSH PRIVILEGES;
```
Don't forget to adapt the settings in `config/database.yml` accordingly.
2018-06-09 13:29:39 +02:00
Also, on Debian 9 with MariaDB, the database socket is at `/var/run/mysqld/mysqld.sock`, which is not the default in the configuration file.
You must run the migrations with `# bundle exec rails db:migrate` (for the default environment development) and `# bundle exec rails db:migrate RAILS_ENV=test` (for the test environment).
2018-06-09 13:29:39 +02:00
## Tests
The test suite can be run with `# bundle exec rails test`.
This will also generate a code coverage report in `coverage/index.html`.
2018-06-09 13:29:39 +02:00
With `# bundle exec guard` your test suite is run completely a first time, then once for each file you change and save. Take a look at https://guardgem.org for more information.
To execute Rubocop (the style-guide linter for Ruby), run `# bundle exec rubocop`.
2018-06-09 13:29:39 +02:00
## Local execution
If you want to start the Rails application manually, with a simple Puma configuration, you have to execute `# bundle exec rails server`. You will be able to open http://127.0.0.1:3000 in your browser and see Chexpire in action.
2018-05-24 13:46:20 +02:00
## Deployment
**staging** and **production** environments are preconfigured. You can use any of them or add more if you want.
2018-05-24 13:46:20 +02:00
### Capistrano
2018-06-12 22:38:09 +02:00
If you want to use capistrano for deployment, yout need to create `config/deploy/config.yml` from the example file, and use the `script/to_staging` and/or `script/to_production` scripts.
2018-05-24 13:46:20 +02:00
The same way you've created the config files for development, you'll have to do the same on the staging and production servers in the `shared/config/` directory,relative to your `deploy_to` path.