Follow the steps below in order to setup our project locally.
For macOS users: You can try running
make setup-macin the root directory. That command will essentially do everything that thisREADMEtells you do to, but we can't guarantee that it works.
A Github Personal Access Token (PAT) is required to run this script. You can make one here https://github.com/settings/tokens/new. Tick scopes repo, read:org and admin:public_key), then store the token somewhere safe (Github will never show it again).
Copy these commands (press button on the right-hand side of the block) and run from the directory you would clone the project.
read -s -p "Github PAT token: " TOKEN ; X_INTERACTIVE=n /bin/bash -c "$(curl -fsSL https://$TOKEN@raw.githubusercontent.com/Samfundet/Samfundet/master/{bash_utils.sh,install.sh})" && . ~/.bash_profile && cd Samfundet ; unset TOKEN ; unset X_INTERACTIVE;read -s -p "Github PAT token: " TOKEN ; X_INTERACTIVE=y /bin/bash -c "$(curl -fsSL https://$TOKEN@raw.githubusercontent.com/Samfundet/Samfundet/master/{bash_utils.sh,install.sh})" && . ~/.bash_profile && cd Samfundet ; unset TOKEN ; unset X_INTERACTIVE;Details
- X_INTERACTIVE (y/n) determines how many prompts you receive before performing an action.
- Fetches files {bash_utils.sh, install.sh} and runs bash.
- f: fail fast
- s: silent, no progress-meter
- S: show error on fail
- L: follow redirect
Clone our main repository:
git clone https://github.com/Samfundet/Samfundet.gitWe 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.gitThere 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
- Go to your terminal preferences, and select your terminal profile. Go to the "Commands" tab and check "Run command as a login shell".
-
Make sure you have navigated to the project directory in the terminal. Then run the following script: (copy and paste into terminal)
./linux-prerequisites.sh
This will make a script run, that will install a few dependencies for you. A restart is however required after running this script, so restart your computer before proceeding to step 3.
-
Navigate back to the project and run the following script:
./linux-setup-rvm.sh
A restart is also required after running this script. Restart before proceeding to step 4.
-
Navigate back to the project and run the following script:
./linux-setup-database.sh
After this script has completed, the project should be up and running!
- graphviz:
sudo apt-get install graphviz - imagemagick:
sudo apt-get install imagemagick - nodejs:
sudo apt-get install nodejs - ubuntu_rvm
- Source RVM:
source ~/.rvm/scripts/rvm
We now have all dependencies installed, including RVM, so let's install Ruby 2.7.6. Run these two commands in succession:
rvm install 2.7.6 --movable
rvm use 2.7.6 --defaultWe 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 'samfundet';\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-filesThen, setup the database with
bundle exec rails db:setupYou 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-hooksThis will add symbolic links in .git/hooks from the hooks dir.
MIT © Samfundet.no project authors


