-
-
Notifications
You must be signed in to change notification settings - Fork 725
Development Environment Setup: Ubuntu
This guide will help you set up a development environment for OFN on Ubuntu 22.04 LTS or Ubuntu 20.04 LTS.
This section is based on instructions here (22.04) and here (20.04). Those instructions include a section on configuring git. That is optional, but may be useful to you. Rails does not need to be installed now. It is installed by a setup script in a later step.
The version of Ruby used in OFN is shown here. At the time of writing it is 3.1.4. If it has changed, the commands below starting with rbenv
will need to be adjusted (and this guide updated).
The version of Node is shown here. It's recommended to install nodenv to ensure you have the matching version. Here is a great script to install it: Installing nodenv on Ubuntu. Alternatively you can install as per below. We are using imagemagick and libvips for image processing.
sudo apt install curl
curl -sL https://deb.nodesource.com/setup_lts.x | sudo -E bash -
curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
sudo apt update
sudo apt install git-core zlib1g-dev build-essential libssl-dev libreadline-dev libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt1-dev libcurl4-openssl-dev software-properties-common libffi-dev nodejs yarn imagemagick libvips
cd
git clone https://github.com/rbenv/rbenv.git ~/.rbenv
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc
echo 'eval "$(rbenv init -)"' >> ~/.bashrc
exec $SHELL
git clone https://github.com/rbenv/ruby-build.git ~/.rbenv/plugins/ruby-build
echo 'export PATH="$HOME/.rbenv/plugins/ruby-build/bin:$PATH"' >> ~/.bashrc
exec $SHELL
rbenv install 3.1.4
rbenv global 3.1.4
gem install bundler
rbenv rehash
This will install PostgreSQL, the database that OFN uses, and Redis, which is used for caching. It also installs a supporting library for PostgreSQL.
sudo apt install postgresql redis-server libpq-dev
As per the Getting Started document, fork the OFN repo then enter the following to clone it and set up the database superuser.
cd
git clone https://github.com/YOUR_GITHUB_USERNAME_HERE/openfoodnetwork
cd openfoodnetwork
git remote add upstream https://github.com/openfoodfoundation/openfoodnetwork
git fetch upstream master
sudo -u postgres psql -c "CREATE USER ofn WITH SUPERUSER CREATEDB PASSWORD 'f00d'"
The next step is to run the setup script:
script/setup
Check the console output for error messages. Here are hints how to fix them. Then run the script again.
-
Unable to connect to server: could not connect to server: Connection refused : Is the server running on host "localhost" and accepting TCP/IP connections on port 5432?
- Look for the port number in the message and make sure that the same port is set in the
postgresql.conf
file. You should find the file in/etc/postgresql/<version>/main
. - Restart PostgreSQL by running
sudo service postgresql restart
- Look for the port number in the message and make sure that the same port is set in the
-
Error: EACCES: permission denied, access '<SOME_PATH>'
- Maybe the best way is to run the script as sudo, I haven't tried that. For me the steps below worked - probably not recommended.
- You can check the access rights with
ls -la '<SOME_PATH>'
. - Change ownership to your user with
sudo chown -R <$USER> <SOME_PATH>
.
The script above does not install foreman, which is used to start the dev server. Install it with
gem install foreman
Exit your shell and reopen it for the setting to take effect. You can then run the dev server with
foreman start
Chrome or Chromium is used for UI testing. This is automated using a driver. Install them with
sudo apt install -y chromium-browser
sudo apt install -y chromium-chromedriver
Tests, both unit and integration, are based on RSpec. To run the test suite, first prepare the test database:
bundle exec rake db:test:prepare
For more details on testing, please check that section of the GETTING_STARTED guide.
Development environment setup
- Pipeline development process
- Bug severity
- Feature template (epic)
- Internationalisation (i18n)
- Dependency updates
Development
- Developer Guidelines
- The process of review, test, merge and deploy
- Making a great commit
- Making a great pull request
- Code Conventions
- Database migrations
- Testing and Rspec Tips
- Automated Testing Gotchas
- Rubocop
- Angular and OFN
- Feature toggles
- Stimulus and Turbo
Testing
- Testing process
- OFN Testing Documentation (Handbooks)
- Continuous Integration
- Parallelized test suite with knapsack
- Karma
Releasing
Specific features
Data and APIs
Instance-specific configuration
External services
Design