Follow the steps below in order to setup our project locally.
For macOS users: You can try running
make setup-mac
in the root directory. That command will essentially do everything that thisREADME
tells you do to, but we can't guarantee that it works.
Clone our main repository:
git clone https://github.com/Samfundet/Samfundet.git
We also use two other repositories, SamfundetAuth and SamfundetDomain. These can be cloned with the following commands:
# SamfundetAuth
git clone https://github.com/Samfundet/SamfundetAuth.git
# SamfundetDomain
git clone https://github.com/Samfundet/SamfundetDomain.git
There are several dependencies needed to get Samfundet up and running. Note that RVM is a Ruby version manager used for handling different Ruby versions, but you can use others as well (like rbenv).
- Homebrew:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
- imagemagick:
brew install imagemagick
- graphviz:
brew install graphviz
- RVM
- graphviz:
sudo apt-get install graphviz
- ubuntu_rvm
- Source RVM:
source ~/.rvm/scripts/rvm
We now have all dependencies installed, including RVM, so let's install Ruby 2.5.5. Run these two commands in succession:
rvm install 2.5.5
rvm use 2.5.5 --default
First, we must pick an appropriate development database password that we'll use later:
# Replace '.bashrc' with '.zshrc' if you use ZSH
echo 'export SAMFDB_DEV_PASS="<PASSWORD-GOES-HERE>"' >> ~/.bashrc
source ~/.bashrc
We use PostgreSQL as our database. There are several ways it can be installed depending on your operating system.
- Install PostgreSQL:
sudo apt-get install postgresql postgresql-contrib libpq-dev
- Create the PostgreSQL user:
echo -e "CREATE USER samfundet WITH PASSWORD '$SAMFDB_DEV_PASS';\nALTER USER samfundet CREATEDB;" | sudo -u postgres psql
- Install Docker Engine and Docker Compose.
- Start the database:
docker-compose up -d
- Install PostgreSQL:
sudo apt-get install libpq-dev
- Install the PostgreSQL macOS application.
- Install Docker:
brew cask install docker
- Start the database:
docker-compose up -d
- Install PostgreSQL:
brew install postgresql
Samfundet depends on several Ruby dependencies called gems that are listed in our Gemfile
. To install these, run
bundle install # or just 'bundle' or 'bundler'
First, there are some configuration files that needs to be copied. Run
make copy-config-files
Only for Linux users:
sed -i "s/password:.*/password: $SAMFDB_DEV_PASS/" > config/database.yml
Then, setup the database with
bundle exec rails db:setup
You are now ready to start the server. Run
make run # which executes 'bundle exec rails server'
You can optionally add checks before commits et cetera through git/hooks
. To apply them run
make git-hooks
This will add symbolic links in .git/hooks from the hooks dir.
MIT © Samfundet.no project authors