Also: - Updated links in Vagrantfile - Applied some basic rubocop rules to the Vagrantfile
7.0 KiB
Install Fab-manager in a development environment with Docker
This document will guide you through all the steps needed to set up a development environment for Fab-manager.
Table of contents
- General Guidelines
- PostgreSQL
- ElasticSearch
3.1. Rebuild statistics
3.2. Backup and Restore 3.3. Debugging
This procedure is not easy to follow so if you don't need to write some code for Fab-manager, please prefer the production installation method.
General Guidelines
-
Install RVM, with the ruby version specified in the .ruby-version file. For more details about the process, please read the official RVM documentation
-
Install NVM, with the node.js version specified in the .nvmrc file. For instructions about installing NVM, please refer to the NVM readme.
-
Install Yarn, the front-end package manager. Depending on your system, the installation process may differ, please read the official Yarn documentation.
-
Install docker. Your system may provide a pre-packaged version of docker in its repositories, but this version may be outdated. Please refer to ubuntu, debian or MacOS documentation to setup a recent version of docker.
-
Add your current user to the docker group, to allow using docker without
sudo
.# add the docker group if it doesn't already exist sudo groupadd docker # add the current user to the docker group sudo usermod -aG docker $(whoami) # restart to validate changes sudo reboot
-
Retrieve the project from Git
git clone https://github.com/sleede/fab-manager.git
-
Move into the project directory and install the docker-based dependencies.
⚠ If you are using MacOS X, you must first edit the files located in docker/development to use port binding instead of ip-based binding. This can be achieved by uncommenting the "port" directives and commenting the "networks" directives in the docker-compose.yml file. The hosts file must be modified too, accordingly.
cd fab-manager
cat docker/development/hosts | sudo tee -a /etc/hosts
mkdir -p .docker/elasticsearch/config
cp docker/development/docker-compose.yml .docker
cp docker/elasticsearch.yml .docker/elasticsearch/config
cp docker/log4j2.properties .docker/elasticsearch/config
cd .docker
docker-compose up -d
cd -
-
Install the other dependencies.
- For Ubuntu/Debian:
# on Ubuntu 18.04 server, you may have to enable the "universe" repository sudo add-apt-repository universe # then, install the dependencies sudo apt-get install libpq-dev imagemagick
- For MacOS X:
brew install imagemagick
-
Init the RVM and NVM instances and check they were correctly configured
rvm current | grep -q `cat .ruby-version`@fab-manager && echo "ok" # Must print ok nvm use node --version | grep -q `cat .nvmrc` && echo "ok" # Must print ok
If one of these commands does not print "ok", then try to input
rvm use
ornvm use
10. Install bundler in the current RVM gemset
```bash
gem install bundler --version=1.17.3
- Install the required ruby gems and javascript plugins
bundle install
yarn install
- Create the default configuration files and configure them! (see the environment configuration documentation)
cp config/database.yml.default config/database.yml
cp env.example .env
vi .env
# or use your favorite text editor instead of vi (nano, ne...)
- Build the databases.
⚠ Warning: DO NOT run
rails db:setup
instead of these commands, as this will not run some required raw SQL instructions.
🛈 Please note: Your password length must be between 8 and 128 characters, otherwise db:seed will be rejected. This is configured in config/initializers/devise.rb
# for dev
rails db:create
rails db:migrate
ADMIN_EMAIL='youradminemail' ADMIN_PASSWORD='youradminpassword' rails db:seed
rails fablab:es:build_stats
# for tests
RAILS_ENV=test rails db:create
RAILS_ENV=test rails db:migrate
- Create the pids folder used by Sidekiq. If you want to use a different location, you can configure it in
config/sidekiq.yml
mkdir -p tmp/pids
- Start the development web server
foreman s -p 5000
-
You should now be able to access your local development Fab-manager instance by accessing
http://localhost:3000
in your web browser. -
You can login as the default administrator using the credentials defined previously.
-
Email notifications will be caught by MailCatcher. To see the emails sent by the platform, open your web browser at
http://fabmanager-mailcatcher:1080
to access the MailCatcher interface.
PostgreSQL
Some information about PostgreSQL usage in fab-manager is available in the PostgreSQL Readme.
ElasticSearch
ElasticSearch is a powerful search engine based on Apache Lucene combined with a NoSQL database used as a cache to index data and quickly process complex requests on it.
In FabManager, it is used for the admin's statistics module and to perform searches in projects.
The organisation if the data in the ElasticSearch database is documented in elasticsearch.md
Rebuild statistics
Every nights, the statistics for the day that just ended are built automatically at 01:00 (AM) and stored in ElasticSearch. See schedule.yml to modify this behavior. If the scheduled task wasn't executed for any reason (eg. you are in a dev environment and your computer was turned off at 1 AM), you can force the statistics data generation in ElasticSearch, running the following command.
# Here for the 50 last days
rails fablab:es:generate_stats[50]
Backup and Restore
To backup and restore the ElasticSearch database, use the elasticsearch-dump tool.
Dump the database with: elasticdump --input=http://localhost:9200/stats --output=fablab_stats.json
.
Restore it with: elasticdump --input=fablab_stats.json --output=http://localhost:9200/stats
.
Debugging
In development, visit http://fabmanager-kibana:5601 to use Kibana, the web UI for ElasticSearch